function extractDescription (d) {
      if (!d) return;
      if (d === "ERROR: No README data found!") return;
      // the first block of text before the first heading
      // that isn't the first line heading
      d = d.trim().split('\n')
      for (var s = 0; d[s] && d[s].trim().match(/^(#|$)/); s ++);
      var l = d.length
      for (var e = s + 1; e < l && d[e].trim(); e ++);
      return d.slice(s, e).join(' ').trim()
    }

function
extractDescription
(
d
)
{
if
(
!
d
)
return
;
if
(
d
===
"ERROR: No README data found!"
)
return
;
d
=
d
.
trim
(
)
.
split
(
'\n'
)
\n
for
(
var
s
=
0
;
d
[
s
]
&&
d
[
s
]
.
trim
(
)
.
match
(
/
^(#|$)
/
)
;
s
++
)
;
var
l
=
d
.
length
for
(
var
e
=
s
+
1
;
e
<
l
&&
d
[
e
]
.
trim
(
)
;
e
++
)
;
}

Extracts description from contents of a readme file in markdown format


function addComment(type, value, start, end, loc) {
            var comment;
            assert(typeof start === 'number', 'Comment must have valid position');

            // Because the way the actual token is scanned, often the comments
            // (if any) are skipped twice during the lexical analysis.
            // Thus, we need to skip adding a comment if the comment array already
            // handled it.
            if (state.lastCommentStart >= start) {
                return;
            }
            state.lastCommentStart = start;

            comment = {
                type: type,
                value: value
            };
            if (extra.range) {
                comment.range = [start, end];
            }
            if (extra.loc) {
                comment.loc = loc;
            }
            extra.comments.push(comment);
            if (extra.attachComment) {
                extra.leadingComments.push(comment);
                extra.trailingComments.push(comment);
            }
        }

function
addComment
(
type
,
value
,
start
,
end
,
loc
)
{
var
comment
;
assert
(
typeof
start
===
'number'
,
'Comment must have valid position'
)
;
if
(
state
.
lastCommentStart
>=
start
)
{
return
;
}
state
.
lastCommentStart
=
start
;
comment
=
{
type
:
type
,
value
:
value
}
;
if
(
extra
.
range
)
{
comment
.
range
=
[
start
,
end
]
;
}
if
(
extra
.
loc
)
{
comment
.
loc
=
loc
;
}
extra
.
comments
.
push
(
comment
)
;
if
(
extra
.
attachComment
)
{
extra
.
leadingComments
.
push
(
comment
)
;
extra
.
trailingComments
.
push
(
comment
)
;
}
}


function expectKeyword(keyword, contextual) {
            var token = lex();
            if (token.type !== (contextual ? Token.Identifier : Token.Keyword) ||
                    token.value !== keyword) {
                throwUnexpected(token);
            }
        }

function expectKeyword ( keyword , contextual ) { var token = lex ( ) ; if ( token . type !== ( contextual ? Token . Identifier : Token . Keyword ) || token . value !== keyword ) { throwUnexpected ( token ) ; } }

Expect the next token to match the specified keyword. If not, an exception will be thrown.

Expect the next token to match the specified keyword . If not an exception will be thrown .


function parseArrayInitialiser() {
            var elements = [], blocks = [], filter = null, tmp, possiblecomprehension = true,
                marker = markerCreate();

            expect('[');
            while (!match(']')) {
                if (lookahead.value === 'for' &&
                        lookahead.type === Token.Keyword) {
                    if (!possiblecomprehension) {
                        throwError({}, Messages.ComprehensionError);
                    }
                    matchKeyword('for');
                    tmp = parseForStatement({ignoreBody: true});
                    tmp.of = tmp.type === Syntax.ForOfStatement;
                    tmp.type = Syntax.ComprehensionBlock;
                    if (tmp.left.kind) { // can't be let or const
                        throwError({}, Messages.ComprehensionError);
                    }
                    blocks.push(tmp);
                } else if (lookahead.value === 'if' &&
                               lookahead.type === Token.Keyword) {
                    if (!possiblecomprehension) {
                        throwError({}, Messages.ComprehensionError);
                    }
                    expectKeyword('if');
                    expect('(');
                    filter = parseExpression();
                    expect(')');
                } else if (lookahead.value === ',' &&
                               lookahead.type === Token.Punctuator) {
                    possiblecomprehension = false; // no longer allowed.
                    lex();
                    elements.push(null);
                } else {
                    tmp = parseSpreadOrAssignmentExpression();
                    elements.push(tmp);
                    if (tmp && tmp.type === Syntax.SpreadElement) {
                        if (!match(']')) {
                            throwError({}, Messages.ElementAfterSpreadElement);
                        }
                    } else if (!(match(']') || matchKeyword('for') || matchKeyword('if'))) {
                        expect(','); // this lexes.
                        possiblecomprehension = false;
                    }
                }
            }

            expect(']');

            if (filter && !blocks.length) {
                throwError({}, Messages.ComprehensionRequiresBlock);
            }

            if (blocks.length) {
                if (elements.length !== 1) {
                    throwError({}, Messages.ComprehensionError);
                }
                return markerApply(marker, delegate.createComprehensionExpression(filter, blocks, elements[0]));
            }
            return markerApply(marker, delegate.createArrayExpression(elements));
        }

function parseArrayInitialiser ( ) { var elements = [ ] , blocks = [ ] , filter = null , tmp , possiblecomprehension = true , marker = markerCreate ( ) ; expect ( '[' ) ; while ( ! match ( ']' ) ) { if ( lookahead . value === 'for' && lookahead . type === Token . Keyword ) { if ( ! possiblecomprehension ) { throwError ( { } , Messages . ComprehensionError ) ; } matchKeyword ( 'for' ) ; tmp = parseForStatement ( { ignoreBody : true } ) ; tmp . of = tmp . type === Syntax . ForOfStatement ; tmp . type = Syntax . ComprehensionBlock ; if ( tmp . left . kind ) { throwError ( { } , Messages . ComprehensionError ) ; } blocks . push ( tmp ) ; } else if ( lookahead . value === 'if' && lookahead . type === Token . Keyword ) { if ( ! possiblecomprehension ) { throwError ( { } , Messages . ComprehensionError ) ; } expectKeyword ( 'if' ) ; expect ( '(' ) ; filter = parseExpression ( ) ; expect ( ')' ) ; } else if ( lookahead . value === ',' && lookahead . type === Token . Punctuator ) { possiblecomprehension = false ; lex ( ) ; elements . push ( null ) ; } else { tmp = parseSpreadOrAssignmentExpression ( ) ; elements . push ( tmp ) ; if ( tmp && tmp . type === Syntax . SpreadElement ) { if ( ! match ( ']' ) ) { throwError ( { } , Messages . ElementAfterSpreadElement ) ; } } else if ( ! ( match ( ']' ) || matchKeyword ( 'for' ) || matchKeyword ( 'if' ) ) ) { expect ( ',' ) ; possiblecomprehension = false ; } } } expect ( ']' ) ; if ( filter && ! blocks . length ) { throwError ( { } , Messages . ComprehensionRequiresBlock ) ; } if ( blocks . length ) { if ( elements . length !== 1 ) { throwError ( { } , Messages . ComprehensionError ) ; } return markerApply ( marker , delegate . createComprehensionExpression ( filter , blocks , elements [ 0 ] ) ) ; } return markerApply ( marker , delegate . createArrayExpression ( elements ) ) ; }


function parsePropertyFunction(options) {
            var previousStrict, previousYieldAllowed, previousAwaitAllowed,
                params, defaults, body, marker = markerCreate();

            previousStrict = strict;
            previousYieldAllowed = state.yieldAllowed;
            state.yieldAllowed = options.generator;
            previousAwaitAllowed = state.awaitAllowed;
            state.awaitAllowed = options.async;
            params = options.params || [];
            defaults = options.defaults || [];

            body = parseConciseBody();
            if (options.name && strict && isRestrictedWord(params[0].name)) {
                throwErrorTolerant(options.name, Messages.StrictParamName);
            }
            strict = previousStrict;
            state.yieldAllowed = previousYieldAllowed;
            state.awaitAllowed = previousAwaitAllowed;

            return markerApply(marker, delegate.createFunctionExpression(
                null,
                params,
                defaults,
                body,
                options.rest || null,
                options.generator,
                body.type !== Syntax.BlockStatement,
                options.async,
                options.returnType,
                options.typeParameters
            ));
        }

function parsePropertyFunction ( options ) { var previousStrict , previousYieldAllowed , previousAwaitAllowed , params , defaults , body , marker = markerCreate ( ) ; previousStrict = strict ; previousYieldAllowed = state . yieldAllowed ; state . yieldAllowed = options . generator ; previousAwaitAllowed = state . awaitAllowed ; state . awaitAllowed = options . async ; params = options . params || [ ] ; defaults = options . defaults || [ ] ; body = parseConciseBody ( ) ; if ( options . name && strict && isRestrictedWord ( params [ 0 ] . name ) ) { throwErrorTolerant ( options . name , Messages . StrictParamName ) ; } strict = previousStrict ; state . yieldAllowed = previousYieldAllowed ; state . awaitAllowed = previousAwaitAllowed ; return markerApply ( marker , delegate . createFunctionExpression ( null , params , defaults , body , options . rest || null , options . generator , body . type !== Syntax . BlockStatement , options . async , options . returnType , options . typeParameters ) ) ; }


function parsePostfixExpression() {
            var marker = markerCreate(),
                expr = parseLeftHandSideExpressionAllowCall(),
                token;

            if (lookahead.type !== Token.Punctuator) {
                return expr;
            }

            if ((match('++') || match('--')) && !peekLineTerminator()) {
                // 11.3.1, 11.3.2
                if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
                    throwErrorTolerant({}, Messages.StrictLHSPostfix);
                }

                if (!isLeftHandSide(expr)) {
                    throwError({}, Messages.InvalidLHSInAssignment);
                }

                token = lex();
                expr = markerApply(marker, delegate.createPostfixExpression(token.value, expr));
            }

            return expr;
        }

function parsePostfixExpression ( ) { var marker = markerCreate ( ) , expr = parseLeftHandSideExpressionAllowCall ( ) , token ; if ( lookahead . type !== Token . Punctuator ) { return expr ; } if ( ( match ( '++' ) || match ( '--' ) ) && ! peekLineTerminator ( ) ) { if ( strict && expr . type === Syntax . Identifier && isRestrictedWord ( expr . name ) ) { throwErrorTolerant ( { } , Messages . StrictLHSPostfix ) ; } if ( ! isLeftHandSide ( expr ) ) { throwError ( { } , Messages . InvalidLHSInAssignment ) ; } token = lex ( ) ; expr = markerApply ( marker , delegate . createPostfixExpression ( token . value , expr ) ) ; } return expr ; }


function parseUnaryExpression() {
            var marker, token, expr;

            if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) {
                return parsePostfixExpression();
            }

            if (match('++') || match('--')) {
                marker = markerCreate();
                token = lex();
                expr = parseUnaryExpression();
                // 11.4.4, 11.4.5
                if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
                    throwErrorTolerant({}, Messages.StrictLHSPrefix);
                }

                if (!isLeftHandSide(expr)) {
                    throwError({}, Messages.InvalidLHSInAssignment);
                }

                return markerApply(marker, delegate.createUnaryExpression(token.value, expr));
            }

            if (match('+') || match('-') || match('~') || match('!')) {
                marker = markerCreate();
                token = lex();
                expr = parseUnaryExpression();
                return markerApply(marker, delegate.createUnaryExpression(token.value, expr));
            }

            if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) {
                marker = markerCreate();
                token = lex();
                expr = parseUnaryExpression();
                expr = markerApply(marker, delegate.createUnaryExpression(token.value, expr));
                if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) {
                    throwErrorTolerant({}, Messages.StrictDelete);
                }
                return expr;
            }

            return parsePostfixExpression();
        }

function parseUnaryExpression ( ) { var marker , token , expr ; if ( lookahead . type !== Token . Punctuator && lookahead . type !== Token . Keyword ) { return parsePostfixExpression ( ) ; } if ( match ( '++' ) || match ( '--' ) ) { marker = markerCreate ( ) ; token = lex ( ) ; expr = parseUnaryExpression ( ) ; if ( strict && expr . type === Syntax . Identifier && isRestrictedWord ( expr . name ) ) { throwErrorTolerant ( { } , Messages . StrictLHSPrefix ) ; } if ( ! isLeftHandSide ( expr ) ) { throwError ( { } , Messages . InvalidLHSInAssignment ) ; } return markerApply ( marker , delegate . createUnaryExpression ( token . value , expr ) ) ; } if ( match ( '+' ) || match ( '-' ) || match ( '~' ) || match ( '!' ) ) { marker = markerCreate ( ) ; token = lex ( ) ; expr = parseUnaryExpression ( ) ; return markerApply ( marker , delegate . createUnaryExpression ( token . value , expr ) ) ; } if ( matchKeyword ( 'delete' ) || matchKeyword ( 'void' ) || matchKeyword ( 'typeof' ) ) { marker = markerCreate ( ) ; token = lex ( ) ; expr = parseUnaryExpression ( ) ; expr = markerApply ( marker , delegate . createUnaryExpression ( token . value , expr ) ) ; if ( strict && expr . operator === 'delete' && expr . argument . type === Syntax . Identifier ) { throwErrorTolerant ( { } , Messages . StrictDelete ) ; } return expr ; } return parsePostfixExpression ( ) ; }


function reinterpretAsAssignmentBindingPattern(expr) {
            var i, len, property, element;

            if (expr.type === Syntax.ObjectExpression) {
                expr.type = Syntax.ObjectPattern;
                for (i = 0, len = expr.properties.length; i < len; i += 1) {
                    property = expr.properties[i];
                    if (property.type === Syntax.SpreadProperty) {
                        if (i < len - 1) {
                            throwError({}, Messages.PropertyAfterSpreadProperty);
                        }
                        reinterpretAsAssignmentBindingPattern(property.argument);
                    } else {
                        if (property.kind !== 'init') {
                            throwError({}, Messages.InvalidLHSInAssignment);
                        }
                        reinterpretAsAssignmentBindingPattern(property.value);
                    }
                }
            } else if (expr.type === Syntax.ArrayExpression) {
                expr.type = Syntax.ArrayPattern;
                for (i = 0, len = expr.elements.length; i < len; i += 1) {
                    element = expr.elements[i];
                    /* istanbul ignore else */
                    if (element) {
                        reinterpretAsAssignmentBindingPattern(element);
                    }
                }
            } else if (expr.type === Syntax.Identifier) {
                if (isRestrictedWord(expr.name)) {
                    throwError({}, Messages.InvalidLHSInAssignment);
                }
            } else if (expr.type === Syntax.SpreadElement) {
                reinterpretAsAssignmentBindingPattern(expr.argument);
                if (expr.argument.type === Syntax.ObjectPattern) {
                    throwError({}, Messages.ObjectPatternAsSpread);
                }
            } else {
                /* istanbul ignore else */
                if (expr.type !== Syntax.MemberExpression && expr.type !== Syntax.CallExpression && expr.type !== Syntax.NewExpression) {
                    throwError({}, Messages.InvalidLHSInAssignment);
                }
            }
        }

function reinterpretAsAssignmentBindingPattern ( expr ) { var i , len , property , element ; if ( expr . type === Syntax . ObjectExpression ) { expr . type = Syntax . ObjectPattern ; for ( i = 0 , len = expr . properties . length ; i < len ; i += 1 ) { property = expr . properties [ i ] ; if ( property . type === Syntax . SpreadProperty ) { if ( i < len - 1 ) { throwError ( { } , Messages . PropertyAfterSpreadProperty ) ; } reinterpretAsAssignmentBindingPattern ( property . argument ) ; } else { if ( property . kind !== 'init' ) { throwError ( { } , Messages . InvalidLHSInAssignment ) ; } reinterpretAsAssignmentBindingPattern ( property . value ) ; } } } else if ( expr . type === Syntax . ArrayExpression ) { expr . type = Syntax . ArrayPattern ; for ( i = 0 , len = expr . elements . length ; i < len ; i += 1 ) { element = expr . elements [ i ] ; if ( element ) { reinterpretAsAssignmentBindingPattern ( element ) ; } } } else if ( expr . type === Syntax . Identifier ) { if ( isRestrictedWord ( expr . name ) ) { throwError ( { } , Messages . InvalidLHSInAssignment ) ; } } else if ( expr . type === Syntax . SpreadElement ) { reinterpretAsAssignmentBindingPattern ( expr . argument ) ; if ( expr . argument . type === Syntax . ObjectPattern ) { throwError ( { } , Messages . ObjectPatternAsSpread ) ; } } else { if ( expr . type !== Syntax . MemberExpression && expr . type !== Syntax . CallExpression && expr . type !== Syntax . NewExpression ) { throwError ( { } , Messages . InvalidLHSInAssignment ) ; } } }

11.13 Assignment Operators 12.14.5 AssignmentPattern


function parseExpressionStatement() {
            var marker = markerCreate(), expr = parseExpression();
            consumeSemicolon();
            return markerApply(marker, delegate.createExpressionStatement(expr));
        }

function parseExpressionStatement ( ) { var marker = markerCreate ( ) , expr = parseExpression ( ) ; consumeSemicolon ( ) ; return markerApply ( marker , delegate . createExpressionStatement ( expr ) ) ; }


function parseReturnStatement() {
            var argument = null, marker = markerCreate();

            expectKeyword('return');

            if (!state.inFunctionBody) {
                throwErrorTolerant({}, Messages.IllegalReturn);
            }

            // 'return' followed by a space and an identifier is very common.
            if (source.charCodeAt(index) === 32) {
                if (isIdentifierStart(source.charCodeAt(index + 1))) {
                    argument = parseExpression();
                    consumeSemicolon();
                    return markerApply(marker, delegate.createReturnStatement(argument));
                }
            }

            if (peekLineTerminator()) {
                return markerApply(marker, delegate.createReturnStatement(null));
            }

            if (!match(';')) {
                if (!match('}') && lookahead.type !== Token.EOF) {
                    argument = parseExpression();
                }
            }

            consumeSemicolon();

            return markerApply(marker, delegate.createReturnStatement(argument));
        }

function parseReturnStatement ( ) { var argument = null , marker = markerCreate ( ) ; expectKeyword ( 'return' ) ; if ( ! state . inFunctionBody ) { throwErrorTolerant ( { } , Messages . IllegalReturn ) ; } if ( source . charCodeAt ( index ) === 32 ) { if ( isIdentifierStart ( source . charCodeAt ( index + 1 ) ) ) { argument = parseExpression ( ) ; consumeSemicolon ( ) ; return markerApply ( marker , delegate . createReturnStatement ( argument ) ) ; } } if ( peekLineTerminator ( ) ) { return markerApply ( marker , delegate . createReturnStatement ( null ) ) ; } if ( ! match ( ';' ) ) { if ( ! match ( '}' ) && lookahead . type !== Token . EOF ) { argument = parseExpression ( ) ; } } consumeSemicolon ( ) ; return markerApply ( marker , delegate . createReturnStatement ( argument ) ) ; }


function extend(object, properties) {
            var entry, result = {};

            for (entry in object) {
                /* istanbul ignore else */
                if (object.hasOwnProperty(entry)) {
                    result[entry] = object[entry];
                }
            }

            for (entry in properties) {
                /* istanbul ignore else */
                if (properties.hasOwnProperty(entry)) {
                    result[entry] = properties[entry];
                }
            }

            return result;
        }

function extend ( object , properties ) { var entry , result = { } ; for ( entry in object ) { if ( object . hasOwnProperty ( entry ) ) { result [ entry ] = object [ entry ] ; } } for ( entry in properties ) { if ( properties . hasOwnProperty ( entry ) ) { result [ entry ] = properties [ entry ] ; } } return result ; }


function reflowText (text, width, gfm) {
      // Hard break was inserted by Renderer.prototype.br or is
      // <br /> when gfm is true
      var splitRe = gfm ? HARD_RETURN_GFM_RE : HARD_RETURN_RE,
          sections = text.split(splitRe),
          reflowed = [];

      sections.forEach(function (section) {
        var words = section.split(/[ \t\n]+/),
            column = 0,
            nextText = '';

        words.forEach(function (word) {
          var addOne = column != 0;
          if ((column + textLength(word) + addOne) > width) {
            nextText += '\n';
            column = 0;
          } else if (addOne) {
            nextText += " ";
            column += 1;
          }
          nextText += word;
          column += textLength(word);
        });
        reflowed.push(nextText);
      });
      return reflowed.join('\n');
    }

function
reflowText
(
text
,
width
,
gfm
)
{
var
splitRe
=
gfm
HARD_RETURN_GFM_RE
:
HARD_RETURN_RE
,
sections
=
text
.
split
(
splitRe
)
,
reflowed
=
[
]
;
sections
.
forEach
(
function
(
section
)
{
var
words
=
section
.
split
(
/
[ \t\n]+
/
)
,
column
=
0
,
nextText
=
''
;
words
.
forEach
(
function
(
word
)
{
var
addOne
=
column
!=
0
;
if
(
(
column
+
textLength
(
word
)
+
addOne
)
>
width
)
{
nextText
+=
'\n'
;
\n
}
else
column
=
0
;
if
(
addOne
)
{
nextText
+=
" "
;
column
+=
1
;
}
nextText
+=
word
;
}
)
;
column
+=
textLength
(
word
)
;
}
)
;
reflowed
.
push
(
nextText
)
;
}

Munge \n's and spaces in "text" so that the number of characters between \n's is less than or equal to "width".

Munge \ n s and spaces in text so that the number of characters between \ n s is less than or equal to width .


function isAbsolute(fp) {
      if (typeof fp !== 'string') {
        throw new TypeError('isAbsolute expects a string.');
      }
      if (!isWindows() && isAbsolute.posix(fp)) {
        return true;
      }
      return isAbsolute.win32(fp);
    }

function
isAbsolute
(
fp
)
{
if
(
typeof
fp
!==
'string'
)
{
throw
new
TypeError
(
'isAbsolute expects a string.'
)
;
}
if
(
!
isWindows
(
)
&&
isAbsolute
.
posix
(
fp
)
)
{
return
true
;
}
return
isAbsolute
.
win32
(
fp
)
;
}

Returns true if a file path is absolute.

@param  {String} `fp`
@return {Boolean}

Returns true if a file path is absolute .


function repeat(str, num) {
      if (typeof str !== 'string') {
        throw new TypeError('repeat-string expects a string.');
      }

      if (num === 1) return str;
      if (num === 2) return str + str;

      var max = str.length * num;
      if (cache !== str || typeof cache === 'undefined') {
        cache = str;
        res = '';
      }

      while (max > res.length && num > 0) {
        if (num & 1) {
          res += str;
        }

        num >>= 1;
        if (!num) break;
        str += str;
      }

      return res.substr(0, max);
    }

function
repeat
(
str
,
num
)
{
if
(
typeof
str
!==
'string'
)
{
throw
new
TypeError
(
'repeat-string expects a string.'
)
;
}
if
(
num
===
1
)
return
str
;
if
(
num
===
2
)
return
str
+
str
;
var
max
=
str
.
length
*
num
;
if
(
cache
!==
str
||
typeof
cache
===
'undefined'
)
{
cache
=
str
;
res
=
''
;
}
while
(
max
>
res
.
length
&&
num
>
0
)
{
if
(
num
&
1
)
{
res
+=
str
;
}
num
>>=
1
;
if
(
!
num
)
break
;
str
+=
str
;
}
return
res
.
substr
(
0
,
max
)
;
}

Repeat the given `string` the specified `number`
of times.

**Example:**

```js
var repeat =  require('repeat-string');
repeat('A', 5);
//=> AAAAA
```

@param {String} `string` The string to repeat
@param {Number} `number` The number of times to repeat the string
@return {String} Repeated string
@api public

Repeat the given string the specified number of times .


function uniqSet(arr) {
    	var seen = new Set();
    	return arr.filter(function (el) {
    		if (!seen.has(el)) {
    			seen.add(el);
    			return true;
    		}
    	});
    }

function uniqSet ( arr ) { var seen = new Set ( ) ; return arr . filter ( function ( el ) { if ( ! seen . has ( el ) ) { seen . add ( el ) ; return true ; } } ) ; }


function error(msg, _continue) {
      if (state.error === null)
        state.error = '';
      state.error += state.currentCmd + ': ' + msg + '\n';

      if (msg.length > 0)
        log(state.error);

      if (config.fatal)
        process.exit(1);

      if (!_continue)
        throw '';
    }

function
error
(
msg
,
_continue
)
{
if
(
state
.
error
===
)
state
.
error
=
''
;
state
.
error
+=
state
.
currentCmd
+
': '
+
msg
+
'\n'
;
\n
if
(
msg
.
length
>
0
)
log
(
state
.
error
)
;
if
(
config
.
fatal
)
process
.
exit
(
1
)
;
}

Shows error message. Throws unless _continue or config.fatal are true

Shows error message . Throws unless _continue or config . fatal are true


function wrap(cmd, fn, options) {
      return function() {
        var retValue = null;

        state.currentCmd = cmd;
        state.error = null;

        try {
          var args = [].slice.call(arguments, 0);

          if (options && options.notUnix) {
            retValue = fn.apply(this, args);
          } else {
            if (args.length === 0 || typeof args[0] !== 'string' || args[0][0] !== '-')
              args.unshift(''); // only add dummy option if '-option' not already present
            retValue = fn.apply(this, args);
          }
        } catch (e) {
          if (!state.error) {
            // If state.error hasn't been set it's an error thrown by Node, not us - probably a bug...
            console.log('shell.js: internal error');
            console.log(e.stack || e);
            process.exit(1);
          }
          if (config.fatal)
            throw e;
        }

        state.currentCmd = 'shell.js';
        return retValue;
      };
    }

function
wrap
(
cmd
,
fn
,
options
)
{
return
function
(
)
{
var
retValue
=
;
state
.
currentCmd
=
cmd
;
state
.
error
=
;
try
{
var
args
=
[
]
.
slice
.
call
(
arguments
,
0
)
;
if
(
options
&&
options
.
notUnix
)
{
retValue
=
fn
.
apply
(
this
,
args
)
;
}
else
{
if
(
args
.
length
===
0
||
typeof
args
[
0
]
!==
'string'
||
args
[
0
]
[
0
]
!==
'-'
)
args
.
unshift
(
''
)
;
retValue
=
fn
.
apply
(
this
,
args
)
;
}
}
catch
(
e
)
{
if
(
!
state
.
error
)
{
console
.
log
(
'shell.js: internal error'
)
;
console
.
log
(
e
.
stack
||
e
)
;
process
.
exit
(
1
)
;
}
if
(
config
.
fatal
)
throw
e
;
}
state
.
currentCmd
=
'shell.js'
;
return
retValue
;
}
;
}

Common wrapper for all Unix-like commands

Common wrapper for all Unix - like commands


function writeableDir(dir) {
      if (!dir || !fs.existsSync(dir))
        return false;

      if (!fs.statSync(dir).isDirectory())
        return false;

      var testFile = dir+'/'+common.randomFileName();
      try {
        fs.writeFileSync(testFile, ' ');
        common.unlinkSync(testFile);
        return dir;
      } catch (e) {
        return false;
      }
    }

function
writeableDir
(
dir
)
{
if
(
!
dir
||
!
fs
.
existsSync
(
dir
)
)
return
false
;
if
(
!
fs
.
statSync
(
dir
)
.
isDirectory
(
)
)
return
false
;
var
testFile
=
dir
+
'/'
+
common
.
randomFileName
(
)
;
try
{
fs
.
writeFileSync
(
testFile
,
' '
)
;
common
.
unlinkSync
(
testFile
)
;
return
dir
;
}
catch
(
e
)
{
return
false
;
}
}

Returns false if 'dir' is not a writeable directory, 'dir' otherwise

Returns false if dir is not a writeable directory dir otherwise


function mkdirSyncRecursive(dir) {
      var baseDir = path.dirname(dir);

      // Base dir exists, no recursion necessary
      if (fs.existsSync(baseDir)) {
        fs.mkdirSync(dir, parseInt('0777', 8));
        return;
      }

      // Base dir does not exist, go recursive
      mkdirSyncRecursive(baseDir);

      // Base dir created, can create dir
      fs.mkdirSync(dir, parseInt('0777', 8));
    }

function mkdirSyncRecursive ( dir ) { var baseDir = path . dirname ( dir ) ; if ( fs . existsSync ( baseDir ) ) { fs . mkdirSync ( dir , parseInt ( '0777' , 8 ) ) ; return ; } mkdirSyncRecursive ( baseDir ) ; fs . mkdirSync ( dir , parseInt ( '0777' , 8 ) ) ; }


function splitPath(p) {
      for (i=1;i<2;i++) {}

      if (!p)
        return [];

      if (common.platform === 'win')
        return p.split(';');
      else
        return p.split(':');
    }

function splitPath ( p ) { for ( i = 1 ; i < 2 ; i ++ ) { } if ( ! p ) return [ ] ; if ( common . platform === 'win' ) return p . split ( ';' ) ; else return p . split ( ':' ) ; }

Cross-platform method for splitting environment PATH variables

Cross - platform method for splitting environment PATH variables


function updateStdout() {
        if (options.silent || !fs.existsSync(stdoutFile))
          return;

        var stdoutContent = fs.readFileSync(stdoutFile, 'utf8');
        // No changes since last time?
        if (stdoutContent.length <= previousStdoutContent.length)
          return;

        process.stdout.write(stdoutContent.substr(previousStdoutContent.length));
        previousStdoutContent = stdoutContent;
      }

function updateStdout ( ) { if ( options . silent || ! fs . existsSync ( stdoutFile ) ) return ; var stdoutContent = fs . readFileSync ( stdoutFile , 'utf8' ) ; if ( stdoutContent . length <= previousStdoutContent . length ) return ; process . stdout . write ( stdoutContent . substr ( previousStdoutContent . length ) ) ; previousStdoutContent = stdoutContent ; }

Echoes stdout changes from running process, if not silent

Echoes stdout changes from running process if not silent


function formatArgs() {
      var args = arguments;
      var useColors = this.useColors;
      var name = this.namespace;

      if (useColors) {
        var c = this.color;

        args[0] = '  \u001b[3' + c + ';1m' + name + ' '
          + '\u001b[0m'
          + args[0] + '\u001b[3' + c + 'm'
          + ' +' + exports.humanize(this.diff) + '\u001b[0m';
      } else {
        args[0] = new Date().toUTCString()
          + ' ' + name + ' ' + args[0];
      }
      return args;
    }

function
formatArgs
(
)
{
var
args
=
arguments
;
var
useColors
=
this
.
useColors
;
var
name
=
this
.
namespace
;
if
(
useColors
)
{
var
c
=
this
.
color
;
args
[
0
]
=
'  \u001b[3'
+
\u001b
+
c
+
';1m'
+
name
+
' '
+
'\u001b[0m'
+
\u001b
+
args
[
0
]
+
'\u001b[3'
+
\u001b
+
c
+
'm'
;
}
else
' +'
exports
.
humanize
(
this
.
diff
)
}

Adds ANSI color escape codes if enabled.

@api public

Adds ANSI color escape codes if enabled .


function GNTP(type, opts) {
        opts = opts || {};
        this.type = type;
        this.host = opts.host || 'localhost';
        this.port = opts.port || 23053;
        this.request = 'GNTP/1.0 ' + type + ' NONE' + nl;
        this.resources = [];
        this.attempts = 0;
        this.maxAttempts = 5;
    }

function
GNTP
(
type
,
opts
)
{
opts
=
opts
||
{
}
;
this
.
type
=
type
;
this
.
host
=
opts
.
host
||
'localhost'
;
this
.
port
=
opts
.
port
||
23053
;
this
.
request
=
'GNTP/1.0 '
+
type
+
' NONE'
+
nl
;
this
.
resources
=
[
]
;
this
.
attempts
=
0
;
this
.
maxAttempts
=
5
;
}

Create a new GNTP request of the given `type`.

@param {String} type either NOTIFY or REGISTER
@api private

Create a new GNTP request of the given type .


function Growly() {
        this.appname = 'Growly';
        this.notifications = undefined;
        this.labels = undefined;
        this.count = 0;
        this.registered = false;
        this.host = undefined;
        this.port = undefined;
    }

function Growly ( ) { this . appname = 'Growly' ; this . notifications = undefined ; this . labels = undefined ; this . count = 0 ; this . registered = false ; this . host = undefined ; this . port = undefined ; }

Interface for registering Growl applications and sending Growl notifications.

@api private

Interface for registering Growl applications and sending Growl notifications .


function Command(name) {
      this.commands = [];
      this.options = [];
      this._execs = [];
      this._allowUnknownOption = false;
      this._args = [];
      this._name = name;
    }

function Command ( name ) { this . commands = [ ] ; this . options = [ ] ; this . _execs = [ ] ; this . _allowUnknownOption = false ; this . _args = [ ] ; this . _name = name ; }

Initialize a new `Command`.

@param {String} name
@api public


function baseDifference(array, values) {
      var length = array ? array.length : 0,
          result = [];

      if (!length) {
        return result;
      }
      var index = -1,
          indexOf = baseIndexOf,
          isCommon = true,
          cache = (isCommon && values.length >= LARGE_ARRAY_SIZE) ? createCache(values) : null,
          valuesLength = values.length;

      if (cache) {
        indexOf = cacheIndexOf;
        isCommon = false;
        values = cache;
      }
      outer:
      while (++index < length) {
        var value = array[index];

        if (isCommon && value === value) {
          var valuesIndex = valuesLength;
          while (valuesIndex--) {
            if (values[valuesIndex] === value) {
              continue outer;
            }
          }
          result.push(value);
        }
        else if (indexOf(values, value, 0) < 0) {
          result.push(value);
        }
      }
      return result;
    }

function baseDifference ( array , values ) { var length = array ? array . length : 0 , result = [ ] ; if ( ! length ) { return result ; } var index = - 1 , indexOf = baseIndexOf , isCommon = true , cache = ( isCommon && values . length >= LARGE_ARRAY_SIZE ) ? createCache ( values ) : null , valuesLength = values . length ; if ( cache ) { indexOf = cacheIndexOf ; isCommon = false ; values = cache ; } outer : while ( ++ index < length ) { var value = array [ index ] ; if ( isCommon && value === value ) { var valuesIndex = valuesLength ; while ( valuesIndex -- ) { if ( values [ valuesIndex ] === value ) { continue outer ; } } result . push ( value ) ; } else if ( indexOf ( values , value , 0 ) < 0 ) { result . push ( value ) ; } } return result ; }

The base implementation of `_.difference` which accepts a single array
of values to exclude.

@private
@param {Array} array The array to inspect.
@param {Array} values The values to exclude.
@returns {Array} Returns the new array of filtered values.

The base implementation of _ . difference which accepts a single array of values to exclude .


function peek(p) {
        var i = p || 0, j = 0, t;

        while (j <= i) {
          t = lookahead[j];
          if (!t) {
            t = lookahead[j] = lex.token();
          }
          j += 1;
        }

        // Peeking past the end of the program should produce the "(end)" token.
        if (!t && state.tokens.next.id === "(end)") {
          return state.tokens.next;
        }

        return t;
      }

function peek ( p ) { var i = p || 0 , j = 0 , t ; while ( j <= i ) { t = lookahead [ j ] ; if ( ! t ) { t = lookahead [ j ] = lex . token ( ) ; } j += 1 ; } if ( ! t && state . tokens . next . id === "(end)" ) { return state . tokens . next ; } return t ; }

We need a peek function. If it has an argument, it peeks that much farther ahead. It is used to distinguish for ( var i in ... from for ( var i = ...

We need a peek function . If it has an argument it peeks that much farther ahead . It is used to distinguish for ( var i in ... from for ( var i = ...


function identifier(fnparam, prop) {
        var i = optionalidentifier(fnparam, prop, false);
        if (i) {
          return i;
        }

        // parameter destructuring with rest operator
        if (state.tokens.next.value === "...") {
          if (!state.option.esnext) {
            warning("W119", state.tokens.next, "spread/rest operator");
          }
          advance();

          if (checkPunctuators(state.tokens.next, ["..."])) {
            warning("E024", state.tokens.next, "...");
            while (checkPunctuators(state.tokens.next, ["..."])) {
              advance();
            }
          }

          if (!state.tokens.next.identifier) {
            warning("E024", state.tokens.curr, "...");
            return;
          }

          return identifier(fnparam, prop);
        } else {
          error("E030", state.tokens.next, state.tokens.next.value);

          // The token should be consumed after a warning is issued so the parser
          // can continue as though an identifier were found. The semicolon token
          // should not be consumed in this way so that the parser interprets it as
          // a statement delimeter;
          if (state.tokens.next.id !== ";") {
            advance();
          }
        }
      }

function
identifier
(
fnparam
,
prop
)
{
var
i
=
optionalidentifier
(
fnparam
,
prop
,
false
)
;
if
(
i
)
{
return
i
;
}
if
(
state
.
tokens
.
next
.
value
===
"..."
)
{
if
(
!
state
.
option
.
esnext
)
{
warning
(
"W119"
,
state
.
tokens
.
next
,
"spread/rest operator"
)
;
}
advance
(
)
;
if
(
checkPunctuators
(
state
.
tokens
.
next
,
[
"..."
]
)
)
{
warning
(
"E024"
,
state
.
tokens
.
next
,
"..."
)
;
while
(
checkPunctuators
(
state
.
tokens
.
next
,
[
"..."
]
)
)
{
advance
(
)
;
}
}
if
(
!
state
.
tokens
.
next
.
identifier
)
{
warning
(
"E024"
,
state
.
tokens
.
curr
,
"..."
)
;
return
;
}
return
identifier
(
fnparam
,
prop
)
;
}
else
{
error
(
"E030"
,
state
.
tokens
.
next
,
state
.
tokens
.
next
.
value
)
;
if
(
state
.
tokens
.
next
.
id
!==
";"
)
{
advance
(
)
;
}
}
}

fnparam means that this identifier is being defined as a function argument prop means that this identifier is that of an object property


function destructuringAssignOrJsonValue() {
        // lookup for the assignment (esnext only)
        // if it has semicolons, it is a block, so go parse it as a block
        // or it's not a block, but there are assignments, check for undeclared variables

        var block = lookupBlockType();
        if (block.notJson) {
          if (!state.inESNext() && block.isDestAssign) {
            warning("W104", state.tokens.curr, "destructuring assignment");
          }
          statements();
        // otherwise parse json value
        } else {
          state.option.laxbreak = true;
          state.jsonMode = true;
          jsonValue();
        }
      }

function
destructuringAssignOrJsonValue
(
)
{
var
block
=
lookupBlockType
(
)
;
if
(
block
.
notJson
)
{
if
(
!
state
.
inESNext
(
)
&&
block
.
isDestAssign
)
{
warning
(
"W104"
,
state
.
tokens
.
curr
,
"destructuring assignment"
)
;
}
statements
(
)
;
}
else
{
state
.
option
.
laxbreak
=
true
;
state
.
jsonMode
=
true
;
jsonValue
(
)
;
}
}

Check whether this function has been reached for a destructuring assign with undeclared values


function shouldGetter() {
          if (this instanceof String || this instanceof Number || this instanceof Boolean ) {
            return new Assertion(this.valueOf(), null, shouldGetter);
          }
          return new Assertion(this, null, shouldGetter);
        }

function shouldGetter ( ) { if ( this instanceof String || this instanceof Number || this instanceof Boolean ) { return new Assertion ( this . valueOf ( ) , null , shouldGetter ) ; } return new Assertion ( this , null , shouldGetter ) ; }

explicitly define this method as function as to have it's name to include as `ssfi`

explicitly define this method as function as to have it s name to include as ssfi


function isA(object, value) {
      if (_isFunction2['default'](value)) return object instanceof value;

      if (value === 'array') return Array.isArray(object);

      return typeof object === value;
    }

function isA ( object , value ) { if ( _isFunction2 [ 'default' ] ( value ) ) return object instanceof value ; if ( value === 'array' ) return Array . isArray ( object ) ; return typeof object === value ; }

Returns true if the given object is an instanceof value
or its typeof is the given value.

Returns true if the given object is an instanceof value or its typeof is the given value .


function(bin, opt) {

    		cmd = bin;

    		if ( opt.testing !== 'undefined') { opt.dryRun = opt.testing; }

    		if (typeof opt.testSuite === 'undefined')     { opt.testSuite = ''; }
    		if (typeof opt.verbose === 'undefined')       { opt.verbose = ''; }
    		if (typeof opt.dryRun === 'undefined')        { opt.dryRun = false; }
    		if (typeof opt.silent === 'undefined')        { opt.silent = false; }
    		if (typeof opt.testing === 'undefined')       { opt.testing = false; }
    		if (typeof opt.debug === 'undefined')         { opt.debug = false; }
    		if (typeof opt.testClass === 'undefined')     { opt.testClass = ''; }
    		if (typeof opt.clear === 'undefined')         { opt.clear = false; }
    		if (typeof opt.flags === 'undefined')         { opt.flags = ''; }
    		if (typeof opt.notify === 'undefined')        { opt.notify = false; }
    		if (typeof opt.noInteraction === 'undefined') { opt.noInteraction = true; }
    		if (typeof opt.noAnsi === 'undefined')        { opt.noAnsi = false; }
    		if (typeof opt.quiet === 'undefined')         { opt.quiet = false; }
    		if (typeof opt.formatter === 'undefined')     { opt.formatter = ''; }

    		cmd = opt.clear ? 'clear && ' + cmd : cmd;

    		// assign default class and/or test suite
    		if (opt.testSuite)     { cmd += ' ' + opt.testSuite; }
    		if (opt.testClass)     { cmd += ' ' + opt.testClass; }
    		if (opt.verbose)       { cmd += ' -' + opt.verbose; }
    		if (opt.formatter)     { cmd += ' -f' + opt.formatter; }
    		if (opt.quiet)         { cmd += ' --quiet'; }
    		if (opt.noInteraction) { cmd += ' --no-interaction'; }

    		cmd += opt.noAnsi ? ' --no-ansi' : ' --ansi';

    		cmd += ' ' + opt.flags;

    		cmd.trim(); // clean up any lingering space remnants

    		return cmd;
    	}

function
(
bin
,
opt
)
{
cmd
=
bin
;
if
(
opt
.
testing
!==
'undefined'
)
{
opt
.
dryRun
=
opt
.
testing
;
}
if
(
typeof
opt
.
testSuite
===
'undefined'
)
{
opt
.
testSuite
=
''
;
}
if
(
typeof
opt
.
verbose
===
'undefined'
)
{
opt
.
verbose
=
''
;
}
if
(
typeof
opt
.
dryRun
===
'undefined'
)
{
opt
.
dryRun
=
false
;
}
if
(
typeof
opt
.
silent
===
'undefined'
)
{
opt
.
silent
=
false
;
}
if
(
typeof
opt
.
testing
===
'undefined'
)
{
opt
.
testing
=
false
;
}
if
(
typeof
opt
.
debug
===
'undefined'
)
{
opt
.
debug
=
false
;
}
if
(
typeof
opt
.
testClass
===
'undefined'
)
{
opt
.
testClass
=
''
;
}
if
(
typeof
opt
.
clear
===
'undefined'
)
{
opt
.
clear
=
false
;
}
if
(
typeof
opt
.
flags
===
'undefined'
)
{
opt
.
flags
=
''
;
}
if
(
typeof
opt
.
notify
===
'undefined'
)
{
opt
.
notify
=
false
;
}
if
(
typeof
opt
.
noInteraction
===
'undefined'
)
{
opt
.
noInteraction
=
true
;
}
if
(
typeof
opt
.
noAnsi
===
'undefined'
)
{
opt
.
noAnsi
=
false
;
}
if
(
typeof
opt
.
quiet
===
'undefined'
)
{
opt
.
quiet
=
false
;
}
if
(
typeof
opt
.
formatter
===
'undefined'
)
{
opt
.
formatter
=
''
;
}
cmd
=
opt
.
clear
'clear && '
+
cmd
:
cmd
;
if
(
opt
.
testSuite
)
{
cmd
+=
' '
+
opt
.
testSuite
;
}
if
(
opt
.
testClass
)
{
cmd
+=
' '
+
opt
.
testClass
;
}
if
(
opt
.
verbose
)
{
cmd
+=
' -'
+
opt
.
verbose
;
}
if
(
opt
.
formatter
)
{
cmd
+=
' -f'
+
opt
.
formatter
;
}
if
(
opt
.
quiet
)
{
cmd
+=
' --quiet'
;
}
if
(
opt
.
noInteraction
)
{
cmd
+=
' --no-interaction'
;
}
cmd
+=
opt
.
noAnsi
' --no-ansi'
:
' --ansi'
;
cmd
+=
' '
+
opt
.
flags
;
cmd
.
trim
(
)
;
return
cmd
;
}


function eatNargs (i, key, args) {
        var toEat = checkAllAliases(key, opts.narg)

        if (args.length - (i + 1) < toEat) error = Error(__('Not enough arguments following: %s', key))

        for (var ii = i + 1; ii < (toEat + i + 1); ii++) {
          setArg(key, args[ii])
        }

        return (i + toEat)
      }

function
eatNargs
(
i
,
key
,
args
)
{
var
toEat
=
checkAllAliases
(
key
,
opts
.
narg
)
if
(
args
.
length
(
i
+
1
)
<
toEat
)
error
=
Error
(
__
(
'Not enough arguments following: %s'
,
key
)
)
for
(
var
ii
=
i
+
1
;
ii
<
(
toEat
+
i
+
1
)
;
ii
++
)
{
setArg
(
key
,
args
[
ii
]
)
}
return
(
i
+
toEat
)
}

how many arguments should we consume, based on the nargs option?

how many arguments should we consume based on the nargs option?


function setConfig (argv) {
        var configLookup = {}

        // expand defaults/aliases, in-case any happen to reference
        // the config.json file.
        applyDefaultsAndAliases(configLookup, aliases, defaults)

        Object.keys(flags.configs).forEach(function (configKey) {
          var configPath = argv[configKey] || configLookup[configKey]
          if (configPath) {
            try {
              var config = require(path.resolve(process.cwd(), configPath))

              Object.keys(config).forEach(function (key) {
                // setting arguments via CLI takes precedence over
                // values within the config file.
                if (argv[key] === undefined || (flags.defaulted[key])) {
                  delete argv[key]
                  setArg(key, config[key])
                }
              })
            } catch (ex) {
              if (argv[configKey]) error = Error(__('Invalid JSON config file: %s', configPath))
            }
          }
        })
      }

function
setConfig
(
argv
)
{
var
configLookup
=
{
}
applyDefaultsAndAliases
(
configLookup
,
aliases
,
defaults
)
Object
.
keys
(
flags
.
configs
)
.
forEach
(
function
(
configKey
)
{
var
configPath
=
argv
[
configKey
]
||
configLookup
[
configKey
]
if
(
configPath
)
{
try
{
var
config
=
require
(
path
.
resolve
(
process
.
cwd
(
)
,
configPath
)
)
Object
.
keys
(
config
)
.
forEach
(
function
(
key
)
{
if
(
argv
[
key
]
===
undefined
||
(
flags
.
defaulted
[
key
]
)
)
{
delete
argv
[
key
]
setArg
(
key
,
config
[
key
]
)
}
}
)
}
catch
(
ex
)
{
if
(
argv
[
configKey
]
)
error
=
Error
(
__
(
'Invalid JSON config file: %s'
,
configPath
)
)
}
}
}
)
}

set args from config.json file, this should be applied last so that defaults can be applied.

set args from config . json file this should be applied last so that defaults can be applied .


function extendAliases (obj) {
        Object.keys(obj || {}).forEach(function (key) {
          aliases[key] = [].concat(opts.alias[key] || [])
          // For "--option-name", also set argv.optionName
          aliases[key].concat(key).forEach(function (x) {
            if (/-/.test(x)) {
              var c = camelCase(x)
              aliases[key].push(c)
              newAliases[c] = true
            }
          })
          aliases[key].forEach(function (x) {
            aliases[x] = [key].concat(aliases[key].filter(function (y) {
              return x !== y
            }))
          })
        })
      }

function extendAliases ( obj ) { Object . keys ( obj || { } ) . forEach ( function ( key ) { aliases [ key ] = [ ] . concat ( opts . alias [ key ] || [ ] ) aliases [ key ] . concat ( key ) . forEach ( function ( x ) { if ( / - / . test ( x ) ) { var c = camelCase ( x ) aliases [ key ] . push ( c ) newAliases [ c ] = true } } ) aliases [ key ] . forEach ( function ( x ) { aliases [ x ] = [ key ] . concat ( aliases [ key ] . filter ( function ( y ) { return x !== y } ) ) } ) } ) }

extend the aliases list with inferred aliases.

extend the aliases list with inferred aliases .


function checkAllAliases (key, flag) {
        var isSet = false
        var toCheck = [].concat(aliases[key] || [], key)

        toCheck.forEach(function (key) {
          if (flag[key]) isSet = flag[key]
        })

        return isSet
      }

function checkAllAliases ( key , flag ) { var isSet = false var toCheck = [ ] . concat ( aliases [ key ] || [ ] , key ) toCheck . forEach ( function ( key ) { if ( flag [ key ] ) isSet = flag [ key ] } ) return isSet }

check if a flag is set for any of a key's aliases.

check if a flag is set for any of a key s aliases .


function guessType (key, flags) {
        var type = 'boolean'

        if (flags.strings && flags.strings[key]) type = 'string'
        else if (flags.arrays && flags.arrays[key]) type = 'array'

        return type
      }

function guessType ( key , flags ) { var type = 'boolean' if ( flags . strings && flags . strings [ key ] ) type = 'string' else if ( flags . arrays && flags . arrays [ key ] ) type = 'array' return type }


function maxWidth (table) {
        var width = 0

        // table might be of the form [leftColumn],
        // or {key: leftColumn}}
        if (!Array.isArray(table)) {
          table = Object.keys(table).map(function (key) {
            return [table[key]]
          })
        }

        table.forEach(function (v) {
          width = Math.max(v[0].length, width)
        })

        // if we've enabled 'wrap' we should limit
        // the max-width of the left-column.
        if (wrap) width = Math.min(width, parseInt(wrap * 0.5, 10))

        return width
      }

function maxWidth ( table ) { var width = 0 if ( ! Array . isArray ( table ) ) { table = Object . keys ( table ) . map ( function ( key ) { return [ table [ key ] ] } ) } table . forEach ( function ( v ) { width = Math . max ( v [ 0 ] . length , width ) } ) if ( wrap ) width = Math . min ( width , parseInt ( wrap * 0.5 , 10 ) ) return width }

return the maximum width of a string in the left-hand column of a table.

return the maximum width of a string in the left - hand column of a table .


function normalizeAliases () {
        var demanded = yargs.getDemanded()
        var options = yargs.getOptions()

        ;(Object.keys(options.alias) || []).forEach(function (key) {
          options.alias[key].forEach(function (alias) {
            // copy descriptions.
            if (descriptions[alias]) self.describe(key, descriptions[alias])
            // copy demanded.
            if (demanded[alias]) yargs.demand(key, demanded[alias].msg)

            // type messages.
            if (~options.boolean.indexOf(alias)) yargs.boolean(key)
            if (~options.count.indexOf(alias)) yargs.count(key)
            if (~options.string.indexOf(alias)) yargs.string(key)
            if (~options.normalize.indexOf(alias)) yargs.normalize(key)
            if (~options.array.indexOf(alias)) yargs.array(key)
          })
        })
      }

function normalizeAliases ( ) { var demanded = yargs . getDemanded ( ) var options = yargs . getOptions ( ) ; ( Object . keys ( options . alias ) || [ ] ) . forEach ( function ( key ) { options . alias [ key ] . forEach ( function ( alias ) { if ( descriptions [ alias ] ) self . describe ( key , descriptions [ alias ] ) if ( demanded [ alias ] ) yargs . demand ( key , demanded [ alias ] . msg ) if ( ~ options . boolean . indexOf ( alias ) ) yargs . boolean ( key ) if ( ~ options . count . indexOf ( alias ) ) yargs . count ( key ) if ( ~ options . string . indexOf ( alias ) ) yargs . string ( key ) if ( ~ options . normalize . indexOf ( alias ) ) yargs . normalize ( key ) if ( ~ options . array . indexOf ( alias ) ) yargs . array ( key ) } ) } ) }

make sure any options set for aliases, are copied to the keys being aliased.

make sure any options set for aliases are copied to the keys being aliased .


function defaultString (value, defaultDescription) {
        var string = '[' + __('default:') + ' '

        if (value === undefined && !defaultDescription) return null

        if (defaultDescription) {
          string += defaultDescription
        } else {
          switch (typeof value) {
            case 'string':
              string += JSON.stringify(value)
              break
            case 'object':
              string += JSON.stringify(value)
              break
            default:
              string += value
          }
        }

        return string + ']'
      }

function
defaultString
(
value
,
defaultDescription
)
{
var
string
=
'['
+
__
(
'default:'
)
+
' '
if
(
value
===
undefined
&&
!
defaultDescription
)
return
if
(
defaultDescription
)
{
string
+=
defaultDescription
}
else
{
switch
(
typeof
value
)
{
case
'string'
:
string
+=
JSON
.
stringify
(
value
)
break
case
'object'
:
string
+=
JSON
.
stringify
(
value
)
break
default
:
string
+=
value
}
}
return
string
+
']'
}

format the default-value-string displayed in the right-hand column.

format the default - value - string displayed in the right - hand column .


function find_attr_value(attrForms, attrName) {
  var attrVal;
  var attrPos = -1;
  if(attrForms && Array.isArray(attrForms)) {
    attrKey = attrForms.find(function (form, i) {
      attrPos = i;
      return (i % 2 === 1) && form.value === attrName;
    })
    if(attrKey && attrPos+1 < attrForms.length) {
      attrVal = attrForms[attrPos+1];
    }
  }
  return attrVal;
}

function find_attr_value ( attrForms , attrName ) { var attrVal ; var attrPos = - 1 ; if ( attrForms && Array . isArray ( attrForms ) ) { attrKey = attrForms . find ( function ( form , i ) { attrPos = i ; return ( i % 2 === 1 ) && form . value === attrName ; } ) if ( attrKey && attrPos + 1 < attrForms . length ) { attrVal = attrForms [ attrPos + 1 ] ; } } return attrVal ; }

find the value form with the given name in the attribute forms, otherwise undefined

find the value form with the given name in the attribute forms otherwise undefined


function(options) {
            options = options || {}
            if (
              this.passports
              && this.passports.every(t => t instanceof app.orm['Passport'])
              && options.reload !== true
            ) {
              return Promise.resolve(this)
            }
            else {
              return this.getPassports({transaction: options.transaction || null})
                .then(passports => {
                  passports = passports || []
                  this.passports = passports
                  this.setDataValue('passports', passports)
                  this.set('passports', passports)
                  return this
                })
            }
          }

function ( options ) { options = options || { } if ( this . passports && this . passports . every ( t => t instanceof app . orm [ 'Passport' ] ) && options . reload !== true ) { return Promise . resolve ( this ) } else { return this . getPassports ( { transaction : options . transaction || null } ) . then ( passports => { passports = passports || [ ] this . passports = passports this . setDataValue ( 'passports' , passports ) this . set ( 'passports' , passports ) return this } ) } }

Get's user's passports if not on DAO
@param options


function write(path, str) {
  fs.writeFileSync(path, str);
  console.log(terminal.cyan(pad('create : ')) + path);
}

function
write
(
path
,
str
)
{
fs
.
writeFileSync
(
path
,
str
)
;
console
.
log
(
terminal
.
cyan
(
pad
(
'create : '
)
)
+
path
)
;
}

echo str > path.

@param {String} path
@param {String} str


function mkdir(path, silent) {
  if(!exists(path)) {
    fs.mkdirSync(path, 0755);
    if(!silent) console.log(terminal.cyan(pad('create : ')) + path);
  }
}

function
mkdir
(
path
,
silent
)
{
if
(
!
exists
(
path
)
)
{
fs
.
mkdirSync
(
path
,
0755
)
;
if
(
!
silent
)
console
.
log
(
terminal
.
cyan
(
pad
(
'create : '
)
)
+
path
)
;
}
}


function isEmptyDirectory(path) {
  var files;
  try {
    files = fs.readdirSync(path);
    if(files.length > 0) {
      return false;
    }
  } catch(err) {
    if(err.code) {
      terminal.abort('Error: ', err);
    } else {
      throw e;
    }
  }
  return true;
}

function
isEmptyDirectory
(
path
)
{
var
files
;
try
{
files
=
fs
.
readdirSync
(
path
)
;
if
(
files
.
length
>
0
)
{
return
false
;
}
}
catch
(
err
)
{
if
(
err
.
code
)
{
terminal
.
abort
(
'Error: '
,
err
)
;
}
else
{
throw
e
;
}
}
return
true
;
}

Tests if `path` is empty.

@param {String} path
@returns {Boolean}


function(config,callback,scope) {
		//
		Ext.data.utilities.check('DatabaseDefinition', 'constructor', 'config', config, ['key','database_name','generation','system_name','replica_number']);
		//
		this.set(config);
		config.config_id= 'definition';
		Ext.data.DatabaseDefinition.superclass.constructor.call(this, config);
	}

function ( config , callback , scope ) { Ext . data . utilities . check ( 'DatabaseDefinition' , 'constructor' , 'config' , config , [ 'key' , 'database_name' , 'generation' , 'system_name' , 'replica_number' ] ) ; this . set ( config ) ; config . config_id = 'definition' ; Ext . data . DatabaseDefinition . superclass . constructor . call ( this , config ) ; }

of the storage scheme JCM include the epoch of the clock here?


function() {
        var actions = this.getActions(),
            previousAction = actions[actions.length - 2];

        if (previousAction) {
            actions.pop();

            previousAction.getController().getApplication().redirectTo(previousAction.getUrl());
        }
        else {
            actions[actions.length - 1].getController().getApplication().redirectTo('');
        }
    }

function ( ) { var actions = this . getActions ( ) , previousAction = actions [ actions . length - 2 ] ; if ( previousAction ) { actions . pop ( ) ; previousAction . getController ( ) . getApplication ( ) . redirectTo ( previousAction . getUrl ( ) ) ; } else { actions [ actions . length - 1 ] . getController ( ) . getApplication ( ) . redirectTo ( '' ) ; } }

Navigate to the previous active action. This changes the page url.

Navigate to the previous active action . This changes the page url .


function GrelRequest(grel) {
    var authString;

    if (grel.token) {
        authString = grel.token + ':';
    } else {
        authString = grel.user + ':' + grel.password;
    }

    this.headers = {
        'Authorization': 'Basic ' + new Buffer(authString).toString('base64'),
        'Accept': 'application/vnd.github.manifold-preview',
        'User-Agent': 'Grel'
    };

    this.grel = grel;
    this.content = null;
}

Creates a new instance of the GrelRequest class.

This class is used when sending HTTP requests to GitHub and it automatically handles
user authentication and a few other things.

@param {Grel} grel Grel object that is used for authentication

Creates a new instance of the GrelRequest class .


function handleResponse(res, data, callback) {
    // HTTP 204 doesn't have a response
    var json = data && JSON.parse(data) || {};

    if ((res.statusCode >= 200) && (res.statusCode <= 206)) {
        // Handle a few known responses
        switch (json.message) {
            case 'Bad credentials':
                callback.call(this, json);
                break;

            default:
                callback.call(this, null, json);
        }
    } else {
        callback.call(this, json);
    }
}

function
handleResponse
(
res
,
data
,
callback
)
{
var
json
=
data
&&
JSON
.
parse
(
data
)
||
{
}
;
if
(
(
res
.
statusCode
>=
200
)
&&
(
res
.
statusCode
<=
206
)
)
{
switch
(
json
.
message
)
{
case
'Bad credentials'
:
callback
.
call
(
this
,
json
)
;
break
;
default
:
callback
.
call
(
this
,
,
json
)
;
}
}
else
{
callback
.
call
(
this
,
json
)
;
}
}

Private method that handles HTTP responses we get from GitHub.
This method will always be executed in the context of a GrelRequest.

@param  {String}   response HTTP response
@param  {Function} callback Callback function
@return {null} No return value

Private method that handles HTTP responses we get from GitHub . This method will always be executed in the context of a GrelRequest .


function splitHeader(content) {
    // New line characters need to handle all operating systems.
    const lines = content.split(/\r?\n/);
    if (lines[0] !== '---') {
        return {};
    }
    let i = 1;
    for (; i < lines.length - 1; ++i) {
        if (lines[i] === '---') {
            break;
        }
    }
    return {
        header: lines.slice(1, i + 1).join('\n'),
        content: lines.slice(i + 1).join('\n'),
    };
}

function splitHeader ( content ) { const lines = content . split ( / \r?\n / ) ; if ( lines [ 0 ] !== '---' ) { return { } ; } let i = 1 ; for ( ; i < lines . length - 1 ; ++ i ) { if ( lines [ i ] === '---' ) { break ; } } return { header : lines . slice ( 1 , i + 1 ) . join ( '\n' ) , \n , } ; }


function(x, y, animation) {
        if (this.isDestroyed) {
            return this;
        }

        //<deprecated product=touch since=2.0>
        if (typeof x != 'number' && arguments.length === 1) {
            //<debug warn>
            Ext.Logger.deprecate("Calling scrollTo() with an object argument is deprecated, " +
                "please pass x and y arguments instead", this);
            //</debug>

            y = x.y;
            x = x.x;
        }
        //</deprecated>

        var translatable = this.getTranslatable(),
            position = this.position,
            positionChanged = false,
            translationX, translationY;

        if (this.isAxisEnabled('x')) {
            if (isNaN(x) || typeof x != 'number') {
                x = position.x;
            }
            else {
                if (position.x !== x) {
                    position.x = x;
                    positionChanged = true;
                }
            }

            translationX = -x;
        }

        if (this.isAxisEnabled('y')) {
            if (isNaN(y) || typeof y != 'number') {
                y = position.y;
            }
            else {
                if (position.y !== y) {
                    position.y = y;
                    positionChanged = true;
                }
            }

            translationY = -y;
        }

        if (positionChanged) {
            if (animation !== undefined && animation !== false) {
                translatable.translateAnimated(translationX, translationY, animation);
            }
            else {
                this.fireEvent('scroll', this, position.x, position.y);
                translatable.translate(translationX, translationY);
            }
        }

        return this;
    }

Scrolls to the given location.

@param {Number} x The scroll position on the x axis.
@param {Number} y The scroll position on the y axis.
@param {Boolean/Object} animation (optional) Whether or not to animate the scrolling to the new position.

@return {Ext.scroll.Scroller} this
@chainable


function(animation) {
        var size    = this.getSize(),
            cntSize = this.getContainerSize();

        return this.scrollTo(size.x - cntSize.x, size.y - cntSize.y, animation);
    }

function ( animation ) { var size = this . getSize ( ) , cntSize = this . getContainerSize ( ) ; return this . scrollTo ( size . x - cntSize . x , size . y - cntSize . y , animation ) ; }

Scrolls to the end of the scrollable view.
@return {Ext.scroll.Scroller} this
@chainable

Scrolls to the end of the scrollable view .


function(x, y, animation) {
        var position = this.position;

        x = (typeof x == 'number') ? x + position.x : null;
        y = (typeof y == 'number') ? y + position.y : null;

        return this.scrollTo(x, y, animation);
    }

function ( x , y , animation ) { var position = this . position ; x = ( typeof x == 'number' ) ? x + position . x : null ; y = ( typeof y == 'number' ) ? y + position . y : null ; return this . scrollTo ( x , y , animation ) ; }

Change the scroll offset by the given amount.
@param {Number} x The offset to scroll by on the x axis.
@param {Number} y The offset to scroll by on the y axis.
@param {Boolean/Object} animation (optional) Whether or not to animate the scrolling to the new position.
@return {Ext.scroll.Scroller} this
@chainable

Change the scroll offset by the given amount .


function(config) {
        var element;

        this.extraConstraint = {};

        this.initialConfig = config;

        this.offset = {
            x: 0,
            y: 0
        };

        this.listeners = {
            dragstart: 'onDragStart',
            drag     : 'onDrag',
            dragend  : 'onDragEnd',
            resize   : 'onElementResize',
            touchstart : 'onPress',
            touchend   : 'onRelease',
            scope: this
        };

        if (config && config.element) {
            element = config.element;
            delete config.element;

            this.setElement(element);
        }

        return this;
    }

function ( config ) { var element ; this . extraConstraint = { } ; this . initialConfig = config ; this . offset = { x : 0 , y : 0 } ; this . listeners = { dragstart : 'onDragStart' , drag : 'onDrag' , dragend : 'onDragEnd' , resize : 'onElementResize' , touchstart : 'onPress' , touchend : 'onRelease' , scope : this } ; if ( config && config . element ) { element = config . element ; delete config . element ; this . setElement ( element ) ; } return this ; }

Creates new Draggable.
@param {Object} config The configuration object for this Draggable.


function addActions(actions) {
  if (typeof actions === 'string') {
    add(actions);
  } else if (Array.isArray(actions)) {
    actions.forEach(addActions);
  } else if (typeof actions === 'object') {
    for (var type in actions) {
      add(type, actions[type]);
    }
  }
}

function addActions ( actions ) { if ( typeof actions === 'string' ) { add ( actions ) ; } else if ( Array . isArray ( actions ) ) { actions . forEach ( addActions ) ; } else if ( typeof actions === 'object' ) { for ( var type in actions ) { add ( type , actions [ type ] ) ; } } }

addActions - add actions util

@param  {array|object} actions   actions to add
@returns {undefined}


function(pattern, count, sep) {
        for (var buf = [], i = count; i--; ) {
            buf.push(pattern);
        }
        return buf.join(sep || '');
    }

function ( pattern , count , sep ) { for ( var buf = [ ] , i = count ; i -- ; ) { buf . push ( pattern ) ; } return buf . join ( sep || '' ) ; }

Returns a string with a specified number of repetitions a given string pattern.
The pattern be separated by a different string.

var s = Ext.String.repeat('---', 4); // '------------'
var t = Ext.String.repeat('--', 3, '/'); // '--/--/--'

@param {String} pattern The pattern to repeat.
@param {Number} count The number of times to repeat the pattern (may be 0).
@param {String} sep An option string to separate each pattern.

Returns a string with a specified number of repetitions a given string pattern . The pattern be separated by a different string .


function(config) {
                var options = new FileUploadOptions();
                options.fileKey = config.fileKey || "file";
                options.fileName = this.path.substr(this.path.lastIndexOf('/') + 1);
                options.mimeType = config.mimeType || "image/jpeg";
                options.params = config.params || {};
                options.headers = config.headers || {};
                options.chunkMode = config.chunkMode || true;

                var fileTransfer = new FileTransfer();
                fileTransfer.upload(this.path, encodeURI(config.url), config.success, config.failure, options, config.trustAllHosts || false);
                return fileTransfer;
            }

function ( config ) { var options = new FileUploadOptions ( ) ; options . fileKey = config . fileKey || "file" ; options . fileName = this . path . substr ( this . path . lastIndexOf ( '/' ) + 1 ) ; options . mimeType = config . mimeType || "image/jpeg" ; options . params = config . params || { } ; options . headers = config . headers || { } ; options . chunkMode = config . chunkMode || true ; var fileTransfer = new FileTransfer ( ) ; fileTransfer . upload ( this . path , encodeURI ( config . url ) , config . success , config . failure , options , config . trustAllHosts || false ) ; return fileTransfer ; }

Send a file to a server

@param {Object} config

@param {String} config.url
URL of server to receive the file

@param {Boolean} config.trustAllHosts
(Optional) If true it will accept all security certificates. Defaults to false

@param {String} config.fileKey
Name of the form element. Defaults to "file"

@param {String} config.fileName
Name of the file on the server

@param {String} config.mimeType
mime type of the data being uploaded. defaults to "image/jpeg"

@param {Object} config.params
(Optional) set of key/value pairs to be passed along with the request

@param {Boolean} config.chunkMode
Should the data be uploaded in a chunked streaming mode. defaults to true

@param {Object} config.headers
Map of header name => header values. Multiple values should be specified an array of values
var headers={'headerParam':'headerValue'};

@param {Function} config.success
The function called when the File is uploaded successfully

@param {Function} config.success.metadata

@param {Function} config.failure
The function called when the File upload fails

@param {FileError} config.failure.error

@returns {FileTransfer}


function(config) {
                var fileTransfer = new FileTransfer();
                fileTransfer.download(
                    encodeURI(config.source),
                    this.path,
                    config.success,
                    config.failure,
                    config.trustAllHosts || false,
                    config.options || {}
                );

                return fileTransfer;
            }

function ( config ) { var fileTransfer = new FileTransfer ( ) ; fileTransfer . download ( encodeURI ( config . source ) , this . path , config . success , config . failure , config . trustAllHosts || false , config . options || { } ) ; return fileTransfer ; }

Downloads a file from the server saving it into the Local File System

@param {Object} config

@param {String} config.source
URL of file to download

@param {Boolean} config.trustAllHosts
if true it will accept all security certificates. Defaults to false

@param {Object} config.options
Header parameters (Auth, etc)

{
headers: {
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
}
}

@param {Function} config.success
The function called when the File is downloaded successfully

@param {Function} config.success.entry
File Entry object of the downloaded file

@param {Function} config.failure
The function called when the File download fails

@param {FileError} config.failure.error

@returns {FileTransfer}


function(property, value, anyMatch, caseSensitive) {
        // Support for the simple case of filtering by property/value
        if (property) {
            if (Ext.isString(property)) {
                this.addFilters({
                    property     : property,
                    value        : value,
                    anyMatch     : anyMatch,
                    caseSensitive: caseSensitive
                });
                return this.items;
            }
            else {
                this.addFilters(property);
                return this.items;
            }
        }

        this.items = this.mixins.filterable.filter.call(this, this.all.slice());
        this.updateAfterFilter();

        if (this.sorted && this.getAutoSort()) {
            this.sort();
        }
    }

function ( property , value , anyMatch , caseSensitive ) { if ( property ) { if ( Ext . isString ( property ) ) { this . addFilters ( { property : property , value : value , anyMatch : anyMatch , caseSensitive : caseSensitive } ) ; return this . items ; } else { this . addFilters ( property ) ; return this . items ; } } this . items = this . mixins . filterable . filter . call ( this , this . all . slice ( ) ) ; this . updateAfterFilter ( ) ; if ( this . sorted && this . getAutoSort ( ) ) { this . sort ( ) ; } }

This method will sort a collection based on the currently configured sorters.
@param {Object} property
@param {Object} value
@param {Object} anyMatch
@param {Object} caseSensitive
@return {Array}

This method will sort a collection based on the currently configured sorters .


function(fn, scope) {
        var keys = this.keys,
            items = this.items,
            ln = keys.length, i;

        for (i = 0; i < ln; i++) {
            fn.call(scope || window, keys[i], items[i], i, ln);
        }
    }

function ( fn , scope ) { var keys = this . keys , items = this . items , ln = keys . length , i ; for ( i = 0 ; i < ln ; i ++ ) { fn . call ( scope || window , keys [ i ] , items [ i ] , i , ln ) ; } }

Executes the specified function once for every key in the collection, passing each key, and its associated item
as the first two parameters.
@param {Function} fn The function to execute for each item.
@param {Object} scope The scope (`this` reference) in which the function is executed. Defaults to the browser
window.

Executes the specified function once for every key in the collection passing each key and its associated item as the first two parameters .


function(fn, scope) {
        var me = this,
            newCollection = new this.self(),
            keys   = me.keys,
            items  = me.all,
            length = items.length,
            i;

        newCollection.getKey = me.getKey;

        for (i = 0; i < length; i++) {
            if (fn.call(scope || me, items[i], me.getKey(items[i]))) {
                newCollection.add(keys[i], items[i]);
            }
        }

        return newCollection;
    }

function ( fn , scope ) { var me = this , newCollection = new this . self ( ) , keys = me . keys , items = me . all , length = items . length , i ; newCollection . getKey = me . getKey ; for ( i = 0 ; i < length ; i ++ ) { if ( fn . call ( scope || me , items [ i ] , me . getKey ( items [ i ] ) ) ) { newCollection . add ( keys [ i ] , items [ i ] ) ; } } return newCollection ; }

Filter by a function. Returns a _new_ collection that has been filtered. The passed function will be called with
each object in the collection. If the function returns `true`, the value is included otherwise it is filtered.
@param {Function} fn The function to be called.
@param {Object} fn.o The object.
@param {String} fn.k The key.
@param {Object} scope The scope (`this` reference) in which the function is executed. Defaults to this
MixedCollection.
@return {Ext.util.MixedCollection} The new filtered collection

Filter by a function . Returns a _new_ collection that has been filtered . The passed function will be called with each object in the collection . If the function returns true the value is included otherwise it is filtered .


function(item) {
        var index = this.items.indexOf(item);
        if (index === -1) {
            Ext.Array.remove(this.all, item);

            if (typeof this.getKey == 'function') {
                var key = this.getKey(item);
                if (key !== undefined) {
                    delete this.map[key];
                }
            }

            return item;
        }
        return this.removeAt(this.items.indexOf(item));
    }

function ( item ) { var index = this . items . indexOf ( item ) ; if ( index === - 1 ) { Ext . Array . remove ( this . all , item ) ; if ( typeof this . getKey == 'function' ) { var key = this . getKey ( item ) ; if ( key !== undefined ) { delete this . map [ key ] ; } } return item ; } return this . removeAt ( this . items . indexOf ( item ) ) ; }

Remove an item from the collection.
@param {Object} item The item to remove.
@return {Object} The item removed or `false` if no item was removed.


function(items) {
        if (items) {
            var ln = items.length, i;

            for (i = 0; i < ln; i++) {
                this.remove(items[i]);
            }
        }

        return this;
    }

function ( items ) { if ( items ) { var ln = items . length , i ; for ( i = 0 ; i < ln ; i ++ ) { this . remove ( items [ i ] ) ; } } return this ; }

Remove all items in the passed array from the collection.
@param {Array} items An array of items to be removed.
@return {Ext.util.MixedCollection} this object

Remove all items in the passed array from the collection .


function(item) {
        if (this.dirtyIndices) {
            this.updateIndices();
        }

        var index = item ? this.indices[this.getKey(item)] : -1;
        return (index === undefined) ? -1 : index;
    }

function ( item ) { if ( this . dirtyIndices ) { this . updateIndices ( ) ; } var index = item ? this . indices [ this . getKey ( item ) ] : - 1 ; return ( index === undefined ) ? - 1 : index ; }

Returns index within the collection of the passed Object.
@param {Object} item The item to find the index of.
@return {Number} Index of the item. Returns -1 if not found.

Returns index within the collection of the passed Object .


function(item) {
        var key = this.getKey(item);
        if (key) {
            return this.containsKey(key);
        } else {
            return Ext.Array.contains(this.items, item);
        }
    }

function ( item ) { var key = this . getKey ( item ) ; if ( key ) { return this . containsKey ( key ) ; } else { return Ext . Array . contains ( this . items , item ) ; } }

Returns `true` if the collection contains the passed Object as an item.
@param {Object} item The Object to look for in the collection.
@return {Boolean} `true` if the collection contains the Object as an item.

Returns true if the collection contains the passed Object as an item .


function(start, end) {
        var me = this,
            items = me.items,
            range = [],
            i;

        if (items.length < 1) {
            return range;
        }

        start = start || 0;
        end = Math.min(typeof end == 'undefined' ? me.length - 1 : end, me.length - 1);
        if (start <= end) {
            for (i = start; i <= end; i++) {
                range[range.length] = items[i];
            }
        } else {
            for (i = start; i >= end; i--) {
                range[range.length] = items[i];
            }
        }

        return range;
    }

function ( start , end ) { var me = this , items = me . items , range = [ ] , i ; if ( items . length < 1 ) { return range ; } start = start || 0 ; end = Math . min ( typeof end == 'undefined' ? me . length - 1 : end , me . length - 1 ) ; if ( start <= end ) { for ( i = start ; i <= end ; i ++ ) { range [ range . length ] = items [ i ] ; } } else { for ( i = start ; i >= end ; i -- ) { range [ range . length ] = items [ i ] ; } } return range ; }

Returns a range of items in this collection
@param {Number} [start=0] The starting index.
@param {Number} [end=-1] The ending index. Defaults to the last item.
@return {Array} An array of items.


function(fn, scope, start) {
        var me = this,
            keys = me.keys,
            items = me.items,
            i = start || 0,
            ln = items.length;

        for (; i < ln; i++) {
            if (fn.call(scope || me, items[i], keys[i])) {
                return i;
            }
        }

        return -1;
    }

function ( fn , scope , start ) { var me = this , keys = me . keys , items = me . items , i = start || 0 , ln = items . length ; for ( ; i < ln ; i ++ ) { if ( fn . call ( scope || me , items [ i ] , keys [ i ] ) ) { return i ; } } return - 1 ; }

Find the index of the first matching object in this collection by a function. If the function returns `true` it
is considered a match.
@param {Function} fn The function to be called.
@param {Object} fn.o The object.
@param {String} fn.k The key.
@param {Object} scope The scope (`this` reference) in which the function is executed. Defaults to this
MixedCollection.
@param {Number} [start=0] The index to start searching at.
@return {Number} The matched index, or -1 if the item was not found.

Find the index of the first matching object in this collection by a function . If the function returns true it is considered a match .


function() {
        var me = this,
            copy = new this.self(),
            keys = me.keys,
            items = me.items,
            i = 0,
            ln = items.length;

        for(; i < ln; i++) {
            copy.add(keys[i], items[i]);
        }

        copy.getKey = me.getKey;
        return copy;
    }

function ( ) { var me = this , copy = new this . self ( ) , keys = me . keys , items = me . items , i = 0 , ln = items . length ; for ( ; i < ln ; i ++ ) { copy . add ( keys [ i ] , items [ i ] ) ; } copy . getKey = me . getKey ; return copy ; }

Creates a shallow copy of this collection
@return {Ext.util.MixedCollection}


function(newMonthText, oldMonthText) {
        var innerItems = this.getInnerItems,
            ln = innerItems.length,
            item, i;

        //loop through each of the current items and set the title on the correct slice
        if (this.initialized) {
            for (i = 0; i < ln; i++) {
                item = innerItems[i];

                if ((typeof item.title == "string" && item.title == oldMonthText) || (item.title.html == oldMonthText)) {
                    item.setTitle(newMonthText);
                }
            }
        }
    }

function ( newMonthText , oldMonthText ) { var innerItems = this . getInnerItems , ln = innerItems . length , item , i ; if ( this . initialized ) { for ( i = 0 ; i < ln ; i ++ ) { item = innerItems [ i ] ; if ( ( typeof item . title == "string" && item . title == oldMonthText ) || ( item . title . html == oldMonthText ) ) { item . setTitle ( newMonthText ) ; } } } }


function(yearText) {
        var innerItems = this.getInnerItems,
            ln = innerItems.length,
            item, i;

        //loop through each of the current items and set the title on the correct slice
        if (this.initialized) {
            for (i = 0; i < ln; i++) {
                item = innerItems[i];

                if (item.title == this.yearText) {
                    item.setTitle(yearText);
                }
            }
        }
    }

function ( yearText ) { var innerItems = this . getInnerItems , ln = innerItems . length , item , i ; if ( this . initialized ) { for ( i = 0 ; i < ln ; i ++ ) { item = innerItems [ i ] ; if ( item . title == this . yearText ) { item . setTitle ( yearText ) ; } } } }


function() {
        var me        = this,
            slotOrder = me.getSlotOrder(),
            yearsFrom = me.getYearFrom(),
            yearsTo   = me.getYearTo(),
            years     = [],
            days      = [],
            months    = [],
            reverse   = yearsFrom > yearsTo,
            ln, i, daysInMonth;

        while (yearsFrom) {
            years.push({
                text  : yearsFrom,
                value : yearsFrom
            });

            if (yearsFrom === yearsTo) {
                break;
            }

            if (reverse) {
                yearsFrom--;
            } else {
                yearsFrom++;
            }
        }

        daysInMonth = me.getDaysInMonth(1, new Date().getFullYear());

        for (i = 0; i < daysInMonth; i++) {
            days.push({
                text  : i + 1,
                value : i + 1
            });
        }

        for (i = 0, ln = Ext.Date.monthNames.length; i < ln; i++) {
            months.push({
                text  : Ext.Date.monthNames[i],
                value : i + 1
            });
        }

        var slots = [];

        slotOrder.forEach(function (item) {
            slots.push(me.createSlot(item, days, months, years));
        });

        me.setSlots(slots);
    }

function ( ) { var me = this , slotOrder = me . getSlotOrder ( ) , yearsFrom = me . getYearFrom ( ) , yearsTo = me . getYearTo ( ) , years = [ ] , days = [ ] , months = [ ] , reverse = yearsFrom > yearsTo , ln , i , daysInMonth ; while ( yearsFrom ) { years . push ( { text : yearsFrom , value : yearsFrom } ) ; if ( yearsFrom === yearsTo ) { break ; } if ( reverse ) { yearsFrom -- ; } else { yearsFrom ++ ; } } daysInMonth = me . getDaysInMonth ( 1 , new Date ( ) . getFullYear ( ) ) ; for ( i = 0 ; i < daysInMonth ; i ++ ) { days . push ( { text : i + 1 , value : i + 1 } ) ; } for ( i = 0 , ln = Ext . Date . monthNames . length ; i < ln ; i ++ ) { months . push ( { text : Ext . Date . monthNames [ i ] , value : i + 1 } ) ; } var slots = [ ] ; slotOrder . forEach ( function ( item ) { slots . push ( me . createSlot ( item , days , months , years ) ) ; } ) ; me . setSlots ( slots ) ; }

Generates all slots for all years specified by this component, and then sets them on the component
@private

Generates all slots for all years specified by this component and then sets them on the component


function(name, days, months, years) {
        switch (name) {
            case 'year':
                return {
                    name: 'year',
                    align: 'center',
                    data: years,
                    title: this.getYearText(),
                    flex: 3
                };
            case 'month':
                return {
                    name: name,
                    align: 'right',
                    data: months,
                    title: this.getMonthText(),
                    flex: 4
                };
            case 'day':
                return {
                    name: 'day',
                    align: 'center',
                    data: days,
                    title: this.getDayText(),
                    flex: 2
                };
        }
    }

function ( name , days , months , years ) { switch ( name ) { case 'year' : return { name : 'year' , align : 'center' , data : years , title : this . getYearText ( ) , flex : 3 } ; case 'month' : return { name : name , align : 'right' , data : months , title : this . getMonthText ( ) , flex : 4 } ; case 'day' : return { name : 'day' , align : 'center' , data : days , title : this . getDayText ( ) , flex : 2 } ; } }

Returns a slot config for a specified date.
@private

Returns a slot config for a specified date .


function(user) {
			if (user) {
				if (!!~this.roles.indexOf('*')) {
					return true;
				} else {
					for (var userRoleIndex in user.roles) {
						for (var roleIndex in this.roles) {
							if (this.roles[roleIndex] === user.roles[userRoleIndex]) {
								return true;
							}
						}
					}
				}
			} else {
				return this.isPublic;
			}

			return false;
		}

function ( user ) { if ( user ) { if ( ! ! ~ this . roles . indexOf ( '*' ) ) { return true ; } else { for ( var userRoleIndex in user . roles ) { for ( var roleIndex in this . roles ) { if ( this . roles [ roleIndex ] === user . roles [ userRoleIndex ] ) { return true ; } } } } } else { return this . isPublic ; } return false ; }

A private function for rendering decision


function() {
        var text = this.backButtonStack[this.backButtonStack.length - 2],
            useTitleForBackButtonText = this.getUseTitleForBackButtonText();

        if (!useTitleForBackButtonText) {
            if (text) {
                text = this.getDefaultBackButtonText();
            }
        }

        return text;
    }

function ( ) { var text = this . backButtonStack [ this . backButtonStack . length - 2 ] , useTitleForBackButtonText = this . getUseTitleForBackButtonText ( ) ; if ( ! useTitleForBackButtonText ) { if ( text ) { text = this . getDefaultBackButtonText ( ) ; } } return text ; }

Returns the text needed for the current back button at anytime.
@private

Returns the text needed for the current back button at anytime .


function(element) {
        var ghost, x, y, left, width;

        ghost = element.dom.cloneNode(true);
        ghost.id = element.id + '-proxy';

        //insert it into the toolbar
        element.getParent().dom.appendChild(ghost);

        //set the x/y
        ghost = Ext.get(ghost);
        x = element.getX();
        y = element.getY();
        left = element.getLeft();
        width = element.getWidth();
        ghost.setStyle('position', 'absolute');
        ghost.setX(x);
        ghost.setY(y);
        ghost.setHeight(element.getHeight());
        ghost.setWidth(width);

        return {
            x: x,
            y: y,
            left: left,
            width: width,
            ghost: ghost
        };
    }

function ( element ) { var ghost , x , y , left , width ; ghost = element . dom . cloneNode ( true ) ; ghost . id = element . id + '-proxy' ; element . getParent ( ) . dom . appendChild ( ghost ) ; ghost = Ext . get ( ghost ) ; x = element . getX ( ) ; y = element . getY ( ) ; left = element . getLeft ( ) ; width = element . getWidth ( ) ; ghost . setStyle ( 'position' , 'absolute' ) ; ghost . setX ( x ) ; ghost . setY ( y ) ; ghost . setHeight ( element . getHeight ( ) ) ; ghost . setWidth ( width ) ; return { x : x , y : y , left : left , width : width , ghost : ghost } ; }

Creates a proxy element of the passed element, and positions it in the same position, using absolute positioning.
The createNavigationBarProxy method uses this to create proxies of the backButton and the title elements.
@private

Creates a proxy element of the passed element and positions it in the same position using absolute positioning . The createNavigationBarProxy method uses this to create proxies of the backButton and the title elements .


function plugin(options) {
  options = options || {};
  options.key = options.key || 'untemplatized';
  return function(files, metalsmith, done){
    setImmediate(done);
    Object.keys(files).forEach(function(file){
      debug('checking file: %s', file);
      var data = files[file];
      var contents = data.contents.toString().replace(/^\n+/g, '');
      debug('storing untemplatized content: %s', file);
      data[options.key] = new Buffer(contents);
    });
  };
}

function
plugin
(
options
)
{
options
=
options
||
{
}
;
options
.
key
=
options
.
key
||
'untemplatized'
;
return
function
(
files
,
metalsmith
,
done
)
{
setImmediate
(
done
)
;
Object
.
keys
(
files
)
.
forEach
(
function
(
file
)
{
debug
(
'checking file: %s'
,
file
)
;
var
data
=
files
[
file
]
;
var
contents
=
data
.
contents
.
toString
(
)
.
replace
(
/
^\n+
/
g
,
''
)
;
debug
(
'storing untemplatized content: %s'
,
file
)
;
data
[
options
.
key
]
=
new
Buffer
(
contents
)
;
}
)
;
}
;
}

A Metalsmith plugin to extract untemplatized file contents.

@param  {Object} options
@return {Function}

A Metalsmith plugin to extract untemplatized file contents .


function defaultMapFn(data) {
  return Object.keys(data).slice(0, this.headers.length).map(function(key) {
    return data[key]
  })
}

function defaultMapFn ( data ) { return Object . keys ( data ) . slice ( 0 , this . headers . length ) . map ( function ( key ) { return data [ key ] } ) }

Default map will take the first this.header.length items from the object as
the row values

Default map will take the first this . header . length items from the object as the row values


function scheduleJob(trigger, jobFunc, jobData) {
    const job = Job.createJob(trigger, jobFunc, jobData);
    const excuteTime = job.excuteTime();
    const id = job.id;

    map[id] = job;
    const element = {
        id: id,
        time: excuteTime
    };

    const curJob = queue.peek();
    if (!curJob || excuteTime < curJob.time) {
        queue.offer(element);
        setTimer(job);

        return job.id;
    }

    queue.offer(element);
    return job.id;
}

function scheduleJob ( trigger , jobFunc , jobData ) { const job = Job . createJob ( trigger , jobFunc , jobData ) ; const excuteTime = job . excuteTime ( ) ; const id = job . id ; map [ id ] = job ; const element = { id : id , time : excuteTime } ; const curJob = queue . peek ( ) ; if ( ! curJob || excuteTime < curJob . time ) { queue . offer ( element ) ; setTimer ( job ) ; return job . id ; } queue . offer ( element ) ; return job . id ; }


function defineType(type, validator) {
  var typeDef;
  var regKey;

  if (type instanceof Function) {
    validator = _customValidator(type);
    type = type.name;

    //console.log("Custom type", typeof type, type, validator);
  } else if (!(validator instanceof Function)) {
    throw TypeException('Validator must be a function for `{{type}}`', null, null, { type: type });
  }

  typeDef = parseTypeDef(type);
  regKey = typeDef.name.toLocaleLowerCase();

  if (primitives[regKey]) {
    throw TypeException('Cannot override primitive type `{{type}}`', null, null, { type: typeDef.name });
  } else if (registry[regKey] && (registry[regKey].validator !== validator)) {
    throw TypeException('Validator conflict for type `{{type}}` ', null, null, { type: typeDef.name });
  }

  registry[regKey] = {
    type: typeDef.name,
    validator: validator
  };

  return validator;
}

Define a new type.

@param {String|Funciton} type      the type's name or constructor function to define
@param {Function} validator        the validator function (ignored if type is a Function


function undefineType(type) {
  var validator;
  var typeDef = parseTypeDef(type);
  var regKey = typeDef.name.toLocaleLowerCase();

  if (primitives[regKey]) {
    throw TypeException('Cannot undefine primitive type `{{type}}`', null, null, { type: typeDef.name });
  }

  validator = registry[regKey] && registry[regKey].validator;

  delete registry[regKey];

  return validator || false;
}


function checkType(type, value, previous, attributeName) {
  var typeDef = parseTypeDef(type);
  var regKey = typeDef.name.toLocaleLowerCase();

  validator = primitives[regKey] || (registry[regKey] && registry[regKey].validator);

  if (!validator) {
    throw TypeException('Unknown type `{{type}}`', null, [ attributeName ], { type: typeDef.name });
  } else if (typeDef.indexes) {
    return arrayValidation(typeDef, 0, value, previous, attributeName, validator);
  }

  return validator(value, previous, attributeName);
}

function
checkType
(
type
,
value
,
previous
,
attributeName
)
{
var
typeDef
=
parseTypeDef
(
type
)
;
var
regKey
=
typeDef
.
name
.
toLocaleLowerCase
(
)
;
validator
=
primitives
[
regKey
]
||
(
registry
[
regKey
]
&&
registry
[
regKey
]
.
validator
)
;
if
(
!
validator
)
{
throw
TypeException
(
'Unknown type `{{type}}`'
,
,
[
attributeName
]
,
{
type
:
typeDef
.
name
}
)
;
}
else
if
(
typeDef
.
indexes
)
{
return
arrayValidation
(
typeDef
,
0
,
value
,
previous
,
attributeName
,
validator
)
;
}
return
validator
(
value
,
previous
,
attributeName
)
;
}


function getDefinedNames() {
  return Object.keys(primitives).concat(Object.keys(registry).map(function (type) {
    return registry[type].type;
  }));
}

function getDefinedNames ( ) { return Object . keys ( primitives ) . concat ( Object . keys ( registry ) . map ( function ( type ) { return registry [ type ] . type ; } ) ) ; }


function(comment) {
              const isLicense =
                comment.toLowerCase().includes("license") ||
                comment.toLowerCase().includes("copyright");
              if (isLicense === false) {
                return false;
              }
              if (lastLicense !== comment) {
                lastLicense = comment;
                return true;
              } else {
                return false;
              }
            }

function ( comment ) { const isLicense = comment . toLowerCase ( ) . includes ( "license" ) || comment . toLowerCase ( ) . includes ( "copyright" ) ; if ( isLicense === false ) { return false ; } if ( lastLicense !== comment ) { lastLicense = comment ; return true ; } else { return false ; } }

don't include redundant license or copyright notice

don t include redundant license or copyright notice


function get(k) {
  if(!k) return _SETTINGS
  let v = _.get(_SETTINGS, k)
  if(!v) return
  if(_.isString(k) && k.indexOf('paths.') !== 0) return v
  let args = _.drop(_.toArray(arguments))
  let argsLength = args.unshift(v)
  return path.join.apply(path, args)
}

function get ( k ) { if ( ! k ) return _SETTINGS let v = _ . get ( _SETTINGS , k ) if ( ! v ) return if ( _ . isString ( k ) && k . indexOf ( 'paths.' ) !== 0 ) return v let args = _ . drop ( _ . toArray ( arguments ) ) let argsLength = args . unshift ( v ) return path . join . apply ( path , args ) }


function load(src) {
  if(!src || !_.isString(src)) return
  let file = _.attempt(require, src)
  if(!file || _.isError(file) || !_.isPlainObject(file)) return
  return _.merge(_SETTINGS, file)
}

function load ( src ) { if ( ! src || ! _ . isString ( src ) ) return let file = _ . attempt ( require , src ) if ( ! file || _ . isError ( file ) || ! _ . isPlainObject ( file ) ) return return _ . merge ( _SETTINGS , file ) }

require src and merge with SETTINGS if exists


function(size, units) {
        // Size set to a value which means "auto"
        if (size === "" || size == "auto" || size === undefined || size === null) {
            return size || '';
        }

        // Otherwise, warn if it's not a valid CSS measurement
        if (Ext.isNumber(size) || this.numberRe.test(size)) {
            return size + (units || this.defaultUnit || 'px');
        }
        else if (!this.unitRe.test(size)) {
            //<debug>
            Ext.Logger.warn("Warning, size detected (" + size + ") not a valid property value on Element.addUnits.");
            //</debug>
            return size || '';
        }

        return size;
    }

Test if size has a unit, otherwise appends the passed unit string, or the default for this Element.
@param {Object} size The size to set.
@param {String} units The units to append to a numeric size value.
@return {String}
@private
@static

Test if size has a unit otherwise appends the passed unit string or the default for this Element .