forked from 0x2620/oxjs
remove unneeded constants
This commit is contained in:
parent
7282835f0d
commit
8581a3da3a
3 changed files with 47 additions and 43 deletions
|
|
@ -475,9 +475,15 @@ Ox.doc = (function() {
|
|||
|
||||
/*@
|
||||
Ox.identify <f> Returns the type of a JavaScript identifier
|
||||
(str) -> <s> Type
|
||||
(string) -> <s> Type
|
||||
Type can be `constant`, `identifier`, `keyword`, `method`, `object` or
|
||||
`property`.
|
||||
> Ox.identify('foo')
|
||||
'identifier'
|
||||
> Ox.identify('break')
|
||||
'keyword'
|
||||
> Ox.identify('window')
|
||||
'object'
|
||||
@*/
|
||||
Ox.identify = (function() {
|
||||
// see https://developer.mozilla.org/en/JavaScript/Reference
|
||||
|
|
@ -488,6 +494,23 @@ Ox.identify = (function() {
|
|||
// Number
|
||||
'MAX_VALUE', 'MIN_VALUE', 'NEGATIVE_INFINITY', 'POSITIVE_INFINITY'
|
||||
],
|
||||
keyword: [
|
||||
'break',
|
||||
'case', 'catch', 'class', 'const', 'continue',
|
||||
'debugger', 'default', 'delete', 'do',
|
||||
'else', 'enum', 'export', 'extends',
|
||||
'false', 'finally', 'for', 'function',
|
||||
'if', 'implements', 'import', 'in', 'instanceof', 'interface',
|
||||
'let', 'module',
|
||||
'new', 'null',
|
||||
'package', 'private', 'protected', 'public',
|
||||
'return',
|
||||
'super', 'switch', 'static',
|
||||
'this', 'throw', 'true', 'try', 'typeof',
|
||||
'var', 'void',
|
||||
'yield',
|
||||
'while', 'with'
|
||||
],
|
||||
method: [
|
||||
// Array
|
||||
'concat',
|
||||
|
|
@ -615,10 +638,11 @@ Ox.identify = (function() {
|
|||
};
|
||||
return function(identifier) {
|
||||
var ret;
|
||||
if (Ox.KEYWORDS.indexOf(identifier) > -1) {
|
||||
ret = 'keyword'
|
||||
if (identifiers.keyword.indexOf(identifier) > -1) {
|
||||
// fast track for keywords (used in Ox.tokenize)
|
||||
ret = 'keyword';
|
||||
} else {
|
||||
ret = 'identifier'
|
||||
ret = 'identifier';
|
||||
Ox.forEach(identifiers, function(words, type) {
|
||||
if (words.indexOf(identifier) > -1) {
|
||||
ret = type;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue