shift-identifiers
shift-identifiers -----------------
Last updated 6 years ago by jsoverson .
ISC · Original npm · Tarball · package.json
$ cnpm install shift-identifiers 
SYNC missed versions from official npm registry.

shift-identifiers

Find all the identifiers and their closest matches in a source file.

Why?

Curiosity.

It may be useful to expose similarities in identifiers across an entire source file to find out where there is inconsistent naming or where there may be pockets of similar code.

Usage

You can use the executable, but it's not really useful outside of quick testing.

$ ./bin/shift-identifiers jquery.js

/bin/shift-identifiers vendor/jquery/dist/jquery.js
{ selector: [ 'toSelector', 'select', 'selectors', 'selection', 'selected' ],
  toSelector: [ 'selector', 'newSelector', 'postSelector' ],
  select: [ 'selector' ],
  selectors: [ 'selector', 'selection', 'selected' ],
  selection: [ 'selector', 'selectors', 'collection', 'selected' ],
  selected: [ 'selector', 'selectors', 'related', 'selection' ],
  context: [ 'text', 'concat', 'contexts', 'next', 'content', 'contents' ],
  text: [ 'context' ],
  concat: [ 'context' ],
  contexts: [ 'context', 'contains', 'content', 'contents' ],
  next: [ 'context' ],
  content:
   [ 'context',
     'contains',
     'contexts',
     'condense',
     'contents',
     'current' ],
  contents: [ 'context', 'contains', 'contexts', 'condense', 'content' ],
  arguments: [ 'argument' ],
  argument: [ 'arguments', 'document', 'fragment' ],
  options: [ 'opts', 'option', 'optionSet' ],
  opts: [ 'options' ],
  option: [ 'options' ],
  optionSet: [ 'options' ],
  undefined: [ 'strundefined', 'define' ],
  strundefined: [ 'undefined' ],
  define: [ 'undefined' ],
  document: [ 'argument' ],
  indirect: [ 'inspect' ],
  inspect: [ 'indirect', 'inspected' ],
  results: [ 'result', 'resolve' ],
  result: [ 'results' ],
  resolve: [ 'results', 'rescape', 'response' ],
  indexOf: [ 'index' ],
  index: [ 'indexOf' ],
  matches:
   [ 'match',
     'cache',
     'matched',
     'matcher',
     'unmatched',
     'cached',
     'matchers',
     'matcherIn',
     'attaches' ],
  match: [ 'matches' ],
  cache: [ 'matches' ],
  matched:
   [ 'matches',
     'matcher',
     'unmatched',
     'cached',
     'matchers',
     'mapped',
     'matcherIn',
     'method' ],
  matcher:
   [ 'matches',
     'matchExpr',
     'matched',
     'unmatched',
     'cached',
     'matchers',
     'matcherIn',
     'matcherOut' ],
  unmatched: [ 'matches', 'matched', 'matcher' ],
  cached: [ 'matches', 'matched', 'matcher' ],
  matchers: [ 'matches', 'matched', 'matcher', 'matcherIn', 'matcherOut' ],
  matcherIn: [ 'matches', 'matched', 'matcher', 'matchers', 'matcherOut' ],
  attaches: [ 'matches' ],
  whitespace: [ 'rwhitespace' ],
  rwhitespace: [ 'whitespace' ],
  identifier: [ 'ridentifier' ],
  ridentifier: [ 'identifier' ],
  pseudos: [ 'rpseudo', 'pseudo' ],
  rpseudo: [ 'pseudos', 'pseudo' ],
  pseudo: [ 'pseudos', 'rpseudo' ],
  escaped: [ 'rescape', 'eased', 'scale' ],
  rescape: [ 'escaped', 'runescape', 'funescape', 'resolve', 'scale' ],
  eased: [ 'escaped', 'related' ],
  scale: [ 'escaped', 'rescape' ],
  nodeType: [ 'nodeName', 'ofType', 'nType' ],
  nodeName: [ 'nodeType', 'doneName' ],
  ofType: [ 'nodeType' ],
  nType: [ 'nodeType' ],
  contains: [ 'contexts', 'content', 'container', 'contents' ],
  container: [ 'contains' ],
  expando: [ 'expanded' ],
  expanded: [ 'expando' ],
  newContext: [ 'testContext' ],
  testContext: [ 'newContext' ],
  newSelector: [ 'toSelector' ],
  tokenize: [ 'tokens', 'token' ],
  tokens: [ 'tokenize' ],
  token: [ 'tokenize' ],
  runescape: [ 'rescape', 'funescape' ],
  funescape: [ 'rescape', 'runescape' ],
  postSelector: [ 'toSelector' ],
  rsibling: [ 'sibling' ],
  sibling: [ 'rsibling', 'firing' ],
  handler: [ 'handleObj', 'handlers', 'handle' ],
  handleObj: [ 'handler', 'handleObjIn', 'handlers', 'handle' ],
  handlers: [ 'handler', 'handleObj', 'handle', 'headers' ],
  handle: [ 'handler', 'handleObj', 'handlers' ],
  fragment: [ 'argument' ],
  docElem: [ 'curElem' ],
  curElem: [ 'docElem' ],
  className: [ 'classCache', 'capName', 'classNames' ],
  classCache: [ 'className' ],
  capName: [ 'className', 'rtagName', 'propName' ],
  classNames: [ 'className', 'classes' ],
  compare: [ 'compile', 'compiled', 'computed', 'complete' ],
  compile: [ 'compare', 'compiled', 'computed', 'complete' ],
  compiled: [ 'compare', 'compile', 'completed', 'computed', 'complete' ],
  computed: [ 'compare', 'compile', 'compiled', 'completed', 'complete' ],
  complete: [ 'compare', 'compile', 'compiled', 'completed', 'computed' ],
  elements: [ 'elemData', 'events', 'refElements' ],
  elemData: [ 'elements', 'elemLang', 'keepData' ],
  events: [ 'elements' ],
  refElements: [ 'elements', 'destElements', 'srcElements' ],
  getText: [ 'getter' ],
  getter: [ 'getText', 'pattern' ],
  matchExpr: [ 'matcher' ],
  doneName: [ 'nodeName', 'funcName' ],
  pattern: [ 'attr', 'setter', 'getter' ],
  attr: [ 'pattern' ],
  setter: [ 'pattern' ],
  useCache: [ 'outerCache', 'oldCache', 'newCache' ],
  outerCache: [ 'useCache' ],
  oldCache: [ 'useCache', 'newCache' ],
  newCache: [ 'useCache', 'oldCache' ],
  dirruns: [ 'rrun' ],
  rrun: [ 'dirruns' ],
  mapped: [ 'matched' ],
  method: [ 'matched' ],
  matcherOut: [ 'matcher', 'matchers', 'matcherIn' ],
  elemLang: [ 'elemData' ],
  rheader: [ 'rheaders', 'headers' ],
  rheaders: [ 'rheader', 'headers' ],
  headers: [ 'rheader', 'handlers', 'rheaders' ],
  setFilters: [ 'preFilters' ],
  preFilters: [ 'setFilters', 'preFilter', 'propFilter', 'prefilters' ],
  preFilter: [ 'preFilters', 'postFilter', 'propFilter', 'prefilters' ],
  propFilter: [ 'preFilters', 'postFilter', 'preFilter' ],
  prefilters: [ 'preFilters', 'preFilter' ],
  rcombinators: [ 'combinator' ],
  combinator: [ 'rcombinators' ],
  funcName: [ 'doneName' ],
  postFilter: [ 'postFinder', 'preFilter', 'propFilter' ],
  postFinder: [ 'postFilter' ],
  setMatcher: [ 'setMatchers', 'setMatched', 'superMatcher' ],
  setMatchers: [ 'setMatcher', 'setMatched' ],
  setMatched: [ 'setMatcher', 'setMatchers' ],
  superMatcher: [ 'setMatcher' ],
  condense: [ 'content', 'contents' ],
  matchContext: [ 'matchAnyContext' ],
  matchAnyContext: [ 'matchContext' ],
  elementMatcher: [ 'elementMatchers' ],
  elementMatchers: [ 'elementMatcher' ],
  completed: [ 'compiled', 'computed', 'complete' ],
  addHandle: [ 'attrHandle' ],
  attrHandle: [ 'addHandle' ],
  targets: [ 'parts' ],
  parts: [ 'targets' ],
  firing: [ 'sibling' ],
  deferred: [ 'defer' ],
  defer: [ 'deferred' ],
  returned: [ 'rreturn' ],
  rreturn: [ 'returned' ],
  promise: [ 'props' ],
  props: [ 'promise' ],
  setTimeout: [ 'timeout' ],
  timeout: [ 'setTimeout', 'timerId' ],
  emptyGet: [ 'empty' ],
  empty: [ 'emptyGet' ],
  response: [ 'resolve', 'responses' ],
  keepData: [ 'elemData' ],
  handleObjIn: [ 'handleObj' ],
  origType: [ 'origName' ],
  origName: [ 'origType', 'rtagName', 'propName' ],
  original: [ 'origFn' ],
  origFn: [ 'original' ],
  related: [ 'eased', 'selected' ],
  wrapMap: [ 'wrap' ],
  wrap: [ 'wrapMap' ],
  current: [ 'content', 'percent', 'curLeft' ],
  destElements: [ 'refElements' ],
  srcElements: [ 'refElements' ],
  pdataOld: [ 'pdataCur', 'udataOld' ],
  pdataCur: [ 'pdataOld', 'udataCur' ],
  udataOld: [ 'pdataOld', 'udataCur' ],
  udataCur: [ 'pdataCur', 'udataOld' ],
  rtagName: [ 'capName', 'origName' ],
  collection: [ 'selection' ],
  scripts: [ 'hasScripts' ],
  hasScripts: [ 'scripts' ],
  rmargin: [ 'margin' ],
  margin: [ 'rmargin', 'marginDiv' ],
  minWidth: [ 'maxWidth' ],
  maxWidth: [ 'minWidth' ],
  marginDiv: [ 'margin' ],
  propName: [ 'capName', 'origName' ],
  isHidden: [ 'hidden' ],
  hidden: [ 'isHidden' ],
  percent: [ 'current' ],
  animation: [ 'Animation', 'doAnimation' ],
  Animation: [ 'animation', 'doAnimation' ],
  doAnimation: [ 'animation', 'Animation' ],
  stopped: [ 'speed', 'stop' ],
  speed: [ 'stopped' ],
  stop: [ 'stopped' ],
  prepend: [ 'proceed' ],
  proceed: [ 'prepend' ],
  timerId: [ 'time', 'timeout' ],
  time: [ 'timerId' ],
  boolHook: [ 'nodeHook' ],
  nodeHook: [ 'boolHook' ],
  classes: [ 'rclass', 'classNames' ],
  rclass: [ 'classes' ],
  dataType: [ 'dataTypes' ],
  dataTypes: [ 'dataType', 'allTypes' ],
  allTypes: [ 'dataTypes' ],
  transports: [ 'transport' ],
  transport: [ 'transports' ],
  inspected: [ 'inspect' ],
  responses: [ 'response' ],
  finalDataType: [ 'firstDataType' ],
  firstDataType: [ 'finalDataType' ],
  curLeft: [ 'current', 'curCSSLeft' ],
  isSuccess: [ 'success' ],
  success: [ 'isSuccess' ],
  xhrCallbacks: [ 'oldCallbacks' ],
  oldCallbacks: [ 'xhrCallbacks' ],
  curCSSTop: [ 'curTop' ],
  curTop: [ 'curCSSTop' ],
  curCSSLeft: [ 'curLeft' ] }

In code

var shiftIdentifiers = require('../dist');

var file = 'some/file.js';

var source = fs.readFileSync(file).toString();

console.log(shiftIdentifiers(source));

Licenses

ISC

Current Tags

  • 0.0.1                                ...           latest (6 years ago)

1 Versions

  • 0.0.1                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (3)
Dev Dependencies (1)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |