id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
38,400
imbo/imboclient-js
lib/client.js
function(publicKey, expandGroups, callback) { var qs = ''; if (!callback && typeof expandGroups === 'function') { callback = expandGroups; } else if (expandGroups) { qs = '?expandGroups=1'; } request.get( this.getResourceUrl({ path: '/keys/' + publicKey + '/access' + qs, user: null }), function onAccessControlRulesResponse(err, res, body) { callback(err, body, res); } ); return this; }
javascript
function(publicKey, expandGroups, callback) { var qs = ''; if (!callback && typeof expandGroups === 'function') { callback = expandGroups; } else if (expandGroups) { qs = '?expandGroups=1'; } request.get( this.getResourceUrl({ path: '/keys/' + publicKey + '/access' + qs, user: null }), function onAccessControlRulesResponse(err, res, body) { callback(err, body, res); } ); return this; }
[ "function", "(", "publicKey", ",", "expandGroups", ",", "callback", ")", "{", "var", "qs", "=", "''", ";", "if", "(", "!", "callback", "&&", "typeof", "expandGroups", "===", "'function'", ")", "{", "callback", "=", "expandGroups", ";", "}", "else", "if", "(", "expandGroups", ")", "{", "qs", "=", "'?expandGroups=1'", ";", "}", "request", ".", "get", "(", "this", ".", "getResourceUrl", "(", "{", "path", ":", "'/keys/'", "+", "publicKey", "+", "'/access'", "+", "qs", ",", "user", ":", "null", "}", ")", ",", "function", "onAccessControlRulesResponse", "(", "err", ",", "res", ",", "body", ")", "{", "callback", "(", "err", ",", "body", ",", "res", ")", ";", "}", ")", ";", "return", "this", ";", "}" ]
Get a list of access control rules for a given public key @param {String} publicKey @param {Boolean} expandGroups @param {Function} callback @return {ImboClient}
[ "Get", "a", "list", "of", "access", "control", "rules", "for", "a", "given", "public", "key" ]
809dcc489528dca9d67f49b03b612a99704339d0
https://github.com/imbo/imboclient-js/blob/809dcc489528dca9d67f49b03b612a99704339d0/lib/client.js#L843-L858
38,401
imbo/imboclient-js
lib/client.js
function(publicKey, aclRuleId, callback) { request.get( this.getResourceUrl({ path: '/keys/' + publicKey + '/access/' + aclRuleId, user: null }), function onAccessControlRulesResponse(err, res, body) { callback(err, body, res); } ); return this; }
javascript
function(publicKey, aclRuleId, callback) { request.get( this.getResourceUrl({ path: '/keys/' + publicKey + '/access/' + aclRuleId, user: null }), function onAccessControlRulesResponse(err, res, body) { callback(err, body, res); } ); return this; }
[ "function", "(", "publicKey", ",", "aclRuleId", ",", "callback", ")", "{", "request", ".", "get", "(", "this", ".", "getResourceUrl", "(", "{", "path", ":", "'/keys/'", "+", "publicKey", "+", "'/access/'", "+", "aclRuleId", ",", "user", ":", "null", "}", ")", ",", "function", "onAccessControlRulesResponse", "(", "err", ",", "res", ",", "body", ")", "{", "callback", "(", "err", ",", "body", ",", "res", ")", ";", "}", ")", ";", "return", "this", ";", "}" ]
Get the details for the access control rule with the given ID @param {String} publicKey @param {String} aclRuleId @param {Function} callback @return {ImboClient}
[ "Get", "the", "details", "for", "the", "access", "control", "rule", "with", "the", "given", "ID" ]
809dcc489528dca9d67f49b03b612a99704339d0
https://github.com/imbo/imboclient-js/blob/809dcc489528dca9d67f49b03b612a99704339d0/lib/client.js#L868-L879
38,402
imbo/imboclient-js
lib/client.js
function(publicKey, rules, callback) { if (!Array.isArray(rules)) { rules = [rules]; } if (!publicKey) { throw new Error('Public key must be a valid string'); } var url = this.getResourceUrl({ path: '/keys/' + publicKey + '/access', user: null }); request({ method: 'POST', uri: this.getSignedResourceUrl('POST', url), json: rules, onComplete: function(err, res, body) { callback(err, body, res); } }); return this; }
javascript
function(publicKey, rules, callback) { if (!Array.isArray(rules)) { rules = [rules]; } if (!publicKey) { throw new Error('Public key must be a valid string'); } var url = this.getResourceUrl({ path: '/keys/' + publicKey + '/access', user: null }); request({ method: 'POST', uri: this.getSignedResourceUrl('POST', url), json: rules, onComplete: function(err, res, body) { callback(err, body, res); } }); return this; }
[ "function", "(", "publicKey", ",", "rules", ",", "callback", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "rules", ")", ")", "{", "rules", "=", "[", "rules", "]", ";", "}", "if", "(", "!", "publicKey", ")", "{", "throw", "new", "Error", "(", "'Public key must be a valid string'", ")", ";", "}", "var", "url", "=", "this", ".", "getResourceUrl", "(", "{", "path", ":", "'/keys/'", "+", "publicKey", "+", "'/access'", ",", "user", ":", "null", "}", ")", ";", "request", "(", "{", "method", ":", "'POST'", ",", "uri", ":", "this", ".", "getSignedResourceUrl", "(", "'POST'", ",", "url", ")", ",", "json", ":", "rules", ",", "onComplete", ":", "function", "(", "err", ",", "res", ",", "body", ")", "{", "callback", "(", "err", ",", "body", ",", "res", ")", ";", "}", "}", ")", ";", "return", "this", ";", "}" ]
Add one or more access control rules to the given public key @param {String} publicKey The public key to add rules to @param {Array} rules Array of access control rules to add @param {Function} callback @return {ImboClient}
[ "Add", "one", "or", "more", "access", "control", "rules", "to", "the", "given", "public", "key" ]
809dcc489528dca9d67f49b03b612a99704339d0
https://github.com/imbo/imboclient-js/blob/809dcc489528dca9d67f49b03b612a99704339d0/lib/client.js#L889-L910
38,403
imbo/imboclient-js
lib/client.js
function(imageUrl, callback) { readers.getContentsFromUrl(imageUrl.toString(), function(err, data) { callback(err, err ? null : data); }); return this; }
javascript
function(imageUrl, callback) { readers.getContentsFromUrl(imageUrl.toString(), function(err, data) { callback(err, err ? null : data); }); return this; }
[ "function", "(", "imageUrl", ",", "callback", ")", "{", "readers", ".", "getContentsFromUrl", "(", "imageUrl", ".", "toString", "(", ")", ",", "function", "(", "err", ",", "data", ")", "{", "callback", "(", "err", ",", "err", "?", "null", ":", "data", ")", ";", "}", ")", ";", "return", "this", ";", "}" ]
Get the binary data of an image, specified by URL @param {String} imageUrl @param {Function} callback @return {ImboClient}
[ "Get", "the", "binary", "data", "of", "an", "image", "specified", "by", "URL" ]
809dcc489528dca9d67f49b03b612a99704339d0
https://github.com/imbo/imboclient-js/blob/809dcc489528dca9d67f49b03b612a99704339d0/lib/client.js#L951-L957
38,404
imbo/imboclient-js
lib/client.js
function(imageIdentifier, usePrimary) { if (usePrimary) { return this.options.hosts[0]; } var dec = imageIdentifier.charCodeAt(imageIdentifier.length - 1); // If this is an old image identifier (32 character hex string), // maintain backwards compatibility if (imageIdentifier.match(/^[a-f0-9]{32}$/)) { dec = parseInt(imageIdentifier.substr(0, 2), 16); } return this.options.hosts[dec % this.options.hosts.length]; }
javascript
function(imageIdentifier, usePrimary) { if (usePrimary) { return this.options.hosts[0]; } var dec = imageIdentifier.charCodeAt(imageIdentifier.length - 1); // If this is an old image identifier (32 character hex string), // maintain backwards compatibility if (imageIdentifier.match(/^[a-f0-9]{32}$/)) { dec = parseInt(imageIdentifier.substr(0, 2), 16); } return this.options.hosts[dec % this.options.hosts.length]; }
[ "function", "(", "imageIdentifier", ",", "usePrimary", ")", "{", "if", "(", "usePrimary", ")", "{", "return", "this", ".", "options", ".", "hosts", "[", "0", "]", ";", "}", "var", "dec", "=", "imageIdentifier", ".", "charCodeAt", "(", "imageIdentifier", ".", "length", "-", "1", ")", ";", "// If this is an old image identifier (32 character hex string),", "// maintain backwards compatibility", "if", "(", "imageIdentifier", ".", "match", "(", "/", "^[a-f0-9]{32}$", "/", ")", ")", "{", "dec", "=", "parseInt", "(", "imageIdentifier", ".", "substr", "(", "0", ",", "2", ")", ",", "16", ")", ";", "}", "return", "this", ".", "options", ".", "hosts", "[", "dec", "%", "this", ".", "options", ".", "hosts", ".", "length", "]", ";", "}" ]
Get a predictable hostname for the given image identifier @param {String} imageIdentifier @param {Boolean} [usePrimary=false] Whether to use the primary host @return {String}
[ "Get", "a", "predictable", "hostname", "for", "the", "given", "image", "identifier" ]
809dcc489528dca9d67f49b03b612a99704339d0
https://github.com/imbo/imboclient-js/blob/809dcc489528dca9d67f49b03b612a99704339d0/lib/client.js#L966-L980
38,405
imbo/imboclient-js
lib/client.js
function(method, url, timestamp) { var data = [method, url, this.options.publicKey, timestamp].join('|'), signature = crypto.sha256(this.options.privateKey, data); return signature; }
javascript
function(method, url, timestamp) { var data = [method, url, this.options.publicKey, timestamp].join('|'), signature = crypto.sha256(this.options.privateKey, data); return signature; }
[ "function", "(", "method", ",", "url", ",", "timestamp", ")", "{", "var", "data", "=", "[", "method", ",", "url", ",", "this", ".", "options", ".", "publicKey", ",", "timestamp", "]", ".", "join", "(", "'|'", ")", ",", "signature", "=", "crypto", ".", "sha256", "(", "this", ".", "options", ".", "privateKey", ",", "data", ")", ";", "return", "signature", ";", "}" ]
Generate a signature for the given parameters @param {String} method @param {String} url @param {String} timestamp @return {String}
[ "Generate", "a", "signature", "for", "the", "given", "parameters" ]
809dcc489528dca9d67f49b03b612a99704339d0
https://github.com/imbo/imboclient-js/blob/809dcc489528dca9d67f49b03b612a99704339d0/lib/client.js#L1018-L1023
38,406
imbo/imboclient-js
lib/client.js
function(method, url, date) { var timestamp = (date || new Date()).toISOString().replace(/\.\d+Z$/, 'Z'), addPubKey = this.options.user !== this.options.publicKey, qs = url.toString().indexOf('?') > -1 ? '&' : '?', signUrl = addPubKey ? url + qs + 'publicKey=' + this.options.publicKey : url, signature = this.generateSignature(method, signUrl.toString(), timestamp); qs = addPubKey ? '&' : qs; qs += 'signature=' + encodeURIComponent(signature); qs += '&timestamp=' + encodeURIComponent(timestamp); return signUrl + qs; }
javascript
function(method, url, date) { var timestamp = (date || new Date()).toISOString().replace(/\.\d+Z$/, 'Z'), addPubKey = this.options.user !== this.options.publicKey, qs = url.toString().indexOf('?') > -1 ? '&' : '?', signUrl = addPubKey ? url + qs + 'publicKey=' + this.options.publicKey : url, signature = this.generateSignature(method, signUrl.toString(), timestamp); qs = addPubKey ? '&' : qs; qs += 'signature=' + encodeURIComponent(signature); qs += '&timestamp=' + encodeURIComponent(timestamp); return signUrl + qs; }
[ "function", "(", "method", ",", "url", ",", "date", ")", "{", "var", "timestamp", "=", "(", "date", "||", "new", "Date", "(", ")", ")", ".", "toISOString", "(", ")", ".", "replace", "(", "/", "\\.\\d+Z$", "/", ",", "'Z'", ")", ",", "addPubKey", "=", "this", ".", "options", ".", "user", "!==", "this", ".", "options", ".", "publicKey", ",", "qs", "=", "url", ".", "toString", "(", ")", ".", "indexOf", "(", "'?'", ")", ">", "-", "1", "?", "'&'", ":", "'?'", ",", "signUrl", "=", "addPubKey", "?", "url", "+", "qs", "+", "'publicKey='", "+", "this", ".", "options", ".", "publicKey", ":", "url", ",", "signature", "=", "this", ".", "generateSignature", "(", "method", ",", "signUrl", ".", "toString", "(", ")", ",", "timestamp", ")", ";", "qs", "=", "addPubKey", "?", "'&'", ":", "qs", ";", "qs", "+=", "'signature='", "+", "encodeURIComponent", "(", "signature", ")", ";", "qs", "+=", "'&timestamp='", "+", "encodeURIComponent", "(", "timestamp", ")", ";", "return", "signUrl", "+", "qs", ";", "}" ]
Get a signed version of a given URL @param {String} method - HTTP method @param {String} url - Endpoint URL @param {Date} [date] - Date to use for signing request @return {String}
[ "Get", "a", "signed", "version", "of", "a", "given", "URL" ]
809dcc489528dca9d67f49b03b612a99704339d0
https://github.com/imbo/imboclient-js/blob/809dcc489528dca9d67f49b03b612a99704339d0/lib/client.js#L1033-L1045
38,407
DimitarChristoff/primish
options.js
function(options){ var option, o; this.options || (this.options = {}); o = this.options = primish.merge(primish.clone(this.options), options); // add the events as well, if class has events. if ((this.on && this.off)) for (option in o){ if (o.hasOwnProperty(option)){ if (typeof o[option] !== sFunction || !(/^on[A-Z]/).test(option)) continue; this.on(removeOn(option), o[option]); delete o[option]; } } return this; }
javascript
function(options){ var option, o; this.options || (this.options = {}); o = this.options = primish.merge(primish.clone(this.options), options); // add the events as well, if class has events. if ((this.on && this.off)) for (option in o){ if (o.hasOwnProperty(option)){ if (typeof o[option] !== sFunction || !(/^on[A-Z]/).test(option)) continue; this.on(removeOn(option), o[option]); delete o[option]; } } return this; }
[ "function", "(", "options", ")", "{", "var", "option", ",", "o", ";", "this", ".", "options", "||", "(", "this", ".", "options", "=", "{", "}", ")", ";", "o", "=", "this", ".", "options", "=", "primish", ".", "merge", "(", "primish", ".", "clone", "(", "this", ".", "options", ")", ",", "options", ")", ";", "// add the events as well, if class has events.", "if", "(", "(", "this", ".", "on", "&&", "this", ".", "off", ")", ")", "for", "(", "option", "in", "o", ")", "{", "if", "(", "o", ".", "hasOwnProperty", "(", "option", ")", ")", "{", "if", "(", "typeof", "o", "[", "option", "]", "!==", "sFunction", "||", "!", "(", "/", "^on[A-Z]", "/", ")", ".", "test", "(", "option", ")", ")", "continue", ";", "this", ".", "on", "(", "removeOn", "(", "option", ")", ",", "o", "[", "option", "]", ")", ";", "delete", "o", "[", "option", "]", ";", "}", "}", "return", "this", ";", "}" ]
a mixin class that allows for this.setOptions
[ "a", "mixin", "class", "that", "allows", "for", "this", ".", "setOptions" ]
b80d54e346c8d5594254e95db0936be72264e4b4
https://github.com/DimitarChristoff/primish/blob/b80d54e346c8d5594254e95db0936be72264e4b4/options.js#L25-L42
38,408
Schoonology/discovery
lib/service.js
Service
function Service(options) { if (!(this instanceof Service)) { return new Service(options); } options = options || {}; debug('New Service: %j', options); // There's no reasonable way to protect this, so we let it be writable with // the understanding that .update is called in the future. TL;DR - Write at // your own risk. this.data = clone(options.data || {}); this._dataHash = sigmund(this.data); this._initProperties(options); assert(this.name, 'Name is required.'); }
javascript
function Service(options) { if (!(this instanceof Service)) { return new Service(options); } options = options || {}; debug('New Service: %j', options); // There's no reasonable way to protect this, so we let it be writable with // the understanding that .update is called in the future. TL;DR - Write at // your own risk. this.data = clone(options.data || {}); this._dataHash = sigmund(this.data); this._initProperties(options); assert(this.name, 'Name is required.'); }
[ "function", "Service", "(", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Service", ")", ")", "{", "return", "new", "Service", "(", "options", ")", ";", "}", "options", "=", "options", "||", "{", "}", ";", "debug", "(", "'New Service: %j'", ",", "options", ")", ";", "// There's no reasonable way to protect this, so we let it be writable with", "// the understanding that .update is called in the future. TL;DR - Write at", "// your own risk.", "this", ".", "data", "=", "clone", "(", "options", ".", "data", "||", "{", "}", ")", ";", "this", ".", "_dataHash", "=", "sigmund", "(", "this", ".", "data", ")", ";", "this", ".", "_initProperties", "(", "options", ")", ";", "assert", "(", "this", ".", "name", ",", "'Name is required.'", ")", ";", "}" ]
Creates a new instance of Service with the provided `options`. A Service is a simple wrapper around its `data` to ease managing the Service's representation within its Registry and the announcements thereof. For more information, see the README. @param {Object} options
[ "Creates", "a", "new", "instance", "of", "Service", "with", "the", "provided", "options", "." ]
9d123d74c13f8c9b6904e409f8933b09ab22e175
https://github.com/Schoonology/discovery/blob/9d123d74c13f8c9b6904e409f8933b09ab22e175/lib/service.js#L19-L37
38,409
imbo/imboclient-js
lib/url/imageurl.js
function(options) { options = options || {}; var params = [ 'color=' + (options.color || '000000').replace(/^#/, ''), 'width=' + toInt(options.width || 1), 'height=' + toInt(options.height || 1), 'mode=' + (options.mode || 'outbound') ]; return this.append('border:' + params.join(',')); }
javascript
function(options) { options = options || {}; var params = [ 'color=' + (options.color || '000000').replace(/^#/, ''), 'width=' + toInt(options.width || 1), 'height=' + toInt(options.height || 1), 'mode=' + (options.mode || 'outbound') ]; return this.append('border:' + params.join(',')); }
[ "function", "(", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "var", "params", "=", "[", "'color='", "+", "(", "options", ".", "color", "||", "'000000'", ")", ".", "replace", "(", "/", "^#", "/", ",", "''", ")", ",", "'width='", "+", "toInt", "(", "options", ".", "width", "||", "1", ")", ",", "'height='", "+", "toInt", "(", "options", ".", "height", "||", "1", ")", ",", "'mode='", "+", "(", "options", ".", "mode", "||", "'outbound'", ")", "]", ";", "return", "this", ".", "append", "(", "'border:'", "+", "params", ".", "join", "(", "','", ")", ")", ";", "}" ]
Add a border to the image @param {Object} [options={}] @param {String} [options.color=000000] Color of the border (in hex-format) @param {Number} [options.width=1] Width of the left and right borders @param {Number} [options.height=1] Height of the top and bottom borders @param {String} [options.mode=outbound] Mode of the border, "inline" or "outbound" @return {Imbo.ImageUrl}
[ "Add", "a", "border", "to", "the", "image" ]
809dcc489528dca9d67f49b03b612a99704339d0
https://github.com/imbo/imboclient-js/blob/809dcc489528dca9d67f49b03b612a99704339d0/lib/url/imageurl.js#L72-L83
38,410
imbo/imboclient-js
lib/url/imageurl.js
function(options) { options = options || {}; if (!options.width || !options.height) { throw new Error('width and height must be specified'); } var params = [ 'width=' + toInt(options.width), 'height=' + toInt(options.height) ]; if (options.mode) { params.push('mode=' + options.mode); } if (options.x) { params.push('x=' + toInt(options.x)); } if (options.y) { params.push('y=' + toInt(options.y)); } if (options.bg) { params.push('bg=' + options.bg.replace(/^#/, '')); } return this.append('canvas:' + params.join(',')); }
javascript
function(options) { options = options || {}; if (!options.width || !options.height) { throw new Error('width and height must be specified'); } var params = [ 'width=' + toInt(options.width), 'height=' + toInt(options.height) ]; if (options.mode) { params.push('mode=' + options.mode); } if (options.x) { params.push('x=' + toInt(options.x)); } if (options.y) { params.push('y=' + toInt(options.y)); } if (options.bg) { params.push('bg=' + options.bg.replace(/^#/, '')); } return this.append('canvas:' + params.join(',')); }
[ "function", "(", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "if", "(", "!", "options", ".", "width", "||", "!", "options", ".", "height", ")", "{", "throw", "new", "Error", "(", "'width and height must be specified'", ")", ";", "}", "var", "params", "=", "[", "'width='", "+", "toInt", "(", "options", ".", "width", ")", ",", "'height='", "+", "toInt", "(", "options", ".", "height", ")", "]", ";", "if", "(", "options", ".", "mode", ")", "{", "params", ".", "push", "(", "'mode='", "+", "options", ".", "mode", ")", ";", "}", "if", "(", "options", ".", "x", ")", "{", "params", ".", "push", "(", "'x='", "+", "toInt", "(", "options", ".", "x", ")", ")", ";", "}", "if", "(", "options", ".", "y", ")", "{", "params", ".", "push", "(", "'y='", "+", "toInt", "(", "options", ".", "y", ")", ")", ";", "}", "if", "(", "options", ".", "bg", ")", "{", "params", ".", "push", "(", "'bg='", "+", "options", ".", "bg", ".", "replace", "(", "/", "^#", "/", ",", "''", ")", ")", ";", "}", "return", "this", ".", "append", "(", "'canvas:'", "+", "params", ".", "join", "(", "','", ")", ")", ";", "}" ]
Puts the image inside a canvas @param {Object} options @param {Number} options.width Width of the canvas @param {Number} options.height Height of the canvas @param {String} [options.mode] Placement mode: "free", "center", "center-x" or "center-y" @param {Number} [options.x] X coordinate of the placement of the upper left corner of the existing image @param {Number} [options.y] Y coordinate of the placement of the upper left corner of the existing image @param {String} [options.bg] Background color of the canvas, in hex-format @return {Imbo.ImageUrl}
[ "Puts", "the", "image", "inside", "a", "canvas" ]
809dcc489528dca9d67f49b03b612a99704339d0
https://github.com/imbo/imboclient-js/blob/809dcc489528dca9d67f49b03b612a99704339d0/lib/url/imageurl.js#L97-L126
38,411
imbo/imboclient-js
lib/url/imageurl.js
function(options) { var params = [], opts = options || {}, transform = 'contrast'; if (opts.sharpen) { params.push('sharpen=' + opts.sharpen); } if (params.length) { transform += ':' + params.join(','); } return this.append(transform); }
javascript
function(options) { var params = [], opts = options || {}, transform = 'contrast'; if (opts.sharpen) { params.push('sharpen=' + opts.sharpen); } if (params.length) { transform += ':' + params.join(','); } return this.append(transform); }
[ "function", "(", "options", ")", "{", "var", "params", "=", "[", "]", ",", "opts", "=", "options", "||", "{", "}", ",", "transform", "=", "'contrast'", ";", "if", "(", "opts", ".", "sharpen", ")", "{", "params", ".", "push", "(", "'sharpen='", "+", "opts", ".", "sharpen", ")", ";", "}", "if", "(", "params", ".", "length", ")", "{", "transform", "+=", "':'", "+", "params", ".", "join", "(", "','", ")", ";", "}", "return", "this", ".", "append", "(", "transform", ")", ";", "}" ]
Adjust contrast in the image @param {Object} [options={}] @param {Number} [options.sharpen] Change in contrast given as number of steps up (positive number) or down (negative number) @return {Imbo.ImageUrl}
[ "Adjust", "contrast", "in", "the", "image" ]
809dcc489528dca9d67f49b03b612a99704339d0
https://github.com/imbo/imboclient-js/blob/809dcc489528dca9d67f49b03b612a99704339d0/lib/url/imageurl.js#L148-L162
38,412
imbo/imboclient-js
lib/url/imageurl.js
function(options) { var opts = options || {}, mode = opts.mode, x = opts.x, y = opts.y, width = opts.width, height = opts.height; if (!mode && (isNaN(x) || isNaN(y))) { throw new Error('x and y needs to be specified without a crop mode'); } if (mode === 'center-x' && isNaN(y)) { throw new Error('y needs to be specified when mode is center-x'); } else if (mode === 'center-y' && isNaN(x)) { throw new Error('x needs to be specified when mode is center-y'); } else if (isNaN(width) || isNaN(height)) { throw new Error('width and height needs to be specified'); } var params = [ 'width=' + toInt(width), 'height=' + toInt(height) ]; if (isNumeric(x)) { params.push('x=' + toInt(x)); } if (isNumeric(y)) { params.push('y=' + toInt(y)); } if (mode) { params.push('mode=' + mode); } return this.append('crop:' + params.join(',')); }
javascript
function(options) { var opts = options || {}, mode = opts.mode, x = opts.x, y = opts.y, width = opts.width, height = opts.height; if (!mode && (isNaN(x) || isNaN(y))) { throw new Error('x and y needs to be specified without a crop mode'); } if (mode === 'center-x' && isNaN(y)) { throw new Error('y needs to be specified when mode is center-x'); } else if (mode === 'center-y' && isNaN(x)) { throw new Error('x needs to be specified when mode is center-y'); } else if (isNaN(width) || isNaN(height)) { throw new Error('width and height needs to be specified'); } var params = [ 'width=' + toInt(width), 'height=' + toInt(height) ]; if (isNumeric(x)) { params.push('x=' + toInt(x)); } if (isNumeric(y)) { params.push('y=' + toInt(y)); } if (mode) { params.push('mode=' + mode); } return this.append('crop:' + params.join(',')); }
[ "function", "(", "options", ")", "{", "var", "opts", "=", "options", "||", "{", "}", ",", "mode", "=", "opts", ".", "mode", ",", "x", "=", "opts", ".", "x", ",", "y", "=", "opts", ".", "y", ",", "width", "=", "opts", ".", "width", ",", "height", "=", "opts", ".", "height", ";", "if", "(", "!", "mode", "&&", "(", "isNaN", "(", "x", ")", "||", "isNaN", "(", "y", ")", ")", ")", "{", "throw", "new", "Error", "(", "'x and y needs to be specified without a crop mode'", ")", ";", "}", "if", "(", "mode", "===", "'center-x'", "&&", "isNaN", "(", "y", ")", ")", "{", "throw", "new", "Error", "(", "'y needs to be specified when mode is center-x'", ")", ";", "}", "else", "if", "(", "mode", "===", "'center-y'", "&&", "isNaN", "(", "x", ")", ")", "{", "throw", "new", "Error", "(", "'x needs to be specified when mode is center-y'", ")", ";", "}", "else", "if", "(", "isNaN", "(", "width", ")", "||", "isNaN", "(", "height", ")", ")", "{", "throw", "new", "Error", "(", "'width and height needs to be specified'", ")", ";", "}", "var", "params", "=", "[", "'width='", "+", "toInt", "(", "width", ")", ",", "'height='", "+", "toInt", "(", "height", ")", "]", ";", "if", "(", "isNumeric", "(", "x", ")", ")", "{", "params", ".", "push", "(", "'x='", "+", "toInt", "(", "x", ")", ")", ";", "}", "if", "(", "isNumeric", "(", "y", ")", ")", "{", "params", ".", "push", "(", "'y='", "+", "toInt", "(", "y", ")", ")", ";", "}", "if", "(", "mode", ")", "{", "params", ".", "push", "(", "'mode='", "+", "mode", ")", ";", "}", "return", "this", ".", "append", "(", "'crop:'", "+", "params", ".", "join", "(", "','", ")", ")", ";", "}" ]
Crops the image using specified parameters @param {Object} options @param {String} [options.mode] Crop mode: "center-x" or "center-y" (available in Imbo >= 1.1.0) @param {Number} [options.x] X coordinate of the top left corner of the crop @param {Number} [options.y] Y coordinate of the top left corner of the crop @param {Number} options.width Width of the crop @param {Number} options.height Height of the crop @return {Imbo.ImageUrl}
[ "Crops", "the", "image", "using", "specified", "parameters" ]
809dcc489528dca9d67f49b03b612a99704339d0
https://github.com/imbo/imboclient-js/blob/809dcc489528dca9d67f49b03b612a99704339d0/lib/url/imageurl.js#L186-L224
38,413
imbo/imboclient-js
lib/url/imageurl.js
function(options) { var params = []; if (options.width) { params.push('width=' + toInt(options.width)); } if (options.height) { params.push('height=' + toInt(options.height)); } if (!params.length) { throw new Error('width and/or height needs to be specified'); } return this.append('maxSize:' + params.join(',')); }
javascript
function(options) { var params = []; if (options.width) { params.push('width=' + toInt(options.width)); } if (options.height) { params.push('height=' + toInt(options.height)); } if (!params.length) { throw new Error('width and/or height needs to be specified'); } return this.append('maxSize:' + params.join(',')); }
[ "function", "(", "options", ")", "{", "var", "params", "=", "[", "]", ";", "if", "(", "options", ".", "width", ")", "{", "params", ".", "push", "(", "'width='", "+", "toInt", "(", "options", ".", "width", ")", ")", ";", "}", "if", "(", "options", ".", "height", ")", "{", "params", ".", "push", "(", "'height='", "+", "toInt", "(", "options", ".", "height", ")", ")", ";", "}", "if", "(", "!", "params", ".", "length", ")", "{", "throw", "new", "Error", "(", "'width and/or height needs to be specified'", ")", ";", "}", "return", "this", ".", "append", "(", "'maxSize:'", "+", "params", ".", "join", "(", "','", ")", ")", ";", "}" ]
Resize the image to be at most the size specified while still preserving the aspect ratio. If the image is smaller than the given size, the image remains unchanged @param {Object} options @param {Number} [options.width] Max width of the image @param {Number} [options.height] Max height of the image @return {Imbo.ImageUrl}
[ "Resize", "the", "image", "to", "be", "at", "most", "the", "size", "specified", "while", "still", "preserving", "the", "aspect", "ratio", ".", "If", "the", "image", "is", "smaller", "than", "the", "given", "size", "the", "image", "remains", "unchanged" ]
809dcc489528dca9d67f49b03b612a99704339d0
https://github.com/imbo/imboclient-js/blob/809dcc489528dca9d67f49b03b612a99704339d0/lib/url/imageurl.js#L263-L279
38,414
imbo/imboclient-js
lib/url/imageurl.js
function(options) { if (!options || isNaN(options.angle)) { throw new Error('angle needs to be specified'); } var bg = (options.bg || '000000').replace(/^#/, ''); return this.append('rotate:angle=' + options.angle + ',bg=' + bg); }
javascript
function(options) { if (!options || isNaN(options.angle)) { throw new Error('angle needs to be specified'); } var bg = (options.bg || '000000').replace(/^#/, ''); return this.append('rotate:angle=' + options.angle + ',bg=' + bg); }
[ "function", "(", "options", ")", "{", "if", "(", "!", "options", "||", "isNaN", "(", "options", ".", "angle", ")", ")", "{", "throw", "new", "Error", "(", "'angle needs to be specified'", ")", ";", "}", "var", "bg", "=", "(", "options", ".", "bg", "||", "'000000'", ")", ".", "replace", "(", "/", "^#", "/", ",", "''", ")", ";", "return", "this", ".", "append", "(", "'rotate:angle='", "+", "options", ".", "angle", "+", "',bg='", "+", "bg", ")", ";", "}" ]
Rotate the image by the specified angle @param {Object} options @param {Number} options.angle Angle to rotate by @param {String} [options.bg] Background color of image, in hex-format @return {Imbo.ImageUrl}
[ "Rotate", "the", "image", "by", "the", "specified", "angle" ]
809dcc489528dca9d67f49b03b612a99704339d0
https://github.com/imbo/imboclient-js/blob/809dcc489528dca9d67f49b03b612a99704339d0/lib/url/imageurl.js#L357-L364
38,415
imbo/imboclient-js
lib/url/imageurl.js
function(options) { var params = [], opts = options || {}, transform = 'sharpen'; if (opts.preset) { params.push('preset=' + opts.preset); } if (typeof opts.radius !== 'undefined') { params.push('radius=' + opts.radius); } if (typeof opts.sigma !== 'undefined') { params.push('sigma=' + opts.sigma); } if (typeof opts.gain !== 'undefined') { params.push('gain=' + opts.gain); } if (typeof opts.threshold !== 'undefined') { params.push('threshold=' + opts.threshold); } if (params.length) { transform += ':' + params.join(','); } return this.append(transform); }
javascript
function(options) { var params = [], opts = options || {}, transform = 'sharpen'; if (opts.preset) { params.push('preset=' + opts.preset); } if (typeof opts.radius !== 'undefined') { params.push('radius=' + opts.radius); } if (typeof opts.sigma !== 'undefined') { params.push('sigma=' + opts.sigma); } if (typeof opts.gain !== 'undefined') { params.push('gain=' + opts.gain); } if (typeof opts.threshold !== 'undefined') { params.push('threshold=' + opts.threshold); } if (params.length) { transform += ':' + params.join(','); } return this.append(transform); }
[ "function", "(", "options", ")", "{", "var", "params", "=", "[", "]", ",", "opts", "=", "options", "||", "{", "}", ",", "transform", "=", "'sharpen'", ";", "if", "(", "opts", ".", "preset", ")", "{", "params", ".", "push", "(", "'preset='", "+", "opts", ".", "preset", ")", ";", "}", "if", "(", "typeof", "opts", ".", "radius", "!==", "'undefined'", ")", "{", "params", ".", "push", "(", "'radius='", "+", "opts", ".", "radius", ")", ";", "}", "if", "(", "typeof", "opts", ".", "sigma", "!==", "'undefined'", ")", "{", "params", ".", "push", "(", "'sigma='", "+", "opts", ".", "sigma", ")", ";", "}", "if", "(", "typeof", "opts", ".", "gain", "!==", "'undefined'", ")", "{", "params", ".", "push", "(", "'gain='", "+", "opts", ".", "gain", ")", ";", "}", "if", "(", "typeof", "opts", ".", "threshold", "!==", "'undefined'", ")", "{", "params", ".", "push", "(", "'threshold='", "+", "opts", ".", "threshold", ")", ";", "}", "if", "(", "params", ".", "length", ")", "{", "transform", "+=", "':'", "+", "params", ".", "join", "(", "','", ")", ";", "}", "return", "this", ".", "append", "(", "transform", ")", ";", "}" ]
Sharpen the image @param {Object} [options] @param {String} [options.preset] Name of a defined preset to use @param {Number} [options.radius=2] Radius of the Gaussian operator in pixels @param {Number} [options.sigma=1] Standard deviation of the Gaussian, in pixels @param {Number} [options.gain=1] Percentage of difference between original and blurred image that is added back into the original @param {Number} [options.threshold=0.05] Threshold in pixels needed to apply the difference gain @return {Imbo.ImageUrl}
[ "Sharpen", "the", "image" ]
809dcc489528dca9d67f49b03b612a99704339d0
https://github.com/imbo/imboclient-js/blob/809dcc489528dca9d67f49b03b612a99704339d0/lib/url/imageurl.js#L390-L420
38,416
imbo/imboclient-js
lib/url/imageurl.js
function(options) { options = options || {}; return this.append([ 'thumbnail:width=' + (options.width || 50), 'height=' + (options.height || 50), 'fit=' + (options.fit || 'outbound') ].join(',')); }
javascript
function(options) { options = options || {}; return this.append([ 'thumbnail:width=' + (options.width || 50), 'height=' + (options.height || 50), 'fit=' + (options.fit || 'outbound') ].join(',')); }
[ "function", "(", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "return", "this", ".", "append", "(", "[", "'thumbnail:width='", "+", "(", "options", ".", "width", "||", "50", ")", ",", "'height='", "+", "(", "options", ".", "height", "||", "50", ")", ",", "'fit='", "+", "(", "options", ".", "fit", "||", "'outbound'", ")", "]", ".", "join", "(", "','", ")", ")", ";", "}" ]
Create a thumbnailed version of the image @param {Object} [options] @param {Number} [options.width=50] Width of the thumbnail @param {Number} [options.height=50] Height of the thumbnail @param {String} [options.fit=outbound] Fit mode: "outbound" or "inset" @return {Imbo.ImageUrl}
[ "Create", "a", "thumbnailed", "version", "of", "the", "image" ]
809dcc489528dca9d67f49b03b612a99704339d0
https://github.com/imbo/imboclient-js/blob/809dcc489528dca9d67f49b03b612a99704339d0/lib/url/imageurl.js#L481-L489
38,417
imbo/imboclient-js
lib/url/imageurl.js
function(options) { options = options || {}; var params = [ 'position=' + (options.position || 'top-left'), 'x=' + toInt(options.x || 0), 'y=' + toInt(options.y || 0) ]; if (options.imageIdentifier) { params.push('img=' + options.imageIdentifier); } if (options.width > 0) { params.push('width=' + toInt(options.width)); } if (options.height > 0) { params.push('height=' + toInt(options.height)); } return this.append('watermark:' + params.join(',')); }
javascript
function(options) { options = options || {}; var params = [ 'position=' + (options.position || 'top-left'), 'x=' + toInt(options.x || 0), 'y=' + toInt(options.y || 0) ]; if (options.imageIdentifier) { params.push('img=' + options.imageIdentifier); } if (options.width > 0) { params.push('width=' + toInt(options.width)); } if (options.height > 0) { params.push('height=' + toInt(options.height)); } return this.append('watermark:' + params.join(',')); }
[ "function", "(", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "var", "params", "=", "[", "'position='", "+", "(", "options", ".", "position", "||", "'top-left'", ")", ",", "'x='", "+", "toInt", "(", "options", ".", "x", "||", "0", ")", ",", "'y='", "+", "toInt", "(", "options", ".", "y", "||", "0", ")", "]", ";", "if", "(", "options", ".", "imageIdentifier", ")", "{", "params", ".", "push", "(", "'img='", "+", "options", ".", "imageIdentifier", ")", ";", "}", "if", "(", "options", ".", "width", ">", "0", ")", "{", "params", ".", "push", "(", "'width='", "+", "toInt", "(", "options", ".", "width", ")", ")", ";", "}", "if", "(", "options", ".", "height", ">", "0", ")", "{", "params", ".", "push", "(", "'height='", "+", "toInt", "(", "options", ".", "height", ")", ")", ";", "}", "return", "this", ".", "append", "(", "'watermark:'", "+", "params", ".", "join", "(", "','", ")", ")", ";", "}" ]
Applies a watermark on top of the original image @param {Object} [options] @param {Number} [options.img] Image identifier of the image to apply as watermark @param {Number} [options.width] Width of the watermark, in pixels @param {Number} [options.height] Height of the watermark, in pixels @param {String} [options.position=top-left] Position of the watermark. Values: "top-left", "top-right", "bottom-left", "bottom-right" and "center" @param {Number} [options.x] Number of pixels in the X-axis the watermark image should be offset from the original position @param {Number} [options.y] Number of pixels in the Y-axis the watermark image should be offset from the original position @return {Imbo.ImageUrl}
[ "Applies", "a", "watermark", "on", "top", "of", "the", "original", "image" ]
809dcc489528dca9d67f49b03b612a99704339d0
https://github.com/imbo/imboclient-js/blob/809dcc489528dca9d67f49b03b612a99704339d0/lib/url/imageurl.js#L524-L546
38,418
imbo/imboclient-js
lib/url/imageurl.js
function() { return new ImageUrl({ transformations: this.transformations.slice(0), baseUrl: this.rootUrl, user: this.user, publicKey: this.publicKey, privateKey: this.privateKey, imageIdentifier: this.imageIdentifier, extension: this.extension, queryString: this.queryString, path: this.path }); }
javascript
function() { return new ImageUrl({ transformations: this.transformations.slice(0), baseUrl: this.rootUrl, user: this.user, publicKey: this.publicKey, privateKey: this.privateKey, imageIdentifier: this.imageIdentifier, extension: this.extension, queryString: this.queryString, path: this.path }); }
[ "function", "(", ")", "{", "return", "new", "ImageUrl", "(", "{", "transformations", ":", "this", ".", "transformations", ".", "slice", "(", "0", ")", ",", "baseUrl", ":", "this", ".", "rootUrl", ",", "user", ":", "this", ".", "user", ",", "publicKey", ":", "this", ".", "publicKey", ",", "privateKey", ":", "this", ".", "privateKey", ",", "imageIdentifier", ":", "this", ".", "imageIdentifier", ",", "extension", ":", "this", ".", "extension", ",", "queryString", ":", "this", ".", "queryString", ",", "path", ":", "this", ".", "path", "}", ")", ";", "}" ]
Clone this ImageUrl instance @return {Imbo.ImageUrl}
[ "Clone", "this", "ImageUrl", "instance" ]
809dcc489528dca9d67f49b03b612a99704339d0
https://github.com/imbo/imboclient-js/blob/809dcc489528dca9d67f49b03b612a99704339d0/lib/url/imageurl.js#L592-L604
38,419
imbo/imboclient-js
lib/url/imageurl.js
function(encode) { var query = this.queryString || '', transformations = this.transformations, transformationKey = encode ? 't%5B%5D=' : 't[]='; if (encode) { transformations = transformations.map(encodeURIComponent); } if (this.transformations.length) { query += query.length ? '&' : ''; query += transformationKey + transformations.join('&' + transformationKey); } return query; }
javascript
function(encode) { var query = this.queryString || '', transformations = this.transformations, transformationKey = encode ? 't%5B%5D=' : 't[]='; if (encode) { transformations = transformations.map(encodeURIComponent); } if (this.transformations.length) { query += query.length ? '&' : ''; query += transformationKey + transformations.join('&' + transformationKey); } return query; }
[ "function", "(", "encode", ")", "{", "var", "query", "=", "this", ".", "queryString", "||", "''", ",", "transformations", "=", "this", ".", "transformations", ",", "transformationKey", "=", "encode", "?", "'t%5B%5D='", ":", "'t[]='", ";", "if", "(", "encode", ")", "{", "transformations", "=", "transformations", ".", "map", "(", "encodeURIComponent", ")", ";", "}", "if", "(", "this", ".", "transformations", ".", "length", ")", "{", "query", "+=", "query", ".", "length", "?", "'&'", ":", "''", ";", "query", "+=", "transformationKey", "+", "transformations", ".", "join", "(", "'&'", "+", "transformationKey", ")", ";", "}", "return", "query", ";", "}" ]
Get the query string with all transformations applied @param {Boolean} [encode=false] @return {String}
[ "Get", "the", "query", "string", "with", "all", "transformations", "applied" ]
809dcc489528dca9d67f49b03b612a99704339d0
https://github.com/imbo/imboclient-js/blob/809dcc489528dca9d67f49b03b612a99704339d0/lib/url/imageurl.js#L650-L665
38,420
rootsdev/gedcomx-js
src/core/Identifiers.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Identifiers)){ return new Identifiers(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Identifiers.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Identifiers)){ return new Identifiers(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Identifiers.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "// Protect against forgetting the new keyword when calling the constructor", "if", "(", "!", "(", "this", "instanceof", "Identifiers", ")", ")", "{", "return", "new", "Identifiers", "(", "json", ")", ";", "}", "// If the given object is already an instance then just return it. DON'T copy it.", "if", "(", "Identifiers", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
Manage the set of identifers for an object. @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#identifier-type|GEDCOM X JSON Spec} @class @extends Base @param {Object} [json]
[ "Manage", "the", "set", "of", "identifers", "for", "an", "object", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/core/Identifiers.js#L13-L26
38,421
blaxk/ixband
dist/ixBand_1.2.js
function ( value ) { if ( this.isObject(value) ) { //$('.touch_area').get(0).constructor.toString() return !!( value && value.nodeType === 1 && value.nodeName ); } else { return /HTML(?:.*)Element/.test( Object.prototype.toString.call(value) ); } }
javascript
function ( value ) { if ( this.isObject(value) ) { //$('.touch_area').get(0).constructor.toString() return !!( value && value.nodeType === 1 && value.nodeName ); } else { return /HTML(?:.*)Element/.test( Object.prototype.toString.call(value) ); } }
[ "function", "(", "value", ")", "{", "if", "(", "this", ".", "isObject", "(", "value", ")", ")", "{", "//$('.touch_area').get(0).constructor.toString()", "return", "!", "!", "(", "value", "&&", "value", ".", "nodeType", "===", "1", "&&", "value", ".", "nodeName", ")", ";", "}", "else", "{", "return", "/", "HTML(?:.*)Element", "/", ".", "test", "(", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "value", ")", ")", ";", "}", "}" ]
Element, HTMLElement, NodeElement check
[ "Element", "HTMLElement", "NodeElement", "check" ]
1f1ab638ea6dd633c31cf3f2bef97d121f63084f
https://github.com/blaxk/ixband/blob/1f1ab638ea6dd633c31cf3f2bef97d121f63084f/dist/ixBand_1.2.js#L507-L514
38,422
blaxk/ixband
dist/ixBand_1.2.js
function ( type ) { if ( /pointerdown/i.test(type) ) { type = 'touchstart'; } else if ( /pointermove/i.test(type) ) { type = 'touchmove'; } else if ( /pointerup/i.test(type) ) { type = 'touchend'; } else if ( /pointercancel/i.test(type) ) { type = 'touchcancel'; } return type; }
javascript
function ( type ) { if ( /pointerdown/i.test(type) ) { type = 'touchstart'; } else if ( /pointermove/i.test(type) ) { type = 'touchmove'; } else if ( /pointerup/i.test(type) ) { type = 'touchend'; } else if ( /pointercancel/i.test(type) ) { type = 'touchcancel'; } return type; }
[ "function", "(", "type", ")", "{", "if", "(", "/", "pointerdown", "/", "i", ".", "test", "(", "type", ")", ")", "{", "type", "=", "'touchstart'", ";", "}", "else", "if", "(", "/", "pointermove", "/", "i", ".", "test", "(", "type", ")", ")", "{", "type", "=", "'touchmove'", ";", "}", "else", "if", "(", "/", "pointerup", "/", "i", ".", "test", "(", "type", ")", ")", "{", "type", "=", "'touchend'", ";", "}", "else", "if", "(", "/", "pointercancel", "/", "i", ".", "test", "(", "type", ")", ")", "{", "type", "=", "'touchcancel'", ";", "}", "return", "type", ";", "}" ]
origin event type to cross event type
[ "origin", "event", "type", "to", "cross", "event", "type" ]
1f1ab638ea6dd633c31cf3f2bef97d121f63084f
https://github.com/blaxk/ixband/blob/1f1ab638ea6dd633c31cf3f2bef97d121f63084f/dist/ixBand_1.2.js#L5790-L5802
38,423
Hypermediaisobar-admin/node-any-db-mssql
index.js
function(anyConfig) { var result = {}; result.userName = anyConfig.user || anyConfig.userName || defaultConfig.userName; result.password = anyConfig.password || defaultConfig.password; result.server = anyConfig.host || anyConfig.server || defaultConfig.host; result.options = anyConfig.options || {}; result.options.database = anyConfig.database || result.options.database || defaultConfig.options.database; if (anyConfig.instanceName || result.options.instanceName) { result.options.instanceName = anyConfig.instanceName || result.options.instanceName; result.options.port = false; } else { result.options.port = anyConfig.port || result.options.port || defaultConfig.options.port; } return result; }
javascript
function(anyConfig) { var result = {}; result.userName = anyConfig.user || anyConfig.userName || defaultConfig.userName; result.password = anyConfig.password || defaultConfig.password; result.server = anyConfig.host || anyConfig.server || defaultConfig.host; result.options = anyConfig.options || {}; result.options.database = anyConfig.database || result.options.database || defaultConfig.options.database; if (anyConfig.instanceName || result.options.instanceName) { result.options.instanceName = anyConfig.instanceName || result.options.instanceName; result.options.port = false; } else { result.options.port = anyConfig.port || result.options.port || defaultConfig.options.port; } return result; }
[ "function", "(", "anyConfig", ")", "{", "var", "result", "=", "{", "}", ";", "result", ".", "userName", "=", "anyConfig", ".", "user", "||", "anyConfig", ".", "userName", "||", "defaultConfig", ".", "userName", ";", "result", ".", "password", "=", "anyConfig", ".", "password", "||", "defaultConfig", ".", "password", ";", "result", ".", "server", "=", "anyConfig", ".", "host", "||", "anyConfig", ".", "server", "||", "defaultConfig", ".", "host", ";", "result", ".", "options", "=", "anyConfig", ".", "options", "||", "{", "}", ";", "result", ".", "options", ".", "database", "=", "anyConfig", ".", "database", "||", "result", ".", "options", ".", "database", "||", "defaultConfig", ".", "options", ".", "database", ";", "if", "(", "anyConfig", ".", "instanceName", "||", "result", ".", "options", ".", "instanceName", ")", "{", "result", ".", "options", ".", "instanceName", "=", "anyConfig", ".", "instanceName", "||", "result", ".", "options", ".", "instanceName", ";", "result", ".", "options", ".", "port", "=", "false", ";", "}", "else", "{", "result", ".", "options", ".", "port", "=", "anyConfig", ".", "port", "||", "result", ".", "options", ".", "port", "||", "defaultConfig", ".", "options", ".", "port", ";", "}", "return", "result", ";", "}" ]
Any DB config. @external any-db~Config @see {@link https://github.com/grncdr/node-any-db-adapter-spec#adaptercreateconnection} Convert config provided by Any DB to the one used by Tedious. @private @param {any-db~Config} anyConfig @return {Tedious~Config}
[ "Any", "DB", "config", "." ]
325922af18554bc5db703034d966d666407671db
https://github.com/Hypermediaisobar-admin/node-any-db-mssql/blob/325922af18554bc5db703034d966d666407671db/index.js#L63-L81
38,424
Hypermediaisobar-admin/node-any-db-mssql
index.js
function(request, parameters) { if (!parameters) { return; } var keys = Object.keys(parameters); var type = false; var value = null; var options = null; for (var i = keys.length - 1; i >= 0; i--) { value = parameters[keys[i]]; options = null; if (value instanceof Object && value.type && value.hasOwnProperty('value')) { if (value.hasOwnProperty('options')) { options = value.options; } type = value.type; value = value.value; } else { type = exports.detectParameterType(value); } if (!(value instanceof Array)) { request.addParameter(keys[i], type, value, options); continue; } } }
javascript
function(request, parameters) { if (!parameters) { return; } var keys = Object.keys(parameters); var type = false; var value = null; var options = null; for (var i = keys.length - 1; i >= 0; i--) { value = parameters[keys[i]]; options = null; if (value instanceof Object && value.type && value.hasOwnProperty('value')) { if (value.hasOwnProperty('options')) { options = value.options; } type = value.type; value = value.value; } else { type = exports.detectParameterType(value); } if (!(value instanceof Array)) { request.addParameter(keys[i], type, value, options); continue; } } }
[ "function", "(", "request", ",", "parameters", ")", "{", "if", "(", "!", "parameters", ")", "{", "return", ";", "}", "var", "keys", "=", "Object", ".", "keys", "(", "parameters", ")", ";", "var", "type", "=", "false", ";", "var", "value", "=", "null", ";", "var", "options", "=", "null", ";", "for", "(", "var", "i", "=", "keys", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "value", "=", "parameters", "[", "keys", "[", "i", "]", "]", ";", "options", "=", "null", ";", "if", "(", "value", "instanceof", "Object", "&&", "value", ".", "type", "&&", "value", ".", "hasOwnProperty", "(", "'value'", ")", ")", "{", "if", "(", "value", ".", "hasOwnProperty", "(", "'options'", ")", ")", "{", "options", "=", "value", ".", "options", ";", "}", "type", "=", "value", ".", "type", ";", "value", "=", "value", ".", "value", ";", "}", "else", "{", "type", "=", "exports", ".", "detectParameterType", "(", "value", ")", ";", "}", "if", "(", "!", "(", "value", "instanceof", "Array", ")", ")", "{", "request", ".", "addParameter", "(", "keys", "[", "i", "]", ",", "type", ",", "value", ",", "options", ")", ";", "continue", ";", "}", "}", "}" ]
Tedious' Request object. @external Tedious~Request @see {@link http://pekim.github.io/tedious/api-request.html} Add parameters to the request. @private @param {Tedious~Request} request @param {namedParameters|positionalParameters} [parameters]
[ "Tedious", "Request", "object", "." ]
325922af18554bc5db703034d966d666407671db
https://github.com/Hypermediaisobar-admin/node-any-db-mssql/blob/325922af18554bc5db703034d966d666407671db/index.js#L292-L321
38,425
Hypermediaisobar-admin/node-any-db-mssql
index.js
function(target) { target.adapter = exports; target.query = execQuery.bind(target); // Tedious cannot execute more than one query at a time, so we have to // implement a queue for queries, just in case someone tries to set // multiple queries in a row (like node-any-db-adapter-spec tests do). target._queue = []; target._waitingForQueryToFinish = false; var _execNextInQueue = function(){ if (target._waitingForQueryToFinish) { return; } var query = target._queue.shift(); if (query) { target._waitingForQueryToFinish = true; target.emit('query', query); query.once('close', function(){ target._waitingForQueryToFinish = false; target.execNextInQueue(); }); target.execSql(query._request); } }; target.execNextInQueue = function(query){ if (query) { target._queue.push(query); } if (target._isConnected) { process.nextTick(_execNextInQueue); } }; return target; }
javascript
function(target) { target.adapter = exports; target.query = execQuery.bind(target); // Tedious cannot execute more than one query at a time, so we have to // implement a queue for queries, just in case someone tries to set // multiple queries in a row (like node-any-db-adapter-spec tests do). target._queue = []; target._waitingForQueryToFinish = false; var _execNextInQueue = function(){ if (target._waitingForQueryToFinish) { return; } var query = target._queue.shift(); if (query) { target._waitingForQueryToFinish = true; target.emit('query', query); query.once('close', function(){ target._waitingForQueryToFinish = false; target.execNextInQueue(); }); target.execSql(query._request); } }; target.execNextInQueue = function(query){ if (query) { target._queue.push(query); } if (target._isConnected) { process.nextTick(_execNextInQueue); } }; return target; }
[ "function", "(", "target", ")", "{", "target", ".", "adapter", "=", "exports", ";", "target", ".", "query", "=", "execQuery", ".", "bind", "(", "target", ")", ";", "// Tedious cannot execute more than one query at a time, so we have to", "// implement a queue for queries, just in case someone tries to set", "// multiple queries in a row (like node-any-db-adapter-spec tests do).", "target", ".", "_queue", "=", "[", "]", ";", "target", ".", "_waitingForQueryToFinish", "=", "false", ";", "var", "_execNextInQueue", "=", "function", "(", ")", "{", "if", "(", "target", ".", "_waitingForQueryToFinish", ")", "{", "return", ";", "}", "var", "query", "=", "target", ".", "_queue", ".", "shift", "(", ")", ";", "if", "(", "query", ")", "{", "target", ".", "_waitingForQueryToFinish", "=", "true", ";", "target", ".", "emit", "(", "'query'", ",", "query", ")", ";", "query", ".", "once", "(", "'close'", ",", "function", "(", ")", "{", "target", ".", "_waitingForQueryToFinish", "=", "false", ";", "target", ".", "execNextInQueue", "(", ")", ";", "}", ")", ";", "target", ".", "execSql", "(", "query", ".", "_request", ")", ";", "}", "}", ";", "target", ".", "execNextInQueue", "=", "function", "(", "query", ")", "{", "if", "(", "query", ")", "{", "target", ".", "_queue", ".", "push", "(", "query", ")", ";", "}", "if", "(", "target", ".", "_isConnected", ")", "{", "process", ".", "nextTick", "(", "_execNextInQueue", ")", ";", "}", "}", ";", "return", "target", ";", "}" ]
Inject Queryable API into object. @private @param {Object} target @return {any-db~Queryable} target object with Queryable API injected
[ "Inject", "Queryable", "API", "into", "object", "." ]
325922af18554bc5db703034d966d666407671db
https://github.com/Hypermediaisobar-admin/node-any-db-mssql/blob/325922af18554bc5db703034d966d666407671db/index.js#L535-L574
38,426
AckerApple/ack-node
js/modules/router.js
htmlCloseError
function htmlCloseError(options) { options = options || {}; options.debugLocalNetwork = options.debugLocalNetwork == null ? true : options.debugLocalNetwork; return function (err, req, res, next) { var msg = err.message || err.code; res.statusCode = err.status || err.statusCode || 500; res.statusMessage = msg; res.setHeader('Content-Type', 'text/html'); if (msg) res.setHeader('message', cleanStatusMessage(msg)); var output = '<h3>' + msg + '</h3>'; //message meat var isDebug = options.debug || (options.debugLocalNetwork && ack.reqres(req, res).req.isLocalNetwork()); var dump = null; if (isDebug) { dump = { Error: err }; var jErr = ack.error(err); if (err.stack) { output += jErr.getFirstTrace(); dump.stack = jErr.getStackArray(); } } else { dump = err; } output += ack(dump).dump('html'); res.end(output); }; }
javascript
function htmlCloseError(options) { options = options || {}; options.debugLocalNetwork = options.debugLocalNetwork == null ? true : options.debugLocalNetwork; return function (err, req, res, next) { var msg = err.message || err.code; res.statusCode = err.status || err.statusCode || 500; res.statusMessage = msg; res.setHeader('Content-Type', 'text/html'); if (msg) res.setHeader('message', cleanStatusMessage(msg)); var output = '<h3>' + msg + '</h3>'; //message meat var isDebug = options.debug || (options.debugLocalNetwork && ack.reqres(req, res).req.isLocalNetwork()); var dump = null; if (isDebug) { dump = { Error: err }; var jErr = ack.error(err); if (err.stack) { output += jErr.getFirstTrace(); dump.stack = jErr.getStackArray(); } } else { dump = err; } output += ack(dump).dump('html'); res.end(output); }; }
[ "function", "htmlCloseError", "(", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "options", ".", "debugLocalNetwork", "=", "options", ".", "debugLocalNetwork", "==", "null", "?", "true", ":", "options", ".", "debugLocalNetwork", ";", "return", "function", "(", "err", ",", "req", ",", "res", ",", "next", ")", "{", "var", "msg", "=", "err", ".", "message", "||", "err", ".", "code", ";", "res", ".", "statusCode", "=", "err", ".", "status", "||", "err", ".", "statusCode", "||", "500", ";", "res", ".", "statusMessage", "=", "msg", ";", "res", ".", "setHeader", "(", "'Content-Type'", ",", "'text/html'", ")", ";", "if", "(", "msg", ")", "res", ".", "setHeader", "(", "'message'", ",", "cleanStatusMessage", "(", "msg", ")", ")", ";", "var", "output", "=", "'<h3>'", "+", "msg", "+", "'</h3>'", ";", "//message meat", "var", "isDebug", "=", "options", ".", "debug", "||", "(", "options", ".", "debugLocalNetwork", "&&", "ack", ".", "reqres", "(", "req", ",", "res", ")", ".", "req", ".", "isLocalNetwork", "(", ")", ")", ";", "var", "dump", "=", "null", ";", "if", "(", "isDebug", ")", "{", "dump", "=", "{", "Error", ":", "err", "}", ";", "var", "jErr", "=", "ack", ".", "error", "(", "err", ")", ";", "if", "(", "err", ".", "stack", ")", "{", "output", "+=", "jErr", ".", "getFirstTrace", "(", ")", ";", "dump", ".", "stack", "=", "jErr", ".", "getStackArray", "(", ")", ";", "}", "}", "else", "{", "dump", "=", "err", ";", "}", "output", "+=", "ack", "(", "dump", ")", ".", "dump", "(", "'html'", ")", ";", "res", ".", "end", "(", "output", ")", ";", "}", ";", "}" ]
Returns universal error handler middleware @options {debug:true/false, debugLocalNetwork:true}
[ "Returns", "universal", "error", "handler", "middleware" ]
c123d3fcbdd0195630fece6dc9ddee8910c9e115
https://github.com/AckerApple/ack-node/blob/c123d3fcbdd0195630fece6dc9ddee8910c9e115/js/modules/router.js#L572-L599
38,427
AckerApple/ack-node
js/modules/router.js
jsonCloseError
function jsonCloseError(options) { if (options === void 0) { options = {}; } options.debugLocalNetwork = options.debugLocalNetwork == null ? true : options.debugLocalNetwork; return function (err, req, res, next) { try { err = toError(err); var statusMessage = err.message || err.code; var statusCode = err.status || err.statusCode || 500; statusMessage = cleanStatusMessage(statusMessage); statusCode = statusCode.toString().replace(/[^0-9]/g, ''); res.statusMessage = statusMessage; res.statusCode = statusCode; var rtn = { error: { message: statusMessage, code: statusCode, "debug": { "stack": err.stack } } }; var isDebug = err.stack && (options.debug || (options.debugLocalNetwork && ack.reqres(req, res).req.isLocalNetwork())); if (isDebug) { rtn.error["stack"] = err.stack; //debug requests will get stack traces } /* if(res.json){ res.json(rtn) }else{ var output = JSON.stringify(rtn) res.setHeader('message', statusMessage) res.setHeader('Content-Type','application/json') res.setHeader('Content-Length', output.length.toString()) res.end( output ); } */ var output = JSON.stringify(rtn); res.setHeader('message', statusMessage); res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Length', output.length.toString()); res.end(output); } catch (e) { console.error('ack/modules/reqres/res.js jsonCloseError failed hard'); console.error(e); console.error('------ original error ------', statusMessage); console.error(err); if (next) { next(err); } else { throw err; } } }; }
javascript
function jsonCloseError(options) { if (options === void 0) { options = {}; } options.debugLocalNetwork = options.debugLocalNetwork == null ? true : options.debugLocalNetwork; return function (err, req, res, next) { try { err = toError(err); var statusMessage = err.message || err.code; var statusCode = err.status || err.statusCode || 500; statusMessage = cleanStatusMessage(statusMessage); statusCode = statusCode.toString().replace(/[^0-9]/g, ''); res.statusMessage = statusMessage; res.statusCode = statusCode; var rtn = { error: { message: statusMessage, code: statusCode, "debug": { "stack": err.stack } } }; var isDebug = err.stack && (options.debug || (options.debugLocalNetwork && ack.reqres(req, res).req.isLocalNetwork())); if (isDebug) { rtn.error["stack"] = err.stack; //debug requests will get stack traces } /* if(res.json){ res.json(rtn) }else{ var output = JSON.stringify(rtn) res.setHeader('message', statusMessage) res.setHeader('Content-Type','application/json') res.setHeader('Content-Length', output.length.toString()) res.end( output ); } */ var output = JSON.stringify(rtn); res.setHeader('message', statusMessage); res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Length', output.length.toString()); res.end(output); } catch (e) { console.error('ack/modules/reqres/res.js jsonCloseError failed hard'); console.error(e); console.error('------ original error ------', statusMessage); console.error(err); if (next) { next(err); } else { throw err; } } }; }
[ "function", "jsonCloseError", "(", "options", ")", "{", "if", "(", "options", "===", "void", "0", ")", "{", "options", "=", "{", "}", ";", "}", "options", ".", "debugLocalNetwork", "=", "options", ".", "debugLocalNetwork", "==", "null", "?", "true", ":", "options", ".", "debugLocalNetwork", ";", "return", "function", "(", "err", ",", "req", ",", "res", ",", "next", ")", "{", "try", "{", "err", "=", "toError", "(", "err", ")", ";", "var", "statusMessage", "=", "err", ".", "message", "||", "err", ".", "code", ";", "var", "statusCode", "=", "err", ".", "status", "||", "err", ".", "statusCode", "||", "500", ";", "statusMessage", "=", "cleanStatusMessage", "(", "statusMessage", ")", ";", "statusCode", "=", "statusCode", ".", "toString", "(", ")", ".", "replace", "(", "/", "[^0-9]", "/", "g", ",", "''", ")", ";", "res", ".", "statusMessage", "=", "statusMessage", ";", "res", ".", "statusCode", "=", "statusCode", ";", "var", "rtn", "=", "{", "error", ":", "{", "message", ":", "statusMessage", ",", "code", ":", "statusCode", ",", "\"debug\"", ":", "{", "\"stack\"", ":", "err", ".", "stack", "}", "}", "}", ";", "var", "isDebug", "=", "err", ".", "stack", "&&", "(", "options", ".", "debug", "||", "(", "options", ".", "debugLocalNetwork", "&&", "ack", ".", "reqres", "(", "req", ",", "res", ")", ".", "req", ".", "isLocalNetwork", "(", ")", ")", ")", ";", "if", "(", "isDebug", ")", "{", "rtn", ".", "error", "[", "\"stack\"", "]", "=", "err", ".", "stack", ";", "//debug requests will get stack traces", "}", "/*\n if(res.json){\n res.json(rtn)\n }else{\n var output = JSON.stringify(rtn)\n res.setHeader('message', statusMessage)\n res.setHeader('Content-Type','application/json')\n res.setHeader('Content-Length', output.length.toString())\n res.end( output );\n }\n */", "var", "output", "=", "JSON", ".", "stringify", "(", "rtn", ")", ";", "res", ".", "setHeader", "(", "'message'", ",", "statusMessage", ")", ";", "res", ".", "setHeader", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "res", ".", "setHeader", "(", "'Content-Length'", ",", "output", ".", "length", ".", "toString", "(", ")", ")", ";", "res", ".", "end", "(", "output", ")", ";", "}", "catch", "(", "e", ")", "{", "console", ".", "error", "(", "'ack/modules/reqres/res.js jsonCloseError failed hard'", ")", ";", "console", ".", "error", "(", "e", ")", ";", "console", ".", "error", "(", "'------ original error ------'", ",", "statusMessage", ")", ";", "console", ".", "error", "(", "err", ")", ";", "if", "(", "next", ")", "{", "next", "(", "err", ")", ";", "}", "else", "{", "throw", "err", ";", "}", "}", "}", ";", "}" ]
returns middleware that handles errors with JSON style details @options {debug:true/false, debugLocalNetwork:true}
[ "returns", "middleware", "that", "handles", "errors", "with", "JSON", "style", "details" ]
c123d3fcbdd0195630fece6dc9ddee8910c9e115
https://github.com/AckerApple/ack-node/blob/c123d3fcbdd0195630fece6dc9ddee8910c9e115/js/modules/router.js#L615-L670
38,428
rootsdev/gedcomx-js
src/core/Attribution.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Attribution)){ return new Attribution(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Attribution.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Attribution)){ return new Attribution(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Attribution.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "// Protect against forgetting the new keyword when calling the constructor", "if", "(", "!", "(", "this", "instanceof", "Attribution", ")", ")", "{", "return", "new", "Attribution", "(", "json", ")", ";", "}", "// If the given object is already an instance then just return it. DON'T copy it.", "if", "(", "Attribution", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
Define who is contributing information, when they contributed it, and why they are making the contribution. @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#attribution|GEDCOM X JSON Spec} @class @extends ExtensibleData @param {Object} [json]
[ "Define", "who", "is", "contributing", "information", "when", "they", "contributed", "it", "and", "why", "they", "are", "making", "the", "contribution", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/core/Attribution.js#L14-L27
38,429
ghepesdoru/babel-plugin-module-alias-rn
src/index.js
adaptModulePath
function adaptModulePath(modulePath, state) { // const fileName = state.file.opts.filename; const options = getStateOptions(state); const filesMap = createFilesMap(options); const rootPath = getRootPath(options); let module = determineContext(modulePath, options); // Do not generate infinite cyrcular references on empty nodes if (!module.file) { return null; } // Safeguard against circular calls if (lastIn === lastOut) { return null; } // Remove relative path prefix before replace const absoluteModule = path.isAbsolute(module.file); // Try to replace aliased module let found = false; let constantModulePart; filesMap.keys.filter((k) => { const d = filesMap.contents[k]; let idx = module.file.search(d.regexp); if (!found && idx > -1) { // throw `Found ${d} in ${module.file}` // constantModulePart = module.file.slice(0, idx) || './'; constantModulePart = './'; if (module.file[idx] === '/') { idx += 1; } const value = d.value[0] === '.' && idx > 0 ? d.value.slice(2) : d.value; // const value = d.value; // Replace the alias with it's path and continue module.file = `${module.file.slice(0, idx) || ''}${value}${module.file.slice(idx + d.expose.length) || ''}`; found = true; // Revaluate npm and react flags based on the new mapping module = determineContext(module.file, options); return true; } return false; }); // Leave NPM modules as resolved, do not remap and ignore wrongfully formatted strings of form require('npm:') if (module.npm) { return module.file || null; } // Do not touch direct requires to npm modules (non annotated) if (module.file.indexOf('./') !== 0 && module.file.indexOf('/') !== 0) { return null; } // Check if any substitution took place if (found) { // Module alias substituted if (!path.isAbsolute(module.file)) { if (!absoluteModule && module.file[0] !== '.') { // Add the relative notation back module.file = `./${module.file}`; } } } // Do not break node_modules required by name if (!found && module.file[0] !== '.') { if (reactOsFileInfer(options)) { const aux2 = mapForReact(module.file); if (aux2 !== module.file) { return aux2; } } return null; } // Enforce absolute paths on absolute mode if (rootPath) { if (!path.isAbsolute(module.file)) { module.file = path.join(rootPath, module.file); if (reactOsFileInfer(options)) { return mapForReact(module.file); } return module.file; } // After the node is replaced the visitor will be called again. // Without this condition these functions will generate a circular loop. return null; } // throw `Gets here: ${JSON.stringify(module.file)}`; // Do not bother with relative paths that are not aliased if (!found) { return null; } let moduleMapped = mapToRelative(module.file, constantModulePart, options); if (moduleMapped.indexOf('./') !== 0) { moduleMapped = `./${moduleMapped}`; } // throw JSON.stringify({ // moduleMapped, modulePath, module, constantModulePart // }, null, 2); return moduleMapped !== modulePath ? moduleMapped : null; }
javascript
function adaptModulePath(modulePath, state) { // const fileName = state.file.opts.filename; const options = getStateOptions(state); const filesMap = createFilesMap(options); const rootPath = getRootPath(options); let module = determineContext(modulePath, options); // Do not generate infinite cyrcular references on empty nodes if (!module.file) { return null; } // Safeguard against circular calls if (lastIn === lastOut) { return null; } // Remove relative path prefix before replace const absoluteModule = path.isAbsolute(module.file); // Try to replace aliased module let found = false; let constantModulePart; filesMap.keys.filter((k) => { const d = filesMap.contents[k]; let idx = module.file.search(d.regexp); if (!found && idx > -1) { // throw `Found ${d} in ${module.file}` // constantModulePart = module.file.slice(0, idx) || './'; constantModulePart = './'; if (module.file[idx] === '/') { idx += 1; } const value = d.value[0] === '.' && idx > 0 ? d.value.slice(2) : d.value; // const value = d.value; // Replace the alias with it's path and continue module.file = `${module.file.slice(0, idx) || ''}${value}${module.file.slice(idx + d.expose.length) || ''}`; found = true; // Revaluate npm and react flags based on the new mapping module = determineContext(module.file, options); return true; } return false; }); // Leave NPM modules as resolved, do not remap and ignore wrongfully formatted strings of form require('npm:') if (module.npm) { return module.file || null; } // Do not touch direct requires to npm modules (non annotated) if (module.file.indexOf('./') !== 0 && module.file.indexOf('/') !== 0) { return null; } // Check if any substitution took place if (found) { // Module alias substituted if (!path.isAbsolute(module.file)) { if (!absoluteModule && module.file[0] !== '.') { // Add the relative notation back module.file = `./${module.file}`; } } } // Do not break node_modules required by name if (!found && module.file[0] !== '.') { if (reactOsFileInfer(options)) { const aux2 = mapForReact(module.file); if (aux2 !== module.file) { return aux2; } } return null; } // Enforce absolute paths on absolute mode if (rootPath) { if (!path.isAbsolute(module.file)) { module.file = path.join(rootPath, module.file); if (reactOsFileInfer(options)) { return mapForReact(module.file); } return module.file; } // After the node is replaced the visitor will be called again. // Without this condition these functions will generate a circular loop. return null; } // throw `Gets here: ${JSON.stringify(module.file)}`; // Do not bother with relative paths that are not aliased if (!found) { return null; } let moduleMapped = mapToRelative(module.file, constantModulePart, options); if (moduleMapped.indexOf('./') !== 0) { moduleMapped = `./${moduleMapped}`; } // throw JSON.stringify({ // moduleMapped, modulePath, module, constantModulePart // }, null, 2); return moduleMapped !== modulePath ? moduleMapped : null; }
[ "function", "adaptModulePath", "(", "modulePath", ",", "state", ")", "{", "// const fileName = state.file.opts.filename;", "const", "options", "=", "getStateOptions", "(", "state", ")", ";", "const", "filesMap", "=", "createFilesMap", "(", "options", ")", ";", "const", "rootPath", "=", "getRootPath", "(", "options", ")", ";", "let", "module", "=", "determineContext", "(", "modulePath", ",", "options", ")", ";", "// Do not generate infinite cyrcular references on empty nodes", "if", "(", "!", "module", ".", "file", ")", "{", "return", "null", ";", "}", "// Safeguard against circular calls", "if", "(", "lastIn", "===", "lastOut", ")", "{", "return", "null", ";", "}", "// Remove relative path prefix before replace", "const", "absoluteModule", "=", "path", ".", "isAbsolute", "(", "module", ".", "file", ")", ";", "// Try to replace aliased module", "let", "found", "=", "false", ";", "let", "constantModulePart", ";", "filesMap", ".", "keys", ".", "filter", "(", "(", "k", ")", "=>", "{", "const", "d", "=", "filesMap", ".", "contents", "[", "k", "]", ";", "let", "idx", "=", "module", ".", "file", ".", "search", "(", "d", ".", "regexp", ")", ";", "if", "(", "!", "found", "&&", "idx", ">", "-", "1", ")", "{", "// throw `Found ${d} in ${module.file}`", "// constantModulePart = module.file.slice(0, idx) || './';", "constantModulePart", "=", "'./'", ";", "if", "(", "module", ".", "file", "[", "idx", "]", "===", "'/'", ")", "{", "idx", "+=", "1", ";", "}", "const", "value", "=", "d", ".", "value", "[", "0", "]", "===", "'.'", "&&", "idx", ">", "0", "?", "d", ".", "value", ".", "slice", "(", "2", ")", ":", "d", ".", "value", ";", "// const value = d.value;", "// Replace the alias with it's path and continue", "module", ".", "file", "=", "`", "${", "module", ".", "file", ".", "slice", "(", "0", ",", "idx", ")", "||", "''", "}", "${", "value", "}", "${", "module", ".", "file", ".", "slice", "(", "idx", "+", "d", ".", "expose", ".", "length", ")", "||", "''", "}", "`", ";", "found", "=", "true", ";", "// Revaluate npm and react flags based on the new mapping", "module", "=", "determineContext", "(", "module", ".", "file", ",", "options", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", ")", ";", "// Leave NPM modules as resolved, do not remap and ignore wrongfully formatted strings of form require('npm:')", "if", "(", "module", ".", "npm", ")", "{", "return", "module", ".", "file", "||", "null", ";", "}", "// Do not touch direct requires to npm modules (non annotated)", "if", "(", "module", ".", "file", ".", "indexOf", "(", "'./'", ")", "!==", "0", "&&", "module", ".", "file", ".", "indexOf", "(", "'/'", ")", "!==", "0", ")", "{", "return", "null", ";", "}", "// Check if any substitution took place", "if", "(", "found", ")", "{", "// Module alias substituted", "if", "(", "!", "path", ".", "isAbsolute", "(", "module", ".", "file", ")", ")", "{", "if", "(", "!", "absoluteModule", "&&", "module", ".", "file", "[", "0", "]", "!==", "'.'", ")", "{", "// Add the relative notation back", "module", ".", "file", "=", "`", "${", "module", ".", "file", "}", "`", ";", "}", "}", "}", "// Do not break node_modules required by name", "if", "(", "!", "found", "&&", "module", ".", "file", "[", "0", "]", "!==", "'.'", ")", "{", "if", "(", "reactOsFileInfer", "(", "options", ")", ")", "{", "const", "aux2", "=", "mapForReact", "(", "module", ".", "file", ")", ";", "if", "(", "aux2", "!==", "module", ".", "file", ")", "{", "return", "aux2", ";", "}", "}", "return", "null", ";", "}", "// Enforce absolute paths on absolute mode", "if", "(", "rootPath", ")", "{", "if", "(", "!", "path", ".", "isAbsolute", "(", "module", ".", "file", ")", ")", "{", "module", ".", "file", "=", "path", ".", "join", "(", "rootPath", ",", "module", ".", "file", ")", ";", "if", "(", "reactOsFileInfer", "(", "options", ")", ")", "{", "return", "mapForReact", "(", "module", ".", "file", ")", ";", "}", "return", "module", ".", "file", ";", "}", "// After the node is replaced the visitor will be called again.", "// Without this condition these functions will generate a circular loop.", "return", "null", ";", "}", "// throw `Gets here: ${JSON.stringify(module.file)}`;", "// Do not bother with relative paths that are not aliased", "if", "(", "!", "found", ")", "{", "return", "null", ";", "}", "let", "moduleMapped", "=", "mapToRelative", "(", "module", ".", "file", ",", "constantModulePart", ",", "options", ")", ";", "if", "(", "moduleMapped", ".", "indexOf", "(", "'./'", ")", "!==", "0", ")", "{", "moduleMapped", "=", "`", "${", "moduleMapped", "}", "`", ";", "}", "// throw JSON.stringify({", "// moduleMapped, modulePath, module, constantModulePart", "// }, null, 2);", "return", "moduleMapped", "!==", "modulePath", "?", "moduleMapped", ":", "null", ";", "}" ]
Adapts a module path to the context of caller
[ "Adapts", "a", "module", "path", "to", "the", "context", "of", "caller" ]
db516c8623c3f598237fab07d164126386140186
https://github.com/ghepesdoru/babel-plugin-module-alias-rn/blob/db516c8623c3f598237fab07d164126386140186/src/index.js#L201-L322
38,430
rootsdev/gedcomx-js
src/core/Conclusion.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Conclusion)){ return new Conclusion(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Conclusion.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Conclusion)){ return new Conclusion(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Conclusion.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "// Protect against forgetting the new keyword when calling the constructor", "if", "(", "!", "(", "this", "instanceof", "Conclusion", ")", ")", "{", "return", "new", "Conclusion", "(", "json", ")", ";", "}", "// If the given object is already an instance then just return it. DON'T copy it.", "if", "(", "Conclusion", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
An abstract concept for a basic genealogical data item. @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#conclusion|GEDCOM X JSON Spec} @class @extends ExtensibleData @param {Object} [json]
[ "An", "abstract", "concept", "for", "a", "basic", "genealogical", "data", "item", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/core/Conclusion.js#L13-L26
38,431
rootsdev/gedcomx-js
src/core/EventRole.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof EventRole)){ return new EventRole(json); } // If the given object is already an instance then just return it. DON'T copy it. if(GedcomX.Conclusion.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof EventRole)){ return new EventRole(json); } // If the given object is already an instance then just return it. DON'T copy it. if(GedcomX.Conclusion.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "// Protect against forgetting the new keyword when calling the constructor", "if", "(", "!", "(", "this", "instanceof", "EventRole", ")", ")", "{", "return", "new", "EventRole", "(", "json", ")", ";", "}", "// If the given object is already an instance then just return it. DON'T copy it.", "if", "(", "GedcomX", ".", "Conclusion", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
A role that a specific person plays in an event. @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#conclusion-event-role|GEDCOM X JSON Spec} @class @extends Conclusion @param {Object} [json]
[ "A", "role", "that", "a", "specific", "person", "plays", "in", "an", "event", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/core/EventRole.js#L13-L26
38,432
Ubudu/uBeacon-uart-lib
node/uBeaconUARTController.js
function(finishedCallback){ self.getUARTProtocolVersion(function(data,error){ self.deviceData.uartProtocolVersion = data; finishedCallback(error); }); }
javascript
function(finishedCallback){ self.getUARTProtocolVersion(function(data,error){ self.deviceData.uartProtocolVersion = data; finishedCallback(error); }); }
[ "function", "(", "finishedCallback", ")", "{", "self", ".", "getUARTProtocolVersion", "(", "function", "(", "data", ",", "error", ")", "{", "self", ".", "deviceData", ".", "uartProtocolVersion", "=", "data", ";", "finishedCallback", "(", "error", ")", ";", "}", ")", ";", "}" ]
Get uart protocol version
[ "Get", "uart", "protocol", "version" ]
a7436f3491f61ffabb34e2bc3b2441cc048f5dfa
https://github.com/Ubudu/uBeacon-uart-lib/blob/a7436f3491f61ffabb34e2bc3b2441cc048f5dfa/node/uBeaconUARTController.js#L207-L212
38,433
Ubudu/uBeacon-uart-lib
node/uBeaconUARTController.js
function(finishedCallback){ self.getHardwareModel(function(data,error){ self.deviceData.hardwareModel = data; finishedCallback(error); }); }
javascript
function(finishedCallback){ self.getHardwareModel(function(data,error){ self.deviceData.hardwareModel = data; finishedCallback(error); }); }
[ "function", "(", "finishedCallback", ")", "{", "self", ".", "getHardwareModel", "(", "function", "(", "data", ",", "error", ")", "{", "self", ".", "deviceData", ".", "hardwareModel", "=", "data", ";", "finishedCallback", "(", "error", ")", ";", "}", ")", ";", "}" ]
Get hardware model
[ "Get", "hardware", "model" ]
a7436f3491f61ffabb34e2bc3b2441cc048f5dfa
https://github.com/Ubudu/uBeacon-uart-lib/blob/a7436f3491f61ffabb34e2bc3b2441cc048f5dfa/node/uBeaconUARTController.js#L214-L219
38,434
Ubudu/uBeacon-uart-lib
node/uBeaconUARTController.js
function(finishedCallback){ self.getHardwareVersion(function(data,error){ self.deviceData.hardwareVersion = data; finishedCallback(error); }); }
javascript
function(finishedCallback){ self.getHardwareVersion(function(data,error){ self.deviceData.hardwareVersion = data; finishedCallback(error); }); }
[ "function", "(", "finishedCallback", ")", "{", "self", ".", "getHardwareVersion", "(", "function", "(", "data", ",", "error", ")", "{", "self", ".", "deviceData", ".", "hardwareVersion", "=", "data", ";", "finishedCallback", "(", "error", ")", ";", "}", ")", ";", "}" ]
Get hardware version
[ "Get", "hardware", "version" ]
a7436f3491f61ffabb34e2bc3b2441cc048f5dfa
https://github.com/Ubudu/uBeacon-uart-lib/blob/a7436f3491f61ffabb34e2bc3b2441cc048f5dfa/node/uBeaconUARTController.js#L221-L226
38,435
Ubudu/uBeacon-uart-lib
node/uBeaconUARTController.js
function(finishedCallback){ self.getFirmwareVersion(function(data,error){ self.deviceData.firmwareVersion = data; finishedCallback(error); }); }
javascript
function(finishedCallback){ self.getFirmwareVersion(function(data,error){ self.deviceData.firmwareVersion = data; finishedCallback(error); }); }
[ "function", "(", "finishedCallback", ")", "{", "self", ".", "getFirmwareVersion", "(", "function", "(", "data", ",", "error", ")", "{", "self", ".", "deviceData", ".", "firmwareVersion", "=", "data", ";", "finishedCallback", "(", "error", ")", ";", "}", ")", ";", "}" ]
Get firmware version
[ "Get", "firmware", "version" ]
a7436f3491f61ffabb34e2bc3b2441cc048f5dfa
https://github.com/Ubudu/uBeacon-uart-lib/blob/a7436f3491f61ffabb34e2bc3b2441cc048f5dfa/node/uBeaconUARTController.js#L228-L233
38,436
intel/grunt-zipup
tasks/grunt-zipup.js
function (path) { if (fs.existsSync(path) && fs.statSync(path).isDirectory()) { return true; } return false; }
javascript
function (path) { if (fs.existsSync(path) && fs.statSync(path).isDirectory()) { return true; } return false; }
[ "function", "(", "path", ")", "{", "if", "(", "fs", ".", "existsSync", "(", "path", ")", "&&", "fs", ".", "statSync", "(", "path", ")", ".", "isDirectory", "(", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
returns true if path exists and is a directory
[ "returns", "true", "if", "path", "exists", "and", "is", "a", "directory" ]
872e47cab6d111e7a61c69a042927fc6ffea0b79
https://github.com/intel/grunt-zipup/blob/872e47cab6d111e7a61c69a042927fc6ffea0b79/tasks/grunt-zipup.js#L45-L50
38,437
stylecow/stylecow-core
lib/tasks.js
needFix
function needFix (stylecowSupport, task, method) { const taskSupport = task[method]; if (!taskSupport || !stylecowSupport) { return true; } for (let browser in taskSupport) { if (stylecowSupport[browser] === false) { continue; } if (method === 'forBrowsersLowerThan' && (taskSupport[browser] === false || stylecowSupport[browser] < taskSupport[browser])) { return true; } if (method === 'forBrowsersUpperOrEqualTo') { if (taskSupport[browser] === false) { return false; } if (stylecowSupport[browser] >= taskSupport[browser]) { return true; } } } return false; }
javascript
function needFix (stylecowSupport, task, method) { const taskSupport = task[method]; if (!taskSupport || !stylecowSupport) { return true; } for (let browser in taskSupport) { if (stylecowSupport[browser] === false) { continue; } if (method === 'forBrowsersLowerThan' && (taskSupport[browser] === false || stylecowSupport[browser] < taskSupport[browser])) { return true; } if (method === 'forBrowsersUpperOrEqualTo') { if (taskSupport[browser] === false) { return false; } if (stylecowSupport[browser] >= taskSupport[browser]) { return true; } } } return false; }
[ "function", "needFix", "(", "stylecowSupport", ",", "task", ",", "method", ")", "{", "const", "taskSupport", "=", "task", "[", "method", "]", ";", "if", "(", "!", "taskSupport", "||", "!", "stylecowSupport", ")", "{", "return", "true", ";", "}", "for", "(", "let", "browser", "in", "taskSupport", ")", "{", "if", "(", "stylecowSupport", "[", "browser", "]", "===", "false", ")", "{", "continue", ";", "}", "if", "(", "method", "===", "'forBrowsersLowerThan'", "&&", "(", "taskSupport", "[", "browser", "]", "===", "false", "||", "stylecowSupport", "[", "browser", "]", "<", "taskSupport", "[", "browser", "]", ")", ")", "{", "return", "true", ";", "}", "if", "(", "method", "===", "'forBrowsersUpperOrEqualTo'", ")", "{", "if", "(", "taskSupport", "[", "browser", "]", "===", "false", ")", "{", "return", "false", ";", "}", "if", "(", "stylecowSupport", "[", "browser", "]", ">=", "taskSupport", "[", "browser", "]", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
check the browser support of a task
[ "check", "the", "browser", "support", "of", "a", "task" ]
8c22ec4cff21b10966d1e90fe870f037a8635976
https://github.com/stylecow/stylecow-core/blob/8c22ec4cff21b10966d1e90fe870f037a8635976/lib/tasks.js#L117-L145
38,438
rootsdev/gedcomx-js
src/atom/AtomSource.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof AtomSource)){ return new AtomSource(json); } // If the given object is already an instance then just return it. DON'T copy it. if(AtomSource.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof AtomSource)){ return new AtomSource(json); } // If the given object is already an instance then just return it. DON'T copy it. if(AtomSource.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "// Protect against forgetting the new keyword when calling the constructor", "if", "(", "!", "(", "this", "instanceof", "AtomSource", ")", ")", "{", "return", "new", "AtomSource", "(", "json", ")", ";", "}", "// If the given object is already an instance then just return it. DON'T copy it.", "if", "(", "AtomSource", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
Information about the originating feed if an entry is copied or aggregated from another feed. @see {@link https://github.com/FamilySearch/gedcomx-rs/blob/master/specifications/atom-model-specification.md#atom-json-media-type|GEDCOM X Atom JSON Spec} @see {@link https://tools.ietf.org/html/rfc4287#section-4.2.11|RFC 4287} @class AtomSource @extends AtomCommon @param {Object} [json]
[ "Information", "about", "the", "originating", "feed", "if", "an", "entry", "is", "copied", "or", "aggregated", "from", "another", "feed", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/atom/AtomSource.js#L17-L30
38,439
stackr23/cssobjects-loader
lib/transformToNestedDomStyleObjects.js
transformPropertiesToCamelCase
function transformPropertiesToCamelCase (object) { var output = {} for (var _key in object) { if (typeof object === 'string') { return object.replace(' !important', '') } var key = _key var value = object[_key] if (~key.indexOf('-')) { var splittedKeys = key.split('-') splittedKeys = splittedKeys.map(function (v, i) { return i > 0 // UCFIRST if ! first element ? v.charAt(0).toUpperCase() + v.substr(1) : v }) key = splittedKeys.join('') } output[key] = transformPropertiesToCamelCase(value) } return output }
javascript
function transformPropertiesToCamelCase (object) { var output = {} for (var _key in object) { if (typeof object === 'string') { return object.replace(' !important', '') } var key = _key var value = object[_key] if (~key.indexOf('-')) { var splittedKeys = key.split('-') splittedKeys = splittedKeys.map(function (v, i) { return i > 0 // UCFIRST if ! first element ? v.charAt(0).toUpperCase() + v.substr(1) : v }) key = splittedKeys.join('') } output[key] = transformPropertiesToCamelCase(value) } return output }
[ "function", "transformPropertiesToCamelCase", "(", "object", ")", "{", "var", "output", "=", "{", "}", "for", "(", "var", "_key", "in", "object", ")", "{", "if", "(", "typeof", "object", "===", "'string'", ")", "{", "return", "object", ".", "replace", "(", "' !important'", ",", "''", ")", "}", "var", "key", "=", "_key", "var", "value", "=", "object", "[", "_key", "]", "if", "(", "~", "key", ".", "indexOf", "(", "'-'", ")", ")", "{", "var", "splittedKeys", "=", "key", ".", "split", "(", "'-'", ")", "splittedKeys", "=", "splittedKeys", ".", "map", "(", "function", "(", "v", ",", "i", ")", "{", "return", "i", ">", "0", "// UCFIRST if ! first element", "?", "v", ".", "charAt", "(", "0", ")", ".", "toUpperCase", "(", ")", "+", "v", ".", "substr", "(", "1", ")", ":", "v", "}", ")", "key", "=", "splittedKeys", ".", "join", "(", "''", ")", "}", "output", "[", "key", "]", "=", "transformPropertiesToCamelCase", "(", "value", ")", "}", "return", "output", "}" ]
f.e. font-family => fontFamily border-radius => borderRadius
[ "f", ".", "e", ".", "font", "-", "family", "=", ">", "fontFamily", "border", "-", "radius", "=", ">", "borderRadius" ]
eab363c1df302429b85d5b36d8b65cadf7318ba4
https://github.com/stackr23/cssobjects-loader/blob/eab363c1df302429b85d5b36d8b65cadf7318ba4/lib/transformToNestedDomStyleObjects.js#L8-L27
38,440
jaredhanson/junction-disco
lib/junction-disco/elements/item.js
Item
function Item(jid, node, name) { Element.call(this, 'item', 'http://jabber.org/protocol/disco#items'); this.jid = jid; this.node = node; this.displayName = name; }
javascript
function Item(jid, node, name) { Element.call(this, 'item', 'http://jabber.org/protocol/disco#items'); this.jid = jid; this.node = node; this.displayName = name; }
[ "function", "Item", "(", "jid", ",", "node", ",", "name", ")", "{", "Element", ".", "call", "(", "this", ",", "'item'", ",", "'http://jabber.org/protocol/disco#items'", ")", ";", "this", ".", "jid", "=", "jid", ";", "this", ".", "node", "=", "node", ";", "this", ".", "displayName", "=", "name", ";", "}" ]
Initialize a new `Item` element. @param {String} jid @param {String} node @param {String} name @api public
[ "Initialize", "a", "new", "Item", "element", "." ]
89f2d222518b3b0f282d54b25d6405b5e35c1383
https://github.com/jaredhanson/junction-disco/blob/89f2d222518b3b0f282d54b25d6405b5e35c1383/lib/junction-disco/elements/item.js#L15-L20
38,441
SamVerschueren/gulp-cordova-icon
index.js
copyIcon
function copyIcon() { var dest = path.join(process.env.PWD, 'res'); // Make sure the destination exists mkdir(dest); return pify(fs.copy.bind(fs), Promise)(src, path.join(dest, 'icon.' + mime.extension(mimetype))); }
javascript
function copyIcon() { var dest = path.join(process.env.PWD, 'res'); // Make sure the destination exists mkdir(dest); return pify(fs.copy.bind(fs), Promise)(src, path.join(dest, 'icon.' + mime.extension(mimetype))); }
[ "function", "copyIcon", "(", ")", "{", "var", "dest", "=", "path", ".", "join", "(", "process", ".", "env", ".", "PWD", ",", "'res'", ")", ";", "// Make sure the destination exists", "mkdir", "(", "dest", ")", ";", "return", "pify", "(", "fs", ".", "copy", ".", "bind", "(", "fs", ")", ",", "Promise", ")", "(", "src", ",", "path", ".", "join", "(", "dest", ",", "'icon.'", "+", "mime", ".", "extension", "(", "mimetype", ")", ")", ")", ";", "}" ]
Copy the icon to the res subdirectory of the cordova build.
[ "Copy", "the", "icon", "to", "the", "res", "subdirectory", "of", "the", "cordova", "build", "." ]
e228d4d4ccc4e3e9fbbf3f05f47a46015fc59380
https://github.com/SamVerschueren/gulp-cordova-icon/blob/e228d4d4ccc4e3e9fbbf3f05f47a46015fc59380/index.js#L33-L40
38,442
SamVerschueren/gulp-cordova-icon
index.js
copyHooks
function copyHooks() { var src = path.join(__dirname, 'hooks'); var dest = path.join(process.env.PWD, 'hooks'); return pify(fs.copy.bind(fs), Promise)(path.join(__dirname, 'platforms.json'), path.join(dest, 'platforms.json')) .then(function () { memFsEditor.copyTpl(src, dest, options); return pify(memFsEditor.commit.bind(memFsEditor))(); }) .then(function () { // Make all the scripts executable in the Cordova project fs.readdirSync(src).forEach(function (hook) { var hookPath = path.join(dest, hook); fs.readdirSync(hookPath).forEach(function (script) { fs.chmodSync(path.join(hookPath, script), '755'); }); }); }); }
javascript
function copyHooks() { var src = path.join(__dirname, 'hooks'); var dest = path.join(process.env.PWD, 'hooks'); return pify(fs.copy.bind(fs), Promise)(path.join(__dirname, 'platforms.json'), path.join(dest, 'platforms.json')) .then(function () { memFsEditor.copyTpl(src, dest, options); return pify(memFsEditor.commit.bind(memFsEditor))(); }) .then(function () { // Make all the scripts executable in the Cordova project fs.readdirSync(src).forEach(function (hook) { var hookPath = path.join(dest, hook); fs.readdirSync(hookPath).forEach(function (script) { fs.chmodSync(path.join(hookPath, script), '755'); }); }); }); }
[ "function", "copyHooks", "(", ")", "{", "var", "src", "=", "path", ".", "join", "(", "__dirname", ",", "'hooks'", ")", ";", "var", "dest", "=", "path", ".", "join", "(", "process", ".", "env", ".", "PWD", ",", "'hooks'", ")", ";", "return", "pify", "(", "fs", ".", "copy", ".", "bind", "(", "fs", ")", ",", "Promise", ")", "(", "path", ".", "join", "(", "__dirname", ",", "'platforms.json'", ")", ",", "path", ".", "join", "(", "dest", ",", "'platforms.json'", ")", ")", ".", "then", "(", "function", "(", ")", "{", "memFsEditor", ".", "copyTpl", "(", "src", ",", "dest", ",", "options", ")", ";", "return", "pify", "(", "memFsEditor", ".", "commit", ".", "bind", "(", "memFsEditor", ")", ")", "(", ")", ";", "}", ")", ".", "then", "(", "function", "(", ")", "{", "// Make all the scripts executable in the Cordova project", "fs", ".", "readdirSync", "(", "src", ")", ".", "forEach", "(", "function", "(", "hook", ")", "{", "var", "hookPath", "=", "path", ".", "join", "(", "dest", ",", "hook", ")", ";", "fs", ".", "readdirSync", "(", "hookPath", ")", ".", "forEach", "(", "function", "(", "script", ")", "{", "fs", ".", "chmodSync", "(", "path", ".", "join", "(", "hookPath", ",", "script", ")", ",", "'755'", ")", ";", "}", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Copy all the hooks in the `hooks` directory to the `hooks` directory of the cordova project.
[ "Copy", "all", "the", "hooks", "in", "the", "hooks", "directory", "to", "the", "hooks", "directory", "of", "the", "cordova", "project", "." ]
e228d4d4ccc4e3e9fbbf3f05f47a46015fc59380
https://github.com/SamVerschueren/gulp-cordova-icon/blob/e228d4d4ccc4e3e9fbbf3f05f47a46015fc59380/index.js#L46-L66
38,443
SamVerschueren/gulp-cordova-icon
index.js
installHookDependencies
function installHookDependencies() { return Promise.all(hookDependencies.map(function (dependency) { return pify(npmi, Promise)({name: dependency, path: path.join(process.env.PWD, 'hooks')}); })); }
javascript
function installHookDependencies() { return Promise.all(hookDependencies.map(function (dependency) { return pify(npmi, Promise)({name: dependency, path: path.join(process.env.PWD, 'hooks')}); })); }
[ "function", "installHookDependencies", "(", ")", "{", "return", "Promise", ".", "all", "(", "hookDependencies", ".", "map", "(", "function", "(", "dependency", ")", "{", "return", "pify", "(", "npmi", ",", "Promise", ")", "(", "{", "name", ":", "dependency", ",", "path", ":", "path", ".", "join", "(", "process", ".", "env", ".", "PWD", ",", "'hooks'", ")", "}", ")", ";", "}", ")", ")", ";", "}" ]
Install all the dependencies that are used by the hooks.
[ "Install", "all", "the", "dependencies", "that", "are", "used", "by", "the", "hooks", "." ]
e228d4d4ccc4e3e9fbbf3f05f47a46015fc59380
https://github.com/SamVerschueren/gulp-cordova-icon/blob/e228d4d4ccc4e3e9fbbf3f05f47a46015fc59380/index.js#L71-L75
38,444
rootsdev/gedcomx-js
src/core/Note.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Note)){ return new Note(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Note.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Note)){ return new Note(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Note.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "// Protect against forgetting the new keyword when calling the constructor", "if", "(", "!", "(", "this", "instanceof", "Note", ")", ")", "{", "return", "new", "Note", "(", "json", ")", ";", "}", "// If the given object is already an instance then just return it. DON'T copy it.", "if", "(", "Note", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
A note about a resource. @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#note|GEDCOM X JSON Spec} @class @extends ExtensibleData @param {Object} [json]
[ "A", "note", "about", "a", "resource", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/core/Note.js#L13-L26
38,445
mmalecki/seneca-loadbalance-transport
index.js
makeWorker
function makeWorker(worker) { return { seneca: Seneca().client(worker), id: worker.id, up: undefined, lastCallDuration: -1, meanCallDuration: -1, host: worker.host, port: worker.port, type: worker.type } }
javascript
function makeWorker(worker) { return { seneca: Seneca().client(worker), id: worker.id, up: undefined, lastCallDuration: -1, meanCallDuration: -1, host: worker.host, port: worker.port, type: worker.type } }
[ "function", "makeWorker", "(", "worker", ")", "{", "return", "{", "seneca", ":", "Seneca", "(", ")", ".", "client", "(", "worker", ")", ",", "id", ":", "worker", ".", "id", ",", "up", ":", "undefined", ",", "lastCallDuration", ":", "-", "1", ",", "meanCallDuration", ":", "-", "1", ",", "host", ":", "worker", ".", "host", ",", "port", ":", "worker", ".", "port", ",", "type", ":", "worker", ".", "type", "}", "}" ]
Make a worker and put it in our `workers` object
[ "Make", "a", "worker", "and", "put", "it", "in", "our", "workers", "object" ]
08d7e37370ace7768baaed5234054ec9db9d27a4
https://github.com/mmalecki/seneca-loadbalance-transport/blob/08d7e37370ace7768baaed5234054ec9db9d27a4/index.js#L37-L48
38,446
mmalecki/seneca-loadbalance-transport
index.js
nextWorker
function nextWorker(cb) { seneca.act('role:loadbalance,hook:balance', { workers: workers, lastWorker: lastWorker }, function (err, worker) { if (!worker) return cb(new Error('No up backend found')) lastWorker = worker cb(null, worker) }) }
javascript
function nextWorker(cb) { seneca.act('role:loadbalance,hook:balance', { workers: workers, lastWorker: lastWorker }, function (err, worker) { if (!worker) return cb(new Error('No up backend found')) lastWorker = worker cb(null, worker) }) }
[ "function", "nextWorker", "(", "cb", ")", "{", "seneca", ".", "act", "(", "'role:loadbalance,hook:balance'", ",", "{", "workers", ":", "workers", ",", "lastWorker", ":", "lastWorker", "}", ",", "function", "(", "err", ",", "worker", ")", "{", "if", "(", "!", "worker", ")", "return", "cb", "(", "new", "Error", "(", "'No up backend found'", ")", ")", "lastWorker", "=", "worker", "cb", "(", "null", ",", "worker", ")", "}", ")", "}" ]
Get the next worker by asking the `balance` hook for one. Default one is round robin, as implemented in `roundRobin`.
[ "Get", "the", "next", "worker", "by", "asking", "the", "balance", "hook", "for", "one", ".", "Default", "one", "is", "round", "robin", "as", "implemented", "in", "roundRobin", "." ]
08d7e37370ace7768baaed5234054ec9db9d27a4
https://github.com/mmalecki/seneca-loadbalance-transport/blob/08d7e37370ace7768baaed5234054ec9db9d27a4/index.js#L52-L61
38,447
mmalecki/seneca-loadbalance-transport
index.js
addWorker
function addWorker(worker, cb) { function ping() { // A thing to keep in mind that right now it can take very long // (I think default is 22222 ms) for a request to time out, even // in scenarios like remote side breaking the connection and // ECONNREFUSED on reconnect. madeWorker.seneca.act({ role: 'transport', cmd: 'ping' }, function (err) { worker.up = !isTaskTimeout(err) }) } if (!worker.id) worker.id = nid() var madeWorker = makeWorker(worker) madeWorker.pingInterval = setInterval(ping, opts.pingInterval || 1000) ping() workers.push(madeWorker) cb(null, madeWorker) }
javascript
function addWorker(worker, cb) { function ping() { // A thing to keep in mind that right now it can take very long // (I think default is 22222 ms) for a request to time out, even // in scenarios like remote side breaking the connection and // ECONNREFUSED on reconnect. madeWorker.seneca.act({ role: 'transport', cmd: 'ping' }, function (err) { worker.up = !isTaskTimeout(err) }) } if (!worker.id) worker.id = nid() var madeWorker = makeWorker(worker) madeWorker.pingInterval = setInterval(ping, opts.pingInterval || 1000) ping() workers.push(madeWorker) cb(null, madeWorker) }
[ "function", "addWorker", "(", "worker", ",", "cb", ")", "{", "function", "ping", "(", ")", "{", "// A thing to keep in mind that right now it can take very long", "// (I think default is 22222 ms) for a request to time out, even", "// in scenarios like remote side breaking the connection and", "// ECONNREFUSED on reconnect.", "madeWorker", ".", "seneca", ".", "act", "(", "{", "role", ":", "'transport'", ",", "cmd", ":", "'ping'", "}", ",", "function", "(", "err", ")", "{", "worker", ".", "up", "=", "!", "isTaskTimeout", "(", "err", ")", "}", ")", "}", "if", "(", "!", "worker", ".", "id", ")", "worker", ".", "id", "=", "nid", "(", ")", "var", "madeWorker", "=", "makeWorker", "(", "worker", ")", "madeWorker", ".", "pingInterval", "=", "setInterval", "(", "ping", ",", "opts", ".", "pingInterval", "||", "1000", ")", "ping", "(", ")", "workers", ".", "push", "(", "madeWorker", ")", "cb", "(", "null", ",", "madeWorker", ")", "}" ]
Add a new worker.
[ "Add", "a", "new", "worker", "." ]
08d7e37370ace7768baaed5234054ec9db9d27a4
https://github.com/mmalecki/seneca-loadbalance-transport/blob/08d7e37370ace7768baaed5234054ec9db9d27a4/index.js#L79-L96
38,448
BeLi4L/subz-hero
src/providers/subscene.js
getSubtitlesByFilename
async function getSubtitlesByFilename (filename) { // TODO: revamp this + add unit tests return getSubtitlesList(filename) .then(parseSearchResults) .then(getBestSearchResult(filename)) .then(getSubtitlesPage) .then(parseDownloadLink) .then(downloadZip) .then(extractSrt) }
javascript
async function getSubtitlesByFilename (filename) { // TODO: revamp this + add unit tests return getSubtitlesList(filename) .then(parseSearchResults) .then(getBestSearchResult(filename)) .then(getSubtitlesPage) .then(parseDownloadLink) .then(downloadZip) .then(extractSrt) }
[ "async", "function", "getSubtitlesByFilename", "(", "filename", ")", "{", "// TODO: revamp this + add unit tests", "return", "getSubtitlesList", "(", "filename", ")", ".", "then", "(", "parseSearchResults", ")", ".", "then", "(", "getBestSearchResult", "(", "filename", ")", ")", ".", "then", "(", "getSubtitlesPage", ")", ".", "then", "(", "parseDownloadLink", ")", ".", "then", "(", "downloadZip", ")", ".", "then", "(", "extractSrt", ")", "}" ]
Get subtitles for the given filename. @param {string} filename @returns {Promise<string>} the subtitles, formatted as .srt
[ "Get", "subtitles", "for", "the", "given", "filename", "." ]
c22c6df7c2d80c00685a9326043e1ceae3cbf53d
https://github.com/BeLi4L/subz-hero/blob/c22c6df7c2d80c00685a9326043e1ceae3cbf53d/src/providers/subscene.js#L34-L43
38,449
BeLi4L/subz-hero
src/providers/subscene.js
getSubtitlesList
async function getSubtitlesList (filename) { return request({ method: 'GET', uri: SUBSCENE_URL + '/subtitles/release', qs: { q: filename, // search query l: '', // language (english) r: true // released or whatever } }) }
javascript
async function getSubtitlesList (filename) { return request({ method: 'GET', uri: SUBSCENE_URL + '/subtitles/release', qs: { q: filename, // search query l: '', // language (english) r: true // released or whatever } }) }
[ "async", "function", "getSubtitlesList", "(", "filename", ")", "{", "return", "request", "(", "{", "method", ":", "'GET'", ",", "uri", ":", "SUBSCENE_URL", "+", "'/subtitles/release'", ",", "qs", ":", "{", "q", ":", "filename", ",", "// search query", "l", ":", "''", ",", "// language (english)", "r", ":", "true", "// released or whatever", "}", "}", ")", "}" ]
Search for the given file on SubScene. @param {string} filename @returns {Promise<string>} the HTML string, containing the search results
[ "Search", "for", "the", "given", "file", "on", "SubScene", "." ]
c22c6df7c2d80c00685a9326043e1ceae3cbf53d
https://github.com/BeLi4L/subz-hero/blob/c22c6df7c2d80c00685a9326043e1ceae3cbf53d/src/providers/subscene.js#L51-L61
38,450
BeLi4L/subz-hero
src/providers/subscene.js
parseSearchResults
function parseSearchResults (html) { const $ = cheerio.load(html) return $('a') .filter(function (index, element) { const spans = $(element).find('span') return spans.length === 2 && spans.eq(0).text().trim() === 'English' }) .map(function (index, element) { const title = $(element).find('span').eq(1).text().trim() const url = $(element).attr('href') return new SearchResult({ title: title, url: url }) }) .get() }
javascript
function parseSearchResults (html) { const $ = cheerio.load(html) return $('a') .filter(function (index, element) { const spans = $(element).find('span') return spans.length === 2 && spans.eq(0).text().trim() === 'English' }) .map(function (index, element) { const title = $(element).find('span').eq(1).text().trim() const url = $(element).attr('href') return new SearchResult({ title: title, url: url }) }) .get() }
[ "function", "parseSearchResults", "(", "html", ")", "{", "const", "$", "=", "cheerio", ".", "load", "(", "html", ")", "return", "$", "(", "'a'", ")", ".", "filter", "(", "function", "(", "index", ",", "element", ")", "{", "const", "spans", "=", "$", "(", "element", ")", ".", "find", "(", "'span'", ")", "return", "spans", ".", "length", "===", "2", "&&", "spans", ".", "eq", "(", "0", ")", ".", "text", "(", ")", ".", "trim", "(", ")", "===", "'English'", "}", ")", ".", "map", "(", "function", "(", "index", ",", "element", ")", "{", "const", "title", "=", "$", "(", "element", ")", ".", "find", "(", "'span'", ")", ".", "eq", "(", "1", ")", ".", "text", "(", ")", ".", "trim", "(", ")", "const", "url", "=", "$", "(", "element", ")", ".", "attr", "(", "'href'", ")", "return", "new", "SearchResult", "(", "{", "title", ":", "title", ",", "url", ":", "url", "}", ")", "}", ")", ".", "get", "(", ")", "}" ]
Parse an HTML document that contains a list of SubScene search results. @param {string} html @returns {Array<SearchResult>} the list of search results
[ "Parse", "an", "HTML", "document", "that", "contains", "a", "list", "of", "SubScene", "search", "results", "." ]
c22c6df7c2d80c00685a9326043e1ceae3cbf53d
https://github.com/BeLi4L/subz-hero/blob/c22c6df7c2d80c00685a9326043e1ceae3cbf53d/src/providers/subscene.js#L69-L85
38,451
BeLi4L/subz-hero
src/providers/subscene.js
downloadZip
async function downloadZip (href) { return request({ method: 'GET', uri: SUBSCENE_URL + href, encoding: null }) }
javascript
async function downloadZip (href) { return request({ method: 'GET', uri: SUBSCENE_URL + href, encoding: null }) }
[ "async", "function", "downloadZip", "(", "href", ")", "{", "return", "request", "(", "{", "method", ":", "'GET'", ",", "uri", ":", "SUBSCENE_URL", "+", "href", ",", "encoding", ":", "null", "}", ")", "}" ]
Download the subtitles based on the given link. @param {string} href @returns {Promise<Buffer>} the ZIP content
[ "Download", "the", "subtitles", "based", "on", "the", "given", "link", "." ]
c22c6df7c2d80c00685a9326043e1ceae3cbf53d
https://github.com/BeLi4L/subz-hero/blob/c22c6df7c2d80c00685a9326043e1ceae3cbf53d/src/providers/subscene.js#L138-L144
38,452
BeLi4L/subz-hero
src/providers/subscene.js
extractSrt
function extractSrt (buffer) { const zip = new AdmZip(buffer) const srtZipEntry = zip .getEntries() .find(zipEntry => zipEntry.entryName.endsWith('.srt') ) return zip.readAsText(srtZipEntry) }
javascript
function extractSrt (buffer) { const zip = new AdmZip(buffer) const srtZipEntry = zip .getEntries() .find(zipEntry => zipEntry.entryName.endsWith('.srt') ) return zip.readAsText(srtZipEntry) }
[ "function", "extractSrt", "(", "buffer", ")", "{", "const", "zip", "=", "new", "AdmZip", "(", "buffer", ")", "const", "srtZipEntry", "=", "zip", ".", "getEntries", "(", ")", ".", "find", "(", "zipEntry", "=>", "zipEntry", ".", "entryName", ".", "endsWith", "(", "'.srt'", ")", ")", "return", "zip", ".", "readAsText", "(", "srtZipEntry", ")", "}" ]
Extract the first .srt file found in the given ZIP buffer. @param {Buffer} buffer @returns {string} the content of the first .srt file found in the given ZIP
[ "Extract", "the", "first", ".", "srt", "file", "found", "in", "the", "given", "ZIP", "buffer", "." ]
c22c6df7c2d80c00685a9326043e1ceae3cbf53d
https://github.com/BeLi4L/subz-hero/blob/c22c6df7c2d80c00685a9326043e1ceae3cbf53d/src/providers/subscene.js#L152-L160
38,453
WRidder/backgrid-advanced-filter
src/filter-dropdown.js
function (e) { var self = this; if (e) { self.stopPropagation(e); } // Get current filter var currentFilter = self.filterStateModel.getActiveFilter(); if (currentFilter !== self.filter) { self.filterStateModel.setActiveFilter(self.filter); self.filterStateModel.trigger("filter:loaded"); } }
javascript
function (e) { var self = this; if (e) { self.stopPropagation(e); } // Get current filter var currentFilter = self.filterStateModel.getActiveFilter(); if (currentFilter !== self.filter) { self.filterStateModel.setActiveFilter(self.filter); self.filterStateModel.trigger("filter:loaded"); } }
[ "function", "(", "e", ")", "{", "var", "self", "=", "this", ";", "if", "(", "e", ")", "{", "self", ".", "stopPropagation", "(", "e", ")", ";", "}", "// Get current filter", "var", "currentFilter", "=", "self", ".", "filterStateModel", ".", "getActiveFilter", "(", ")", ";", "if", "(", "currentFilter", "!==", "self", ".", "filter", ")", "{", "self", ".", "filterStateModel", ".", "setActiveFilter", "(", "self", ".", "filter", ")", ";", "self", ".", "filterStateModel", ".", "trigger", "(", "\"filter:loaded\"", ")", ";", "}", "}" ]
Activates current filer @method setActiveFilter @param {object} e
[ "Activates", "current", "filer" ]
5b10216f091d0e4bad418398fb4ec4c4588f4475
https://github.com/WRidder/backgrid-advanced-filter/blob/5b10216f091d0e4bad418398fb4ec4c4588f4475/src/filter-dropdown.js#L49-L61
38,454
WRidder/backgrid-advanced-filter
src/filter-dropdown.js
function (e) { var self = this; if (self.isOpen !== true) { self.open(e); } else { self.close(e); } }
javascript
function (e) { var self = this; if (self.isOpen !== true) { self.open(e); } else { self.close(e); } }
[ "function", "(", "e", ")", "{", "var", "self", "=", "this", ";", "if", "(", "self", ".", "isOpen", "!==", "true", ")", "{", "self", ".", "open", "(", "e", ")", ";", "}", "else", "{", "self", ".", "close", "(", "e", ")", ";", "}", "}" ]
Toggle the dropdown visibility @method toggle @param {object} [e]
[ "Toggle", "the", "dropdown", "visibility" ]
5b10216f091d0e4bad418398fb4ec4c4588f4475
https://github.com/WRidder/backgrid-advanced-filter/blob/5b10216f091d0e4bad418398fb4ec4c4588f4475/src/filter-dropdown.js#L348-L356
38,455
WRidder/backgrid-advanced-filter
src/filter-dropdown.js
function (e) { var self = this; clearTimeout(self.closeTimeout); clearTimeout(self.deferCloseTimeout); if (e) { if (e.stopPropagation) { e.stopPropagation(); } if (e.preventDefault) { e.preventDefault(); } e.cancelBubble = true; } // Don't do anything if already open if (self.isOpen) { return; } self.isOpen = true; self.$el.addClass("open"); // Notify child view self.dropdownContainerView.open(); }
javascript
function (e) { var self = this; clearTimeout(self.closeTimeout); clearTimeout(self.deferCloseTimeout); if (e) { if (e.stopPropagation) { e.stopPropagation(); } if (e.preventDefault) { e.preventDefault(); } e.cancelBubble = true; } // Don't do anything if already open if (self.isOpen) { return; } self.isOpen = true; self.$el.addClass("open"); // Notify child view self.dropdownContainerView.open(); }
[ "function", "(", "e", ")", "{", "var", "self", "=", "this", ";", "clearTimeout", "(", "self", ".", "closeTimeout", ")", ";", "clearTimeout", "(", "self", ".", "deferCloseTimeout", ")", ";", "if", "(", "e", ")", "{", "if", "(", "e", ".", "stopPropagation", ")", "{", "e", ".", "stopPropagation", "(", ")", ";", "}", "if", "(", "e", ".", "preventDefault", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "}", "e", ".", "cancelBubble", "=", "true", ";", "}", "// Don't do anything if already open", "if", "(", "self", ".", "isOpen", ")", "{", "return", ";", "}", "self", ".", "isOpen", "=", "true", ";", "self", ".", "$el", ".", "addClass", "(", "\"open\"", ")", ";", "// Notify child view", "self", ".", "dropdownContainerView", ".", "open", "(", ")", ";", "}" ]
Open the dropdown @method open @param {object} [e]
[ "Open", "the", "dropdown" ]
5b10216f091d0e4bad418398fb4ec4c4588f4475
https://github.com/WRidder/backgrid-advanced-filter/blob/5b10216f091d0e4bad418398fb4ec4c4588f4475/src/filter-dropdown.js#L364-L390
38,456
WRidder/backgrid-advanced-filter
src/filter-dropdown.js
function (e) { var self = this; // Don't do anything if already closed if (!self.isOpen) { return; } self.isOpen = false; self.$el.removeClass("open"); // Notify child view self.dropdownContainerView.close(); }
javascript
function (e) { var self = this; // Don't do anything if already closed if (!self.isOpen) { return; } self.isOpen = false; self.$el.removeClass("open"); // Notify child view self.dropdownContainerView.close(); }
[ "function", "(", "e", ")", "{", "var", "self", "=", "this", ";", "// Don't do anything if already closed", "if", "(", "!", "self", ".", "isOpen", ")", "{", "return", ";", "}", "self", ".", "isOpen", "=", "false", ";", "self", ".", "$el", ".", "removeClass", "(", "\"open\"", ")", ";", "// Notify child view", "self", ".", "dropdownContainerView", ".", "close", "(", ")", ";", "}" ]
Close the dropdown @method close @param {object} [e]
[ "Close", "the", "dropdown" ]
5b10216f091d0e4bad418398fb4ec4c4588f4475
https://github.com/WRidder/backgrid-advanced-filter/blob/5b10216f091d0e4bad418398fb4ec4c4588f4475/src/filter-dropdown.js#L398-L411
38,457
rootsdev/gedcomx-js
src/core/Address.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Address)){ return new Address(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Address.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Address)){ return new Address(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Address.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "// Protect against forgetting the new keyword when calling the constructor", "if", "(", "!", "(", "this", "instanceof", "Address", ")", ")", "{", "return", "new", "Address", "(", "json", ")", ";", "}", "// If the given object is already an instance then just return it. DON'T copy it.", "if", "(", "Address", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
An address. @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#address|GEDCOM X JSON Spec} @class @extends ExtensibleData @param {Object} [json]
[ "An", "address", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/core/Address.js#L13-L26
38,458
greim/ng-falcor
src/index.js
function(...path) { path = pathify(path); return noUndef(path) ? model.getValueSync(path) : undefined; }
javascript
function(...path) { path = pathify(path); return noUndef(path) ? model.getValueSync(path) : undefined; }
[ "function", "(", "...", "path", ")", "{", "path", "=", "pathify", "(", "path", ")", ";", "return", "noUndef", "(", "path", ")", "?", "model", ".", "getValueSync", "(", "path", ")", ":", "undefined", ";", "}" ]
Retrieve a value. Path must reference a single node in the graph.
[ "Retrieve", "a", "value", ".", "Path", "must", "reference", "a", "single", "node", "in", "the", "graph", "." ]
bbdad2bcf63f9b3b7e0b5ead083f36b0454cccd3
https://github.com/greim/ng-falcor/blob/bbdad2bcf63f9b3b7e0b5ead083f36b0454cccd3/src/index.js#L31-L36
38,459
matterial/reckonjs
reckon.js
function(params) { /** * Reckon version * @type {String} */ this.version = '0.1.0'; /** * Define delimiter that marks beginning of interpolation * @type {String} */ this.delimStart = settings.delimStart; /** * Define delimiter that marks end of interpolation * @type {String} */ this.delimEnd = settings.delimEnd; /** * Get the text from params * @type {String} */ this.text = typeof params !=="undefined" && params.text !== "undefined" ? params.text : ''; /** * Get the scope from the params and ensure its an array, if not, make it one * @type {Array} */ this.scopes = typeof params !=="undefined" && typeof params.scope !== "undefined" ? [].concat(params.scope) : []; /** * Check if config needs to be applied from the global settings */ this.applyConfig(); /** * Compile the initial input */ if (typeof params !=="undefined" && typeof params.text !== "undefined") this.compile(); }
javascript
function(params) { /** * Reckon version * @type {String} */ this.version = '0.1.0'; /** * Define delimiter that marks beginning of interpolation * @type {String} */ this.delimStart = settings.delimStart; /** * Define delimiter that marks end of interpolation * @type {String} */ this.delimEnd = settings.delimEnd; /** * Get the text from params * @type {String} */ this.text = typeof params !=="undefined" && params.text !== "undefined" ? params.text : ''; /** * Get the scope from the params and ensure its an array, if not, make it one * @type {Array} */ this.scopes = typeof params !=="undefined" && typeof params.scope !== "undefined" ? [].concat(params.scope) : []; /** * Check if config needs to be applied from the global settings */ this.applyConfig(); /** * Compile the initial input */ if (typeof params !=="undefined" && typeof params.text !== "undefined") this.compile(); }
[ "function", "(", "params", ")", "{", "/**\n\t\t * Reckon version\n\t\t * @type {String}\n\t\t */", "this", ".", "version", "=", "'0.1.0'", ";", "/**\n\t\t * Define delimiter that marks beginning of interpolation\n\t\t * @type {String}\n\t\t */", "this", ".", "delimStart", "=", "settings", ".", "delimStart", ";", "/**\n\t\t * Define delimiter that marks end of interpolation\n\t\t * @type {String}\n\t\t */", "this", ".", "delimEnd", "=", "settings", ".", "delimEnd", ";", "/**\n\t\t * Get the text from params\n\t\t * @type {String}\n\t\t */", "this", ".", "text", "=", "typeof", "params", "!==", "\"undefined\"", "&&", "params", ".", "text", "!==", "\"undefined\"", "?", "params", ".", "text", ":", "''", ";", "/**\n\t\t * Get the scope from the params and ensure its an array, if not, make it one\n\t\t * @type {Array}\n\t\t */", "this", ".", "scopes", "=", "typeof", "params", "!==", "\"undefined\"", "&&", "typeof", "params", ".", "scope", "!==", "\"undefined\"", "?", "[", "]", ".", "concat", "(", "params", ".", "scope", ")", ":", "[", "]", ";", "/**\n\t\t * Check if config needs to be applied from the global settings\n\t\t */", "this", ".", "applyConfig", "(", ")", ";", "/**\n\t\t * Compile the initial input\n\t\t */", "if", "(", "typeof", "params", "!==", "\"undefined\"", "&&", "typeof", "params", ".", "text", "!==", "\"undefined\"", ")", "this", ".", "compile", "(", ")", ";", "}" ]
The actual Reckon implementation @param {Object} params Configuration and data
[ "The", "actual", "Reckon", "implementation" ]
39e1867886f50a2bd48eaeb15e24b24a09d22c24
https://github.com/matterial/reckonjs/blob/39e1867886f50a2bd48eaeb15e24b24a09d22c24/reckon.js#L28-L69
38,460
matterial/reckonjs
reckon.js
function(param) { /** * Reference the instance */ var rInstance = this; if (typeof param !== "undefined") { rInstance.text = param.text; rInstance.scopes = [].concat(param.scope); } /** * The required regexp computed using delims in settings * @type {RegExp} */ var re = new RegExp(['{%(.+?)%}|', this.delimStart, '(.+?)', this.delimEnd].join(''), 'g'); /** * Save the raw text * @type {String} */ rInstance.raw = rInstance.text; /** * Compute and assign to compiledText property of the same object * @param {String} _ Matched string * @param {String} $1 Content of first match group * @param {String} $2 Content of second match group * @return {String} Interpolated string */ rInstance.text = rInstance.text.replace(re, function(_, $1, $2) { var computed; /** * If escaped value is found, interpolation will not happen */ if ($1) { computed = $1; } /** * Matched content, let's interpolate */ if ($2) { /** * Break out scope variables out of scope's box and evaluate the expr expression */ var scopeBox = function(expr, localScope) { var variables = ''; /** * If scope is a window object, no need to scopebox it */ if (typeof window !== "undefined" ? localScope !== window : true) { for(var i in localScope) { variables += 'var ' + i + ' = localScope.' + i + '; '; } } var unbox = '(function() { ' + variables + ' try { return eval(expr);} catch(e) {} })()'; return eval(unbox); }; if (rInstance.scopes.length) { var numScopes = rInstance.scopes.length; for (var i=0;i<numScopes;i++) { /** * Current Scope * @type {String} */ var scope = rInstance.scopes[i]; /** * Get the computation * @type {Any} */ computed = scopeBox($2, scope); /** * If the computed property is a function, execute it in the context of the current scope * @type {Unknown} */ if (typeof computed === "function") { computed = computed.call(scope); } /** * If the computed property is an object, get the string */ if (typeof computed === "object") { computed = computed.toString(); } /** * Found what we were looking for, now break the loop */ if (computed !== undefined) break; } } else { /** * If no scope is passed, let us assume the global scope * @type {Any} */ computed = scopeBox($2, (typeof window !== "undefined" ? window : {})); } /** * If no computations were found, we return the raw matched value back * @type {String} */ computed = computed !== undefined ? computed : _; } /** * Final computed value returned */ return computed; }); /** * Return self for chaining */ return rInstance; }
javascript
function(param) { /** * Reference the instance */ var rInstance = this; if (typeof param !== "undefined") { rInstance.text = param.text; rInstance.scopes = [].concat(param.scope); } /** * The required regexp computed using delims in settings * @type {RegExp} */ var re = new RegExp(['{%(.+?)%}|', this.delimStart, '(.+?)', this.delimEnd].join(''), 'g'); /** * Save the raw text * @type {String} */ rInstance.raw = rInstance.text; /** * Compute and assign to compiledText property of the same object * @param {String} _ Matched string * @param {String} $1 Content of first match group * @param {String} $2 Content of second match group * @return {String} Interpolated string */ rInstance.text = rInstance.text.replace(re, function(_, $1, $2) { var computed; /** * If escaped value is found, interpolation will not happen */ if ($1) { computed = $1; } /** * Matched content, let's interpolate */ if ($2) { /** * Break out scope variables out of scope's box and evaluate the expr expression */ var scopeBox = function(expr, localScope) { var variables = ''; /** * If scope is a window object, no need to scopebox it */ if (typeof window !== "undefined" ? localScope !== window : true) { for(var i in localScope) { variables += 'var ' + i + ' = localScope.' + i + '; '; } } var unbox = '(function() { ' + variables + ' try { return eval(expr);} catch(e) {} })()'; return eval(unbox); }; if (rInstance.scopes.length) { var numScopes = rInstance.scopes.length; for (var i=0;i<numScopes;i++) { /** * Current Scope * @type {String} */ var scope = rInstance.scopes[i]; /** * Get the computation * @type {Any} */ computed = scopeBox($2, scope); /** * If the computed property is a function, execute it in the context of the current scope * @type {Unknown} */ if (typeof computed === "function") { computed = computed.call(scope); } /** * If the computed property is an object, get the string */ if (typeof computed === "object") { computed = computed.toString(); } /** * Found what we were looking for, now break the loop */ if (computed !== undefined) break; } } else { /** * If no scope is passed, let us assume the global scope * @type {Any} */ computed = scopeBox($2, (typeof window !== "undefined" ? window : {})); } /** * If no computations were found, we return the raw matched value back * @type {String} */ computed = computed !== undefined ? computed : _; } /** * Final computed value returned */ return computed; }); /** * Return self for chaining */ return rInstance; }
[ "function", "(", "param", ")", "{", "/**\n\t\t\t * Reference the instance\n\t\t\t */", "var", "rInstance", "=", "this", ";", "if", "(", "typeof", "param", "!==", "\"undefined\"", ")", "{", "rInstance", ".", "text", "=", "param", ".", "text", ";", "rInstance", ".", "scopes", "=", "[", "]", ".", "concat", "(", "param", ".", "scope", ")", ";", "}", "/**\n\t\t\t * The required regexp computed using delims in settings\n\t\t\t * @type {RegExp}\n\t\t\t */", "var", "re", "=", "new", "RegExp", "(", "[", "'{%(.+?)%}|'", ",", "this", ".", "delimStart", ",", "'(.+?)'", ",", "this", ".", "delimEnd", "]", ".", "join", "(", "''", ")", ",", "'g'", ")", ";", "/**\n\t\t\t * Save the raw text\n\t\t\t * @type {String}\n\t\t\t */", "rInstance", ".", "raw", "=", "rInstance", ".", "text", ";", "/**\n\t\t\t * Compute and assign to compiledText property of the same object\n\t\t\t * @param {String} _ Matched string\n\t\t\t * @param {String} $1 Content of first match group\n\t\t\t * @param {String} $2 Content of second match group\n\t\t\t * @return {String} Interpolated string\n\t\t\t */", "rInstance", ".", "text", "=", "rInstance", ".", "text", ".", "replace", "(", "re", ",", "function", "(", "_", ",", "$1", ",", "$2", ")", "{", "var", "computed", ";", "/**\n\t\t\t\t * If escaped value is found, interpolation will not happen\n\t\t\t\t */", "if", "(", "$1", ")", "{", "computed", "=", "$1", ";", "}", "/**\n\t\t\t\t * Matched content, let's interpolate\n\t\t\t\t */", "if", "(", "$2", ")", "{", "/**\n\t\t\t\t\t * Break out scope variables out of scope's box and evaluate the expr expression\n\t\t\t\t\t */", "var", "scopeBox", "=", "function", "(", "expr", ",", "localScope", ")", "{", "var", "variables", "=", "''", ";", "/**\n\t\t\t\t\t\t * If scope is a window object, no need to scopebox it\n\t\t\t\t\t\t */", "if", "(", "typeof", "window", "!==", "\"undefined\"", "?", "localScope", "!==", "window", ":", "true", ")", "{", "for", "(", "var", "i", "in", "localScope", ")", "{", "variables", "+=", "'var '", "+", "i", "+", "' = localScope.'", "+", "i", "+", "'; '", ";", "}", "}", "var", "unbox", "=", "'(function() { '", "+", "variables", "+", "' try { return eval(expr);} catch(e) {} })()'", ";", "return", "eval", "(", "unbox", ")", ";", "}", ";", "if", "(", "rInstance", ".", "scopes", ".", "length", ")", "{", "var", "numScopes", "=", "rInstance", ".", "scopes", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "numScopes", ";", "i", "++", ")", "{", "/**\n\t\t\t\t\t\t\t * Current Scope\n\t\t\t\t\t\t\t * @type {String}\n\t\t\t\t\t\t\t */", "var", "scope", "=", "rInstance", ".", "scopes", "[", "i", "]", ";", "/**\n\t\t\t\t\t\t\t * Get the computation\n\t\t\t\t\t\t\t * @type {Any}\n\t\t\t\t\t\t\t */", "computed", "=", "scopeBox", "(", "$2", ",", "scope", ")", ";", "/**\n\t\t\t\t\t\t\t * If the computed property is a function, execute it in the context of the current scope\n\t\t\t\t\t\t\t * @type {Unknown}\n\t\t\t\t\t\t\t */", "if", "(", "typeof", "computed", "===", "\"function\"", ")", "{", "computed", "=", "computed", ".", "call", "(", "scope", ")", ";", "}", "/**\n\t\t\t\t\t\t\t * If the computed property is an object, get the string\n\t\t\t\t\t\t\t */", "if", "(", "typeof", "computed", "===", "\"object\"", ")", "{", "computed", "=", "computed", ".", "toString", "(", ")", ";", "}", "/**\n\t\t\t\t\t\t\t * Found what we were looking for, now break the loop\n\t\t\t\t\t\t\t */", "if", "(", "computed", "!==", "undefined", ")", "break", ";", "}", "}", "else", "{", "/**\n\t\t\t\t\t\t * If no scope is passed, let us assume the global scope\n\t\t\t\t\t\t * @type {Any}\n\t\t\t\t\t\t */", "computed", "=", "scopeBox", "(", "$2", ",", "(", "typeof", "window", "!==", "\"undefined\"", "?", "window", ":", "{", "}", ")", ")", ";", "}", "/**\n\t\t\t\t\t * If no computations were found, we return the raw matched value back\n\t\t\t\t\t * @type {String}\n\t\t\t\t\t */", "computed", "=", "computed", "!==", "undefined", "?", "computed", ":", "_", ";", "}", "/**\n\t\t\t\t * Final computed value returned\n\t\t\t\t */", "return", "computed", ";", "}", ")", ";", "/**\n\t\t\t * Return self for chaining\n\t\t\t */", "return", "rInstance", ";", "}" ]
The function responsible for interpolation @return {Reckon} return self object for chaining
[ "The", "function", "responsible", "for", "interpolation" ]
39e1867886f50a2bd48eaeb15e24b24a09d22c24
https://github.com/matterial/reckonjs/blob/39e1867886f50a2bd48eaeb15e24b24a09d22c24/reckon.js#L81-L208
38,461
matterial/reckonjs
reckon.js
function(expr, localScope) { var variables = ''; /** * If scope is a window object, no need to scopebox it */ if (typeof window !== "undefined" ? localScope !== window : true) { for(var i in localScope) { variables += 'var ' + i + ' = localScope.' + i + '; '; } } var unbox = '(function() { ' + variables + ' try { return eval(expr);} catch(e) {} })()'; return eval(unbox); }
javascript
function(expr, localScope) { var variables = ''; /** * If scope is a window object, no need to scopebox it */ if (typeof window !== "undefined" ? localScope !== window : true) { for(var i in localScope) { variables += 'var ' + i + ' = localScope.' + i + '; '; } } var unbox = '(function() { ' + variables + ' try { return eval(expr);} catch(e) {} })()'; return eval(unbox); }
[ "function", "(", "expr", ",", "localScope", ")", "{", "var", "variables", "=", "''", ";", "/**\n\t\t\t\t\t\t * If scope is a window object, no need to scopebox it\n\t\t\t\t\t\t */", "if", "(", "typeof", "window", "!==", "\"undefined\"", "?", "localScope", "!==", "window", ":", "true", ")", "{", "for", "(", "var", "i", "in", "localScope", ")", "{", "variables", "+=", "'var '", "+", "i", "+", "' = localScope.'", "+", "i", "+", "'; '", ";", "}", "}", "var", "unbox", "=", "'(function() { '", "+", "variables", "+", "' try { return eval(expr);} catch(e) {} })()'", ";", "return", "eval", "(", "unbox", ")", ";", "}" ]
Break out scope variables out of scope's box and evaluate the expr expression
[ "Break", "out", "scope", "variables", "out", "of", "scope", "s", "box", "and", "evaluate", "the", "expr", "expression" ]
39e1867886f50a2bd48eaeb15e24b24a09d22c24
https://github.com/matterial/reckonjs/blob/39e1867886f50a2bd48eaeb15e24b24a09d22c24/reckon.js#L132-L145
38,462
matterial/reckonjs
reckon.js
function(setting) { if (typeof setting === "undefined") { if (typeof window !== "undefined") { if (typeof window.reckonSettings !== "undefined") { if (typeof window.reckonSettings.delimStart) { settings.delimStart = window.reckonSettings.delimStart; } if (typeof window.reckonSettings.delimEnd) { settings.delimEnd = window.reckonSettings.delimEnd; } } } } else { if (typeof setting.delimStart) { settings.delimStart = setting.delimStart; } if (typeof setting.delimEnd) { settings.delimEnd = setting.delimEnd; } } this.delimStart = settings.delimStart; this.delimEnd = settings.delimEnd; return this; }
javascript
function(setting) { if (typeof setting === "undefined") { if (typeof window !== "undefined") { if (typeof window.reckonSettings !== "undefined") { if (typeof window.reckonSettings.delimStart) { settings.delimStart = window.reckonSettings.delimStart; } if (typeof window.reckonSettings.delimEnd) { settings.delimEnd = window.reckonSettings.delimEnd; } } } } else { if (typeof setting.delimStart) { settings.delimStart = setting.delimStart; } if (typeof setting.delimEnd) { settings.delimEnd = setting.delimEnd; } } this.delimStart = settings.delimStart; this.delimEnd = settings.delimEnd; return this; }
[ "function", "(", "setting", ")", "{", "if", "(", "typeof", "setting", "===", "\"undefined\"", ")", "{", "if", "(", "typeof", "window", "!==", "\"undefined\"", ")", "{", "if", "(", "typeof", "window", ".", "reckonSettings", "!==", "\"undefined\"", ")", "{", "if", "(", "typeof", "window", ".", "reckonSettings", ".", "delimStart", ")", "{", "settings", ".", "delimStart", "=", "window", ".", "reckonSettings", ".", "delimStart", ";", "}", "if", "(", "typeof", "window", ".", "reckonSettings", ".", "delimEnd", ")", "{", "settings", ".", "delimEnd", "=", "window", ".", "reckonSettings", ".", "delimEnd", ";", "}", "}", "}", "}", "else", "{", "if", "(", "typeof", "setting", ".", "delimStart", ")", "{", "settings", ".", "delimStart", "=", "setting", ".", "delimStart", ";", "}", "if", "(", "typeof", "setting", ".", "delimEnd", ")", "{", "settings", ".", "delimEnd", "=", "setting", ".", "delimEnd", ";", "}", "}", "this", ".", "delimStart", "=", "settings", ".", "delimStart", ";", "this", ".", "delimEnd", "=", "settings", ".", "delimEnd", ";", "return", "this", ";", "}" ]
Modify in-built settings @param {Object} setting Delim settings @return {Object} Return self for chaining
[ "Modify", "in", "-", "built", "settings" ]
39e1867886f50a2bd48eaeb15e24b24a09d22c24
https://github.com/matterial/reckonjs/blob/39e1867886f50a2bd48eaeb15e24b24a09d22c24/reckon.js#L217-L241
38,463
BeLi4L/subz-hero
src/providers/subdb.js
hash
async function hash (file) { const filesize = await fileUtil.getFileSize(file) const chunkSize = 64 * 1024 const firstBytesPromise = fileUtil.readBytes({ file, chunkSize, start: 0 }) const lastBytesPromise = fileUtil.readBytes({ file, chunkSize, start: filesize - chunkSize }) const [ firstBytes, lastBytes ] = await Promise.all([firstBytesPromise, lastBytesPromise]) return crypto .createHash('md5') .update(firstBytes) .update(lastBytes) .digest('hex') }
javascript
async function hash (file) { const filesize = await fileUtil.getFileSize(file) const chunkSize = 64 * 1024 const firstBytesPromise = fileUtil.readBytes({ file, chunkSize, start: 0 }) const lastBytesPromise = fileUtil.readBytes({ file, chunkSize, start: filesize - chunkSize }) const [ firstBytes, lastBytes ] = await Promise.all([firstBytesPromise, lastBytesPromise]) return crypto .createHash('md5') .update(firstBytes) .update(lastBytes) .digest('hex') }
[ "async", "function", "hash", "(", "file", ")", "{", "const", "filesize", "=", "await", "fileUtil", ".", "getFileSize", "(", "file", ")", "const", "chunkSize", "=", "64", "*", "1024", "const", "firstBytesPromise", "=", "fileUtil", ".", "readBytes", "(", "{", "file", ",", "chunkSize", ",", "start", ":", "0", "}", ")", "const", "lastBytesPromise", "=", "fileUtil", ".", "readBytes", "(", "{", "file", ",", "chunkSize", ",", "start", ":", "filesize", "-", "chunkSize", "}", ")", "const", "[", "firstBytes", ",", "lastBytes", "]", "=", "await", "Promise", ".", "all", "(", "[", "firstBytesPromise", ",", "lastBytesPromise", "]", ")", "return", "crypto", ".", "createHash", "(", "'md5'", ")", ".", "update", "(", "firstBytes", ")", ".", "update", "(", "lastBytes", ")", ".", "digest", "(", "'hex'", ")", "}" ]
Create the hash used to identify a file. @param {string} file - path to a file @returns {Promise<string>} a hex string representing the MD5 digest of the first 64kB and the last 64kB of the given file
[ "Create", "the", "hash", "used", "to", "identify", "a", "file", "." ]
c22c6df7c2d80c00685a9326043e1ceae3cbf53d
https://github.com/BeLi4L/subz-hero/blob/c22c6df7c2d80c00685a9326043e1ceae3cbf53d/src/providers/subdb.js#L47-L71
38,464
angie-framework/angie
src/services/$Response.js
controllerTemplateRouteResponse
function controllerTemplateRouteResponse() { if (this.template) { let match = this.template.toString().match(/!doctype ([a-z]+)/i), mime; // In the context where MIME type is not set, but we have a // DOCTYPE tag, we can force set the MIME // We want this here instead of the explicit template definition // in case the MIME failed earlier if (match && !this.response.$headers.hasOwnProperty('Content-Type')) { mime = this.response.$headers[ 'Content-Type' ] = $MimeType.$$(match[1].toLowerCase()); } // Check to see if this is an HTML template and has a DOCTYPE // and that the proper configuration options are set if ( mime === 'text/html' && config.loadDefaultScriptFile && ( this.route.hasOwnProperty('useDefaultScriptFile') || this.route.useDefaultScriptFile !== false ) ) { // Check that option is not true let scriptFile = config.loadDefaultScriptFile === true ? 'application.js' : config.loadDefaultScriptFile; $resourceLoader(scriptFile); } // Pull the response back in from wherever it was before this.content = this.response.content; // Render the template into the resoponse let me = this; return new Promise(function(resolve) { // $Compile to parse template strings and app.directives return $compile(me.template)( // In the context of the scope me.$scope ).then(function(template) { resolve(template); }); }).then(function(template) { me.response.content = me.content += template; me.response.write(me.content); }); } }
javascript
function controllerTemplateRouteResponse() { if (this.template) { let match = this.template.toString().match(/!doctype ([a-z]+)/i), mime; // In the context where MIME type is not set, but we have a // DOCTYPE tag, we can force set the MIME // We want this here instead of the explicit template definition // in case the MIME failed earlier if (match && !this.response.$headers.hasOwnProperty('Content-Type')) { mime = this.response.$headers[ 'Content-Type' ] = $MimeType.$$(match[1].toLowerCase()); } // Check to see if this is an HTML template and has a DOCTYPE // and that the proper configuration options are set if ( mime === 'text/html' && config.loadDefaultScriptFile && ( this.route.hasOwnProperty('useDefaultScriptFile') || this.route.useDefaultScriptFile !== false ) ) { // Check that option is not true let scriptFile = config.loadDefaultScriptFile === true ? 'application.js' : config.loadDefaultScriptFile; $resourceLoader(scriptFile); } // Pull the response back in from wherever it was before this.content = this.response.content; // Render the template into the resoponse let me = this; return new Promise(function(resolve) { // $Compile to parse template strings and app.directives return $compile(me.template)( // In the context of the scope me.$scope ).then(function(template) { resolve(template); }); }).then(function(template) { me.response.content = me.content += template; me.response.write(me.content); }); } }
[ "function", "controllerTemplateRouteResponse", "(", ")", "{", "if", "(", "this", ".", "template", ")", "{", "let", "match", "=", "this", ".", "template", ".", "toString", "(", ")", ".", "match", "(", "/", "!doctype ([a-z]+)", "/", "i", ")", ",", "mime", ";", "// In the context where MIME type is not set, but we have a", "// DOCTYPE tag, we can force set the MIME", "// We want this here instead of the explicit template definition", "// in case the MIME failed earlier", "if", "(", "match", "&&", "!", "this", ".", "response", ".", "$headers", ".", "hasOwnProperty", "(", "'Content-Type'", ")", ")", "{", "mime", "=", "this", ".", "response", ".", "$headers", "[", "'Content-Type'", "]", "=", "$MimeType", ".", "$$", "(", "match", "[", "1", "]", ".", "toLowerCase", "(", ")", ")", ";", "}", "// Check to see if this is an HTML template and has a DOCTYPE", "// and that the proper configuration options are set", "if", "(", "mime", "===", "'text/html'", "&&", "config", ".", "loadDefaultScriptFile", "&&", "(", "this", ".", "route", ".", "hasOwnProperty", "(", "'useDefaultScriptFile'", ")", "||", "this", ".", "route", ".", "useDefaultScriptFile", "!==", "false", ")", ")", "{", "// Check that option is not true", "let", "scriptFile", "=", "config", ".", "loadDefaultScriptFile", "===", "true", "?", "'application.js'", ":", "config", ".", "loadDefaultScriptFile", ";", "$resourceLoader", "(", "scriptFile", ")", ";", "}", "// Pull the response back in from wherever it was before", "this", ".", "content", "=", "this", ".", "response", ".", "content", ";", "// Render the template into the resoponse", "let", "me", "=", "this", ";", "return", "new", "Promise", "(", "function", "(", "resolve", ")", "{", "// $Compile to parse template strings and app.directives", "return", "$compile", "(", "me", ".", "template", ")", "(", "// In the context of the scope", "me", ".", "$scope", ")", ".", "then", "(", "function", "(", "template", ")", "{", "resolve", "(", "template", ")", ";", "}", ")", ";", "}", ")", ".", "then", "(", "function", "(", "template", ")", "{", "me", ".", "response", ".", "content", "=", "me", ".", "content", "+=", "template", ";", "me", ".", "response", ".", "write", "(", "me", ".", "content", ")", ";", "}", ")", ";", "}", "}" ]
Performs the templating inside of Controller Classes
[ "Performs", "the", "templating", "inside", "of", "Controller", "Classes" ]
7d0793f6125e60e0473b17ffd40305d6d6fdbc12
https://github.com/angie-framework/angie/blob/7d0793f6125e60e0473b17ffd40305d6d6fdbc12/src/services/$Response.js#L589-L640
38,465
rootsdev/gedcomx-js
src/core/Date.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof GDate)){ return new GDate(json); } // If the given object is already an instance then just return it. DON'T copy it. if(GDate.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof GDate)){ return new GDate(json); } // If the given object is already an instance then just return it. DON'T copy it. if(GDate.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "// Protect against forgetting the new keyword when calling the constructor", "if", "(", "!", "(", "this", "instanceof", "GDate", ")", ")", "{", "return", "new", "GDate", "(", "json", ")", ";", "}", "// If the given object is already an instance then just return it. DON'T copy it.", "if", "(", "GDate", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
A date. @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#conclusion-date|GEDCOM X JSON Spec} @class @extends ExtensibleData @param {Object} [json] @alias Date
[ "A", "date", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/core/Date.js#L14-L27
38,466
SamVerschueren/gulp-cordova-icon
hooks/before_prepare/icon.js
loadProjectName
function loadProjectName(callback) { try { var contents = fs.readFileSync(path.join(__dirname, '../../config.xml'), 'utf-8'); if (contents) { // Windows is the BOM. Skip the Byte Order Mark. contents = contents.substring(contents.indexOf('<')); } var doc = new et.ElementTree(et.XML(contents)); var root = doc.getroot(); if (root.tag !== 'widget') { throw new Error('config.xml has incorrect root node name (expected "widget", was "' + root.tag + '")'); } var tag = root.find('./name'); if (!tag) { throw new Error('config.xml has no name tag.'); } return tag.text; } catch (e) { console.error('Could not loading config.xml'); throw e; } }
javascript
function loadProjectName(callback) { try { var contents = fs.readFileSync(path.join(__dirname, '../../config.xml'), 'utf-8'); if (contents) { // Windows is the BOM. Skip the Byte Order Mark. contents = contents.substring(contents.indexOf('<')); } var doc = new et.ElementTree(et.XML(contents)); var root = doc.getroot(); if (root.tag !== 'widget') { throw new Error('config.xml has incorrect root node name (expected "widget", was "' + root.tag + '")'); } var tag = root.find('./name'); if (!tag) { throw new Error('config.xml has no name tag.'); } return tag.text; } catch (e) { console.error('Could not loading config.xml'); throw e; } }
[ "function", "loadProjectName", "(", "callback", ")", "{", "try", "{", "var", "contents", "=", "fs", ".", "readFileSync", "(", "path", ".", "join", "(", "__dirname", ",", "'../../config.xml'", ")", ",", "'utf-8'", ")", ";", "if", "(", "contents", ")", "{", "// Windows is the BOM. Skip the Byte Order Mark.", "contents", "=", "contents", ".", "substring", "(", "contents", ".", "indexOf", "(", "'<'", ")", ")", ";", "}", "var", "doc", "=", "new", "et", ".", "ElementTree", "(", "et", ".", "XML", "(", "contents", ")", ")", ";", "var", "root", "=", "doc", ".", "getroot", "(", ")", ";", "if", "(", "root", ".", "tag", "!==", "'widget'", ")", "{", "throw", "new", "Error", "(", "'config.xml has incorrect root node name (expected \"widget\", was \"'", "+", "root", ".", "tag", "+", "'\")'", ")", ";", "}", "var", "tag", "=", "root", ".", "find", "(", "'./name'", ")", ";", "if", "(", "!", "tag", ")", "{", "throw", "new", "Error", "(", "'config.xml has no name tag.'", ")", ";", "}", "return", "tag", ".", "text", ";", "}", "catch", "(", "e", ")", "{", "console", ".", "error", "(", "'Could not loading config.xml'", ")", ";", "throw", "e", ";", "}", "}" ]
Loads the project name from the config.xml file. @param {Function} callback Called when the name is retrieved.
[ "Loads", "the", "project", "name", "from", "the", "config", ".", "xml", "file", "." ]
e228d4d4ccc4e3e9fbbf3f05f47a46015fc59380
https://github.com/SamVerschueren/gulp-cordova-icon/blob/e228d4d4ccc4e3e9fbbf3f05f47a46015fc59380/hooks/before_prepare/icon.js#L33-L59
38,467
SamVerschueren/gulp-cordova-icon
hooks/before_prepare/icon.js
updateConfig
function updateConfig(target) { try { var contents = fs.readFileSync(path.join(__dirname, '../../config.xml'), 'utf-8'); if (contents) { // Windows is the BOM. Skip the Byte Order Mark. contents = contents.substring(contents.indexOf('<')); } var doc = new et.ElementTree(et.XML(contents)); var root = doc.getroot(); if (root.tag !== 'widget') { throw new Error('config.xml has incorrect root node name (expected "widget", was "' + root.tag + '")'); } var platformElement = doc.find('./platform/[@name="' + target + '"]'); if (platformElement) { var icons = platformElement.findall('./icon'); for (var i=0; i<icons.length; i++) { platformElement.remove(icons[i]); } } else { platformElement = new et.Element('platform'); platformElement.attrib.name = target; doc.getroot().append(platformElement); } // Add all the icons for(var i=0; i<platforms[target].icons.length; i++) { var iconElement = new et.Element('icon'); iconElement.attrib = { ...platforms[target].icons[i].attributes, src: 'res/' + target + '/' + platforms[target].icons[i].file }; platformElement.append(iconElement); } fs.writeFileSync(path.join(__dirname, '../../config.xml'), doc.write({indent: 4}), 'utf-8'); } catch (e) { console.error('Could not load config.xml'); throw e; } }
javascript
function updateConfig(target) { try { var contents = fs.readFileSync(path.join(__dirname, '../../config.xml'), 'utf-8'); if (contents) { // Windows is the BOM. Skip the Byte Order Mark. contents = contents.substring(contents.indexOf('<')); } var doc = new et.ElementTree(et.XML(contents)); var root = doc.getroot(); if (root.tag !== 'widget') { throw new Error('config.xml has incorrect root node name (expected "widget", was "' + root.tag + '")'); } var platformElement = doc.find('./platform/[@name="' + target + '"]'); if (platformElement) { var icons = platformElement.findall('./icon'); for (var i=0; i<icons.length; i++) { platformElement.remove(icons[i]); } } else { platformElement = new et.Element('platform'); platformElement.attrib.name = target; doc.getroot().append(platformElement); } // Add all the icons for(var i=0; i<platforms[target].icons.length; i++) { var iconElement = new et.Element('icon'); iconElement.attrib = { ...platforms[target].icons[i].attributes, src: 'res/' + target + '/' + platforms[target].icons[i].file }; platformElement.append(iconElement); } fs.writeFileSync(path.join(__dirname, '../../config.xml'), doc.write({indent: 4}), 'utf-8'); } catch (e) { console.error('Could not load config.xml'); throw e; } }
[ "function", "updateConfig", "(", "target", ")", "{", "try", "{", "var", "contents", "=", "fs", ".", "readFileSync", "(", "path", ".", "join", "(", "__dirname", ",", "'../../config.xml'", ")", ",", "'utf-8'", ")", ";", "if", "(", "contents", ")", "{", "// Windows is the BOM. Skip the Byte Order Mark.", "contents", "=", "contents", ".", "substring", "(", "contents", ".", "indexOf", "(", "'<'", ")", ")", ";", "}", "var", "doc", "=", "new", "et", ".", "ElementTree", "(", "et", ".", "XML", "(", "contents", ")", ")", ";", "var", "root", "=", "doc", ".", "getroot", "(", ")", ";", "if", "(", "root", ".", "tag", "!==", "'widget'", ")", "{", "throw", "new", "Error", "(", "'config.xml has incorrect root node name (expected \"widget\", was \"'", "+", "root", ".", "tag", "+", "'\")'", ")", ";", "}", "var", "platformElement", "=", "doc", ".", "find", "(", "'./platform/[@name=\"'", "+", "target", "+", "'\"]'", ")", ";", "if", "(", "platformElement", ")", "{", "var", "icons", "=", "platformElement", ".", "findall", "(", "'./icon'", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "icons", ".", "length", ";", "i", "++", ")", "{", "platformElement", ".", "remove", "(", "icons", "[", "i", "]", ")", ";", "}", "}", "else", "{", "platformElement", "=", "new", "et", ".", "Element", "(", "'platform'", ")", ";", "platformElement", ".", "attrib", ".", "name", "=", "target", ";", "doc", ".", "getroot", "(", ")", ".", "append", "(", "platformElement", ")", ";", "}", "// Add all the icons", "for", "(", "var", "i", "=", "0", ";", "i", "<", "platforms", "[", "target", "]", ".", "icons", ".", "length", ";", "i", "++", ")", "{", "var", "iconElement", "=", "new", "et", ".", "Element", "(", "'icon'", ")", ";", "iconElement", ".", "attrib", "=", "{", "...", "platforms", "[", "target", "]", ".", "icons", "[", "i", "]", ".", "attributes", ",", "src", ":", "'res/'", "+", "target", "+", "'/'", "+", "platforms", "[", "target", "]", ".", "icons", "[", "i", "]", ".", "file", "}", ";", "platformElement", ".", "append", "(", "iconElement", ")", ";", "}", "fs", ".", "writeFileSync", "(", "path", ".", "join", "(", "__dirname", ",", "'../../config.xml'", ")", ",", "doc", ".", "write", "(", "{", "indent", ":", "4", "}", ")", ",", "'utf-8'", ")", ";", "}", "catch", "(", "e", ")", "{", "console", ".", "error", "(", "'Could not load config.xml'", ")", ";", "throw", "e", ";", "}", "}" ]
This method will update the config.xml file for the target platform. It will add the icon tags to the config file.
[ "This", "method", "will", "update", "the", "config", ".", "xml", "file", "for", "the", "target", "platform", ".", "It", "will", "add", "the", "icon", "tags", "to", "the", "config", "file", "." ]
e228d4d4ccc4e3e9fbbf3f05f47a46015fc59380
https://github.com/SamVerschueren/gulp-cordova-icon/blob/e228d4d4ccc4e3e9fbbf3f05f47a46015fc59380/hooks/before_prepare/icon.js#L65-L111
38,468
Globegitter/sails-hook-eslint
index.js
function (cb) { // If the hook has been deactivated, just return if (!sails.config[this.configKey].check) { sails.log.verbose('Eslint hook deactivated.'); return cb(); } else { var format = sails.config[this.configKey].formatter || 'stylish'; var patterns = sails.config[this.configKey].patterns || ['api', 'config']; patterns.forEach(function (pattern) { if (glob.hasMagic(pattern)) { glob.sync(pattern).forEach(function (file) { runLint(file, format); }); } else { runLint(pattern, format); } }); return cb(); } }
javascript
function (cb) { // If the hook has been deactivated, just return if (!sails.config[this.configKey].check) { sails.log.verbose('Eslint hook deactivated.'); return cb(); } else { var format = sails.config[this.configKey].formatter || 'stylish'; var patterns = sails.config[this.configKey].patterns || ['api', 'config']; patterns.forEach(function (pattern) { if (glob.hasMagic(pattern)) { glob.sync(pattern).forEach(function (file) { runLint(file, format); }); } else { runLint(pattern, format); } }); return cb(); } }
[ "function", "(", "cb", ")", "{", "// If the hook has been deactivated, just return", "if", "(", "!", "sails", ".", "config", "[", "this", ".", "configKey", "]", ".", "check", ")", "{", "sails", ".", "log", ".", "verbose", "(", "'Eslint hook deactivated.'", ")", ";", "return", "cb", "(", ")", ";", "}", "else", "{", "var", "format", "=", "sails", ".", "config", "[", "this", ".", "configKey", "]", ".", "formatter", "||", "'stylish'", ";", "var", "patterns", "=", "sails", ".", "config", "[", "this", ".", "configKey", "]", ".", "patterns", "||", "[", "'api'", ",", "'config'", "]", ";", "patterns", ".", "forEach", "(", "function", "(", "pattern", ")", "{", "if", "(", "glob", ".", "hasMagic", "(", "pattern", ")", ")", "{", "glob", ".", "sync", "(", "pattern", ")", ".", "forEach", "(", "function", "(", "file", ")", "{", "runLint", "(", "file", ",", "format", ")", ";", "}", ")", ";", "}", "else", "{", "runLint", "(", "pattern", ",", "format", ")", ";", "}", "}", ")", ";", "return", "cb", "(", ")", ";", "}", "}" ]
Initialize the hook @param {Function} cb Callback for when we're done initializing
[ "Initialize", "the", "hook" ]
0e3c91a234e8514313e33662620d0006836ec78d
https://github.com/Globegitter/sails-hook-eslint/blob/0e3c91a234e8514313e33662620d0006836ec78d/index.js#L58-L83
38,469
Bartvds/gruntfile-gtx
lib/lib.js
getParamAccessor
function getParamAccessor(id, params) { // easy access var paramGet = function (prop, alt, required) { if (arguments.length < 1) { throw (new Error('expected at least 1 argument')); } if (arguments.length < 2) { required = true; } if (params && hasOwnProp(params, prop)) { return params[prop]; } if (required) { if (!params) { throw (new Error('no params supplied for: ' + id)); } throw (new Error('missing param property: ' + prop + ' in: ' + id)); } return alt; }; paramGet.raw = params; return paramGet; }
javascript
function getParamAccessor(id, params) { // easy access var paramGet = function (prop, alt, required) { if (arguments.length < 1) { throw (new Error('expected at least 1 argument')); } if (arguments.length < 2) { required = true; } if (params && hasOwnProp(params, prop)) { return params[prop]; } if (required) { if (!params) { throw (new Error('no params supplied for: ' + id)); } throw (new Error('missing param property: ' + prop + ' in: ' + id)); } return alt; }; paramGet.raw = params; return paramGet; }
[ "function", "getParamAccessor", "(", "id", ",", "params", ")", "{", "// easy access", "var", "paramGet", "=", "function", "(", "prop", ",", "alt", ",", "required", ")", "{", "if", "(", "arguments", ".", "length", "<", "1", ")", "{", "throw", "(", "new", "Error", "(", "'expected at least 1 argument'", ")", ")", ";", "}", "if", "(", "arguments", ".", "length", "<", "2", ")", "{", "required", "=", "true", ";", "}", "if", "(", "params", "&&", "hasOwnProp", "(", "params", ",", "prop", ")", ")", "{", "return", "params", "[", "prop", "]", ";", "}", "if", "(", "required", ")", "{", "if", "(", "!", "params", ")", "{", "throw", "(", "new", "Error", "(", "'no params supplied for: '", "+", "id", ")", ")", ";", "}", "throw", "(", "new", "Error", "(", "'missing param property: '", "+", "prop", "+", "' in: '", "+", "id", ")", ")", ";", "}", "return", "alt", ";", "}", ";", "paramGet", ".", "raw", "=", "params", ";", "return", "paramGet", ";", "}" ]
return a parameter accessor
[ "return", "a", "parameter", "accessor" ]
90ac642769189ad6be7886b83f1e0c55d350e873
https://github.com/Bartvds/gruntfile-gtx/blob/90ac642769189ad6be7886b83f1e0c55d350e873/lib/lib.js#L6-L28
38,470
ember-cli/broccoli-es6modules
index.js
function(inDir, outDir){ var name = this.bundleOptions.name; var opts = this._generateEsperantoOptions(name); var transpilerName = formatToFunctionName[this.format]; var targetExtension = this.targetExtension; return esperanto.bundle({ base: inDir, entry: this.bundleOptions.entry }).then(function(bundle) { var compiledModule = bundle[transpilerName](opts); var fullOutputPath = path.join(outDir, name + '.' + targetExtension); return writeFile(fullOutputPath, compiledModule.code); }); }
javascript
function(inDir, outDir){ var name = this.bundleOptions.name; var opts = this._generateEsperantoOptions(name); var transpilerName = formatToFunctionName[this.format]; var targetExtension = this.targetExtension; return esperanto.bundle({ base: inDir, entry: this.bundleOptions.entry }).then(function(bundle) { var compiledModule = bundle[transpilerName](opts); var fullOutputPath = path.join(outDir, name + '.' + targetExtension); return writeFile(fullOutputPath, compiledModule.code); }); }
[ "function", "(", "inDir", ",", "outDir", ")", "{", "var", "name", "=", "this", ".", "bundleOptions", ".", "name", ";", "var", "opts", "=", "this", ".", "_generateEsperantoOptions", "(", "name", ")", ";", "var", "transpilerName", "=", "formatToFunctionName", "[", "this", ".", "format", "]", ";", "var", "targetExtension", "=", "this", ".", "targetExtension", ";", "return", "esperanto", ".", "bundle", "(", "{", "base", ":", "inDir", ",", "entry", ":", "this", ".", "bundleOptions", ".", "entry", "}", ")", ".", "then", "(", "function", "(", "bundle", ")", "{", "var", "compiledModule", "=", "bundle", "[", "transpilerName", "]", "(", "opts", ")", ";", "var", "fullOutputPath", "=", "path", ".", "join", "(", "outDir", ",", "name", "+", "'.'", "+", "targetExtension", ")", ";", "return", "writeFile", "(", "fullOutputPath", ",", "compiledModule", ".", "code", ")", ";", "}", ")", ";", "}" ]
A hook called if ES6Modules is being used in a n-to-1 bundle. Begins importing at an entry point and adds a single bundled module to the output tree.
[ "A", "hook", "called", "if", "ES6Modules", "is", "being", "used", "in", "a", "n", "-", "to", "-", "1", "bundle", "." ]
398d2e901687497a9eaab32a6ecb008b4e587230
https://github.com/ember-cli/broccoli-es6modules/blob/398d2e901687497a9eaab32a6ecb008b4e587230/index.js#L151-L166
38,471
ember-cli/broccoli-es6modules
index.js
function(inDir, outDir, relativePath, newCache) { var ext = this._matchingFileExtension(relativePath); var moduleName = relativePath.slice(0, relativePath.length - (ext.length + 1)); var fullInputPath = path.join(inDir, relativePath); var fullOutputPath = path.join(outDir, moduleName + '.' + this.targetExtension); var entry = this._transpileThroughCache( moduleName, fs.readFileSync(fullInputPath, 'utf-8'), newCache ); mkdirp.sync(path.dirname(fullOutputPath)); fs.writeFileSync(fullOutputPath, entry.output); }
javascript
function(inDir, outDir, relativePath, newCache) { var ext = this._matchingFileExtension(relativePath); var moduleName = relativePath.slice(0, relativePath.length - (ext.length + 1)); var fullInputPath = path.join(inDir, relativePath); var fullOutputPath = path.join(outDir, moduleName + '.' + this.targetExtension); var entry = this._transpileThroughCache( moduleName, fs.readFileSync(fullInputPath, 'utf-8'), newCache ); mkdirp.sync(path.dirname(fullOutputPath)); fs.writeFileSync(fullOutputPath, entry.output); }
[ "function", "(", "inDir", ",", "outDir", ",", "relativePath", ",", "newCache", ")", "{", "var", "ext", "=", "this", ".", "_matchingFileExtension", "(", "relativePath", ")", ";", "var", "moduleName", "=", "relativePath", ".", "slice", "(", "0", ",", "relativePath", ".", "length", "-", "(", "ext", ".", "length", "+", "1", ")", ")", ";", "var", "fullInputPath", "=", "path", ".", "join", "(", "inDir", ",", "relativePath", ")", ";", "var", "fullOutputPath", "=", "path", ".", "join", "(", "outDir", ",", "moduleName", "+", "'.'", "+", "this", ".", "targetExtension", ")", ";", "var", "entry", "=", "this", ".", "_transpileThroughCache", "(", "moduleName", ",", "fs", ".", "readFileSync", "(", "fullInputPath", ",", "'utf-8'", ")", ",", "newCache", ")", ";", "mkdirp", ".", "sync", "(", "path", ".", "dirname", "(", "fullOutputPath", ")", ")", ";", "fs", ".", "writeFileSync", "(", "fullOutputPath", ",", "entry", ".", "output", ")", ";", "}" ]
Normalizes module name, input path, and output path then calls transpileThroughCache to get a transpiled version of the ES6 source.
[ "Normalizes", "module", "name", "input", "path", "and", "output", "path", "then", "calls", "transpileThroughCache", "to", "get", "a", "transpiled", "version", "of", "the", "ES6", "source", "." ]
398d2e901687497a9eaab32a6ecb008b4e587230
https://github.com/ember-cli/broccoli-es6modules/blob/398d2e901687497a9eaab32a6ecb008b4e587230/index.js#L199-L213
38,472
ember-cli/broccoli-es6modules
index.js
function(moduleName, source, newCache) { var key = helpers.hashStrings([moduleName, source]); var entry = this._transpilerCache[key]; if (entry) { return newCache[key] = entry; } try { return newCache[key] = { output: this.toFormat( source, this._generateEsperantoOptions(moduleName) ).code }; } catch(err) { err.file = moduleName; throw err; } }
javascript
function(moduleName, source, newCache) { var key = helpers.hashStrings([moduleName, source]); var entry = this._transpilerCache[key]; if (entry) { return newCache[key] = entry; } try { return newCache[key] = { output: this.toFormat( source, this._generateEsperantoOptions(moduleName) ).code }; } catch(err) { err.file = moduleName; throw err; } }
[ "function", "(", "moduleName", ",", "source", ",", "newCache", ")", "{", "var", "key", "=", "helpers", ".", "hashStrings", "(", "[", "moduleName", ",", "source", "]", ")", ";", "var", "entry", "=", "this", ".", "_transpilerCache", "[", "key", "]", ";", "if", "(", "entry", ")", "{", "return", "newCache", "[", "key", "]", "=", "entry", ";", "}", "try", "{", "return", "newCache", "[", "key", "]", "=", "{", "output", ":", "this", ".", "toFormat", "(", "source", ",", "this", ".", "_generateEsperantoOptions", "(", "moduleName", ")", ")", ".", "code", "}", ";", "}", "catch", "(", "err", ")", "{", "err", ".", "file", "=", "moduleName", ";", "throw", "err", ";", "}", "}" ]
Called on every file in a tree when used in per-file mode. First this checks whether the file contents have been previously transpiled by checking the previous cache. If the file has been transpiled, adds the previous transpiled code into the new cache. If it has not been transpiled it adds passed the source code along to a transpiler and adds the resulting value to the new cache.
[ "Called", "on", "every", "file", "in", "a", "tree", "when", "used", "in", "per", "-", "file", "mode", "." ]
398d2e901687497a9eaab32a6ecb008b4e587230
https://github.com/ember-cli/broccoli-es6modules/blob/398d2e901687497a9eaab32a6ecb008b4e587230/index.js#L224-L242
38,473
blendsdk/blend-class-system
examples/hello-world/Hello/app/Greeter.js
function () { var me = this; me.callParent.apply(me, arguments); me.entity = me.entity || 'Someone'; }
javascript
function () { var me = this; me.callParent.apply(me, arguments); me.entity = me.entity || 'Someone'; }
[ "function", "(", ")", "{", "var", "me", "=", "this", ";", "me", ".", "callParent", ".", "apply", "(", "me", ",", "arguments", ")", ";", "me", ".", "entity", "=", "me", ".", "entity", "||", "'Someone'", ";", "}" ]
Constructor example. Don't forget to call the parent constructor
[ "Constructor", "example", ".", "Don", "t", "forget", "to", "call", "the", "parent", "constructor" ]
d6eb82c0305d8f4d17c925b8420654fe8271c590
https://github.com/blendsdk/blend-class-system/blob/d6eb82c0305d8f4d17c925b8420654fe8271c590/examples/hello-world/Hello/app/Greeter.js#L10-L14
38,474
rootsdev/gedcomx-js
src/core/TextValue.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof TextValue)){ return new TextValue(json); } // If the given object is already an instance then just return it. DON'T copy it. if(TextValue.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof TextValue)){ return new TextValue(json); } // If the given object is already an instance then just return it. DON'T copy it. if(TextValue.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "// Protect against forgetting the new keyword when calling the constructor", "if", "(", "!", "(", "this", "instanceof", "TextValue", ")", ")", "{", "return", "new", "TextValue", "(", "json", ")", ";", "}", "// If the given object is already an instance then just return it. DON'T copy it.", "if", "(", "TextValue", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
A text value in a specific language. @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#text-value|GEDCOM X JSON Spec} @class @extends Base @apram {Object} [json]
[ "A", "text", "value", "in", "a", "specific", "language", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/core/TextValue.js#L13-L26
38,475
amrdraz/java-code-runner
index.js
runProc
function runProc(args, cb) { var stoutBuffer = '', sterrBuffer = ''; var proc = cp.spawn('java', args, { cwd: config.rootDir + '/bin' }); proc.stdout.on('data', function(data) { stoutBuffer += data; }); proc.stderr.on('data', function(data) { sterrBuffer += data; }); proc.on('close', function(code) { if (code === null) { cb(code); } else { cb(null, stoutBuffer, sterrBuffer); } running--; }); }
javascript
function runProc(args, cb) { var stoutBuffer = '', sterrBuffer = ''; var proc = cp.spawn('java', args, { cwd: config.rootDir + '/bin' }); proc.stdout.on('data', function(data) { stoutBuffer += data; }); proc.stderr.on('data', function(data) { sterrBuffer += data; }); proc.on('close', function(code) { if (code === null) { cb(code); } else { cb(null, stoutBuffer, sterrBuffer); } running--; }); }
[ "function", "runProc", "(", "args", ",", "cb", ")", "{", "var", "stoutBuffer", "=", "''", ",", "sterrBuffer", "=", "''", ";", "var", "proc", "=", "cp", ".", "spawn", "(", "'java'", ",", "args", ",", "{", "cwd", ":", "config", ".", "rootDir", "+", "'/bin'", "}", ")", ";", "proc", ".", "stdout", ".", "on", "(", "'data'", ",", "function", "(", "data", ")", "{", "stoutBuffer", "+=", "data", ";", "}", ")", ";", "proc", ".", "stderr", ".", "on", "(", "'data'", ",", "function", "(", "data", ")", "{", "sterrBuffer", "+=", "data", ";", "}", ")", ";", "proc", ".", "on", "(", "'close'", ",", "function", "(", "code", ")", "{", "if", "(", "code", "===", "null", ")", "{", "cb", "(", "code", ")", ";", "}", "else", "{", "cb", "(", "null", ",", "stoutBuffer", ",", "sterrBuffer", ")", ";", "}", "running", "--", ";", "}", ")", ";", "}" ]
Spawn a java process and return callback @param {Array} args arguments to pass to java proc @param {Function} cb callback to be called with err, stout, sterr
[ "Spawn", "a", "java", "process", "and", "return", "callback" ]
b5d87b503076bf76a01d111b85c18a639e6f80c8
https://github.com/amrdraz/java-code-runner/blob/b5d87b503076bf76a01d111b85c18a639e6f80c8/index.js#L56-L76
38,476
amrdraz/java-code-runner
index.js
runCMD
function runCMD(options, cb) { if (options.cb) { cb = options.cb; } var args = ["-cp", ".", "-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1", "TerminalRunner"]; args.push(options.name); args.push(options.program); args.push(options.timeLimit); args.push(options.input); runProc(args, function() { observer.emit("runner.finished", options); cb.apply(this, arguments); }); }
javascript
function runCMD(options, cb) { if (options.cb) { cb = options.cb; } var args = ["-cp", ".", "-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1", "TerminalRunner"]; args.push(options.name); args.push(options.program); args.push(options.timeLimit); args.push(options.input); runProc(args, function() { observer.emit("runner.finished", options); cb.apply(this, arguments); }); }
[ "function", "runCMD", "(", "options", ",", "cb", ")", "{", "if", "(", "options", ".", "cb", ")", "{", "cb", "=", "options", ".", "cb", ";", "}", "var", "args", "=", "[", "\"-cp\"", ",", "\".\"", ",", "\"-XX:+TieredCompilation\"", ",", "\"-XX:TieredStopAtLevel=1\"", ",", "\"TerminalRunner\"", "]", ";", "args", ".", "push", "(", "options", ".", "name", ")", ";", "args", ".", "push", "(", "options", ".", "program", ")", ";", "args", ".", "push", "(", "options", ".", "timeLimit", ")", ";", "args", ".", "push", "(", "options", ".", "input", ")", ";", "runProc", "(", "args", ",", "function", "(", ")", "{", "observer", ".", "emit", "(", "\"runner.finished\"", ",", "options", ")", ";", "cb", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ")", ";", "}" ]
Run java program in TerminalRunner @param {Object} options an object containing all prgram needed configuration - {String} name name of class - {String} program source code of JavaClass with public class [name] - {String} input The program's input stream if needed @param {Function} cb callback when complete
[ "Run", "java", "program", "in", "TerminalRunner" ]
b5d87b503076bf76a01d111b85c18a639e6f80c8
https://github.com/amrdraz/java-code-runner/blob/b5d87b503076bf76a01d111b85c18a639e6f80c8/index.js#L86-L101
38,477
amrdraz/java-code-runner
index.js
runInServlet
function runInServlet(request, cb) { // log("waitingQueue:"+waitingQueue.length+", runningQueue:"+runningQueue.length); // log("pushed into running"); if (request.cb) { cb = request.cb; } // program to run var post_data = querystring.stringify({ 'name': request.name, 'code': request.program, 'input': request.input, 'timeLimit': request.timeLimit }); // An object of request to indicate where to post to var post_options = { host: '127.0.0.1', port: server.getPort(), path: '', method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': post_data.length } }; var post_req = http.request(post_options, function(res) { res.setEncoding('utf8'); var responseString = ''; res.on('data', function(data) { // clearTimeout(request.timer); // log(data); // debugger; if (/An exception has occurred in the compiler/.test(data) || /RuntimeError: java.lang.ThreadDeath/.test(data)) { // log("ReWrote the folwoing as timout exception "+data); // queue.checkQueues(); request.timeOut(); } else { data = JSON.parse(data); request.setToDone(); observer.emit("runner.finished", request); // queue.clearRunning(); // queue.checkQueues(); cb(null, data.stout, data.sterr); } // log("finished with one"); }); // res.on('end', function() { // log('::-----end-----::'); // var data = JSON.parse(responseString); // log(responseString); // log('::-----end-----::'); // cb(null, data.stout, data.sterr); // }); }); post_req.on('error', function(e) { log("Error while waiting for server response ", e); request.timeOut(); // cb(e); }); // request.timer = setTimeout(function () { // cb(null, "","TimeoutException: Your program ran for more than "+timeLimit+"ms"); // },timeLimit+200); post_req.write(post_data); post_req.end(); }
javascript
function runInServlet(request, cb) { // log("waitingQueue:"+waitingQueue.length+", runningQueue:"+runningQueue.length); // log("pushed into running"); if (request.cb) { cb = request.cb; } // program to run var post_data = querystring.stringify({ 'name': request.name, 'code': request.program, 'input': request.input, 'timeLimit': request.timeLimit }); // An object of request to indicate where to post to var post_options = { host: '127.0.0.1', port: server.getPort(), path: '', method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': post_data.length } }; var post_req = http.request(post_options, function(res) { res.setEncoding('utf8'); var responseString = ''; res.on('data', function(data) { // clearTimeout(request.timer); // log(data); // debugger; if (/An exception has occurred in the compiler/.test(data) || /RuntimeError: java.lang.ThreadDeath/.test(data)) { // log("ReWrote the folwoing as timout exception "+data); // queue.checkQueues(); request.timeOut(); } else { data = JSON.parse(data); request.setToDone(); observer.emit("runner.finished", request); // queue.clearRunning(); // queue.checkQueues(); cb(null, data.stout, data.sterr); } // log("finished with one"); }); // res.on('end', function() { // log('::-----end-----::'); // var data = JSON.parse(responseString); // log(responseString); // log('::-----end-----::'); // cb(null, data.stout, data.sterr); // }); }); post_req.on('error', function(e) { log("Error while waiting for server response ", e); request.timeOut(); // cb(e); }); // request.timer = setTimeout(function () { // cb(null, "","TimeoutException: Your program ran for more than "+timeLimit+"ms"); // },timeLimit+200); post_req.write(post_data); post_req.end(); }
[ "function", "runInServlet", "(", "request", ",", "cb", ")", "{", "// log(\"waitingQueue:\"+waitingQueue.length+\", runningQueue:\"+runningQueue.length);", "// log(\"pushed into running\");", "if", "(", "request", ".", "cb", ")", "{", "cb", "=", "request", ".", "cb", ";", "}", "// program to run", "var", "post_data", "=", "querystring", ".", "stringify", "(", "{", "'name'", ":", "request", ".", "name", ",", "'code'", ":", "request", ".", "program", ",", "'input'", ":", "request", ".", "input", ",", "'timeLimit'", ":", "request", ".", "timeLimit", "}", ")", ";", "// An object of request to indicate where to post to", "var", "post_options", "=", "{", "host", ":", "'127.0.0.1'", ",", "port", ":", "server", ".", "getPort", "(", ")", ",", "path", ":", "''", ",", "method", ":", "'POST'", ",", "headers", ":", "{", "'Content-Type'", ":", "'application/x-www-form-urlencoded'", ",", "'Content-Length'", ":", "post_data", ".", "length", "}", "}", ";", "var", "post_req", "=", "http", ".", "request", "(", "post_options", ",", "function", "(", "res", ")", "{", "res", ".", "setEncoding", "(", "'utf8'", ")", ";", "var", "responseString", "=", "''", ";", "res", ".", "on", "(", "'data'", ",", "function", "(", "data", ")", "{", "// clearTimeout(request.timer);", "// log(data);", "// debugger;", "if", "(", "/", "An exception has occurred in the compiler", "/", ".", "test", "(", "data", ")", "||", "/", "RuntimeError: java.lang.ThreadDeath", "/", ".", "test", "(", "data", ")", ")", "{", "// log(\"ReWrote the folwoing as timout exception \"+data);", "// queue.checkQueues();", "request", ".", "timeOut", "(", ")", ";", "}", "else", "{", "data", "=", "JSON", ".", "parse", "(", "data", ")", ";", "request", ".", "setToDone", "(", ")", ";", "observer", ".", "emit", "(", "\"runner.finished\"", ",", "request", ")", ";", "// queue.clearRunning();", "// queue.checkQueues();", "cb", "(", "null", ",", "data", ".", "stout", ",", "data", ".", "sterr", ")", ";", "}", "// log(\"finished with one\");", "}", ")", ";", "// res.on('end', function() {", "// log('::-----end-----::');", "// var data = JSON.parse(responseString);", "// log(responseString);", "// log('::-----end-----::');", "// cb(null, data.stout, data.sterr);", "// });", "}", ")", ";", "post_req", ".", "on", "(", "'error'", ",", "function", "(", "e", ")", "{", "log", "(", "\"Error while waiting for server response \"", ",", "e", ")", ";", "request", ".", "timeOut", "(", ")", ";", "// cb(e);", "}", ")", ";", "// request.timer = setTimeout(function () {", "// cb(null, \"\",\"TimeoutException: Your program ran for more than \"+timeLimit+\"ms\");", "// },timeLimit+200);", "post_req", ".", "write", "(", "post_data", ")", ";", "post_req", ".", "end", "(", ")", ";", "}" ]
Run java program in server, which is singnificantly faster then CMD @param {Object} options an object containing all prgram needed configuration - {String} name name of class - {String} program source code of JavaClass with public class [name] - {String} input The program's input stream if needed @param {Function} cb callback when complete
[ "Run", "java", "program", "in", "server", "which", "is", "singnificantly", "faster", "then", "CMD" ]
b5d87b503076bf76a01d111b85c18a639e6f80c8
https://github.com/amrdraz/java-code-runner/blob/b5d87b503076bf76a01d111b85c18a639e6f80c8/index.js#L111-L179
38,478
amrdraz/java-code-runner
index.js
classCase
function classCase(input) { return input.toUpperCase().replace(/[\-\s](.)/g, function(match, group1) { return group1.toUpperCase(); }); }
javascript
function classCase(input) { return input.toUpperCase().replace(/[\-\s](.)/g, function(match, group1) { return group1.toUpperCase(); }); }
[ "function", "classCase", "(", "input", ")", "{", "return", "input", ".", "toUpperCase", "(", ")", ".", "replace", "(", "/", "[\\-\\s](.)", "/", "g", ",", "function", "(", "match", ",", "group1", ")", "{", "return", "group1", ".", "toUpperCase", "(", ")", ";", "}", ")", ";", "}" ]
Turn a sting to Java class style camel Case striping - and space chracters @param {[type]} input [description] @return {[type]} [description]
[ "Turn", "a", "sting", "to", "Java", "class", "style", "camel", "Case", "striping", "-", "and", "space", "chracters" ]
b5d87b503076bf76a01d111b85c18a639e6f80c8
https://github.com/amrdraz/java-code-runner/blob/b5d87b503076bf76a01d111b85c18a639e6f80c8/index.js#L380-L384
38,479
rootsdev/gedcomx-js
src/Base.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Base)){ return new Base(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Base.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Base)){ return new Base(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Base.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "// Protect against forgetting the new keyword when calling the constructor", "if", "(", "!", "(", "this", "instanceof", "Base", ")", ")", "{", "return", "new", "Base", "(", "json", ")", ";", "}", "// If the given object is already an instance then just return it. DON'T copy it.", "if", "(", "Base", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
Base prototype that all other classes in this library extend @class @param {Object} [json]
[ "Base", "prototype", "that", "all", "other", "classes", "in", "this", "library", "extend" ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/Base.js#L9-L22
38,480
wrwrwr/babel-remove-props
dist/main.es5.js
enter
function enter(path, state) { regex = state.opts.regex; if (!regex) { throw new TypeError("A regex option is required."); } pure = function pure(n) { return (0, _sideEffectsSafe.pureBabylon)(n, state.opts); }; }
javascript
function enter(path, state) { regex = state.opts.regex; if (!regex) { throw new TypeError("A regex option is required."); } pure = function pure(n) { return (0, _sideEffectsSafe.pureBabylon)(n, state.opts); }; }
[ "function", "enter", "(", "path", ",", "state", ")", "{", "regex", "=", "state", ".", "opts", ".", "regex", ";", "if", "(", "!", "regex", ")", "{", "throw", "new", "TypeError", "(", "\"A regex option is required.\"", ")", ";", "}", "pure", "=", "function", "pure", "(", "n", ")", "{", "return", "(", "0", ",", "_sideEffectsSafe", ".", "pureBabylon", ")", "(", "n", ",", "state", ".", "opts", ")", ";", "}", ";", "}" ]
Preprocess options.
[ "Preprocess", "options", "." ]
37e0d759a9e6f2d4838f93231abe95f3dcb701ed
https://github.com/wrwrwr/babel-remove-props/blob/37e0d759a9e6f2d4838f93231abe95f3dcb701ed/dist/main.es5.js#L35-L43
38,481
fanout/node-fanoutpub
lib/fanoutpub.js
function(realm, key, ssl) { // Initialize with a specified realm, key, and a boolean indicating wther // SSL should be enabled or disabled. var scheme = 'https'; if (typeof ssl !== 'undefined' && !ssl) { scheme = 'http'; } var uri = scheme + '://api.fanout.io/realm/' + realm; var pubControl = new pubcontrol.PubControlClient(uri); pubControl.setAuthJwt({'iss': realm}, new Buffer(key, 'base64')); this.pubControl = pubControl; }
javascript
function(realm, key, ssl) { // Initialize with a specified realm, key, and a boolean indicating wther // SSL should be enabled or disabled. var scheme = 'https'; if (typeof ssl !== 'undefined' && !ssl) { scheme = 'http'; } var uri = scheme + '://api.fanout.io/realm/' + realm; var pubControl = new pubcontrol.PubControlClient(uri); pubControl.setAuthJwt({'iss': realm}, new Buffer(key, 'base64')); this.pubControl = pubControl; }
[ "function", "(", "realm", ",", "key", ",", "ssl", ")", "{", "// Initialize with a specified realm, key, and a boolean indicating wther", "// SSL should be enabled or disabled.", "var", "scheme", "=", "'https'", ";", "if", "(", "typeof", "ssl", "!==", "'undefined'", "&&", "!", "ssl", ")", "{", "scheme", "=", "'http'", ";", "}", "var", "uri", "=", "scheme", "+", "'://api.fanout.io/realm/'", "+", "realm", ";", "var", "pubControl", "=", "new", "pubcontrol", ".", "PubControlClient", "(", "uri", ")", ";", "pubControl", ".", "setAuthJwt", "(", "{", "'iss'", ":", "realm", "}", ",", "new", "Buffer", "(", "key", ",", "'base64'", ")", ")", ";", "this", ".", "pubControl", "=", "pubControl", ";", "}" ]
The Fanout class is used for publishing messages to Fanout.io and is configured with a Fanout.io realm and associated key. SSL can either be enabled or disabled.
[ "The", "Fanout", "class", "is", "used", "for", "publishing", "messages", "to", "Fanout", ".", "io", "and", "is", "configured", "with", "a", "Fanout", ".", "io", "realm", "and", "associated", "key", ".", "SSL", "can", "either", "be", "enabled", "or", "disabled", "." ]
726ca2f928385358ee095ea3ceb29c6cd32e80eb
https://github.com/fanout/node-fanoutpub/blob/726ca2f928385358ee095ea3ceb29c6cd32e80eb/lib/fanoutpub.js#L22-L34
38,482
keqingrong/react-iframe
packages/iframe-utils/src/index.js
buildOrigin
function buildOrigin(src, href) { try { const url = new URL(src, href || location.href); return url.origin; } catch (error) { return null; } }
javascript
function buildOrigin(src, href) { try { const url = new URL(src, href || location.href); return url.origin; } catch (error) { return null; } }
[ "function", "buildOrigin", "(", "src", ",", "href", ")", "{", "try", "{", "const", "url", "=", "new", "URL", "(", "src", ",", "href", "||", "location", ".", "href", ")", ";", "return", "url", ".", "origin", ";", "}", "catch", "(", "error", ")", "{", "return", "null", ";", "}", "}" ]
Build origin from URL string. @param {string} src - URL string @param {string} [href] - URL string @returns {string|null}
[ "Build", "origin", "from", "URL", "string", "." ]
9ebfa116fc97c9ecf8d4d5968ca5f851f21acb74
https://github.com/keqingrong/react-iframe/blob/9ebfa116fc97c9ecf8d4d5968ca5f851f21acb74/packages/iframe-utils/src/index.js#L13-L20
38,483
keqingrong/react-iframe
packages/iframe-utils/src/index.js
checkOlderIE
function checkOlderIE() { const ua = navigator.userAgent; const isIE = ua.indexOf('MSIE') !== -1 || ua.indexOf('Trident') !== -1; if (!isIE) { return false; } const version = ua.match(/(MSIE\s|Trident.*rv:)([\w.]+)/)[2]; const versionNumber = parseFloat(version); if (versionNumber < 10) { return true; } return false; }
javascript
function checkOlderIE() { const ua = navigator.userAgent; const isIE = ua.indexOf('MSIE') !== -1 || ua.indexOf('Trident') !== -1; if (!isIE) { return false; } const version = ua.match(/(MSIE\s|Trident.*rv:)([\w.]+)/)[2]; const versionNumber = parseFloat(version); if (versionNumber < 10) { return true; } return false; }
[ "function", "checkOlderIE", "(", ")", "{", "const", "ua", "=", "navigator", ".", "userAgent", ";", "const", "isIE", "=", "ua", ".", "indexOf", "(", "'MSIE'", ")", "!==", "-", "1", "||", "ua", ".", "indexOf", "(", "'Trident'", ")", "!==", "-", "1", ";", "if", "(", "!", "isIE", ")", "{", "return", "false", ";", "}", "const", "version", "=", "ua", ".", "match", "(", "/", "(MSIE\\s|Trident.*rv:)([\\w.]+)", "/", ")", "[", "2", "]", ";", "const", "versionNumber", "=", "parseFloat", "(", "version", ")", ";", "if", "(", "versionNumber", "<", "10", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if it is IE below 10. @returns {boolean}
[ "Check", "if", "it", "is", "IE", "below", "10", "." ]
9ebfa116fc97c9ecf8d4d5968ca5f851f21acb74
https://github.com/keqingrong/react-iframe/blob/9ebfa116fc97c9ecf8d4d5968ca5f851f21acb74/packages/iframe-utils/src/index.js#L47-L59
38,484
rootsdev/gedcomx-js
src/atom/AtomPerson.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof AtomPerson)){ return new AtomPerson(json); } // If the given object is already an instance then just return it. DON'T copy it. if(AtomPerson.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof AtomPerson)){ return new AtomPerson(json); } // If the given object is already an instance then just return it. DON'T copy it. if(AtomPerson.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "// Protect against forgetting the new keyword when calling the constructor", "if", "(", "!", "(", "this", "instanceof", "AtomPerson", ")", ")", "{", "return", "new", "AtomPerson", "(", "json", ")", ";", "}", "// If the given object is already an instance then just return it. DON'T copy it.", "if", "(", "AtomPerson", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
Common schema for atom authors and contributors. @see {@link https://github.com/FamilySearch/gedcomx-rs/blob/master/specifications/atom-model-specification.md#atom-json-media-type|GEDCOM X Atom JSON Spec} @see {@link https://tools.ietf.org/html/rfc4287#appendix-B|RFC 4287} @class AtomPerson @extends AtomCommon @param {Object} [json]
[ "Common", "schema", "for", "atom", "authors", "and", "contributors", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/atom/AtomPerson.js#L16-L29
38,485
mikolalysenko/poly-to-pslg
poly-to-pslg.js
polygonToPSLG
function polygonToPSLG(loops, options) { if(!Array.isArray(loops)) { throw new Error('poly-to-pslg: Error, invalid polygon') } if(loops.length === 0) { return { points: [], edges: [] } } options = options || {} var nested = true if('nested' in options) { nested = !!options.nested } else if(loops[0].length === 2 && typeof loops[0][0] === 'number') { //Hack: If use doesn't pass in a loop, then try to guess if it is nested nested = false } if(!nested) { loops = [loops] } //First we just unroll all the points in the dumb/obvious way var points = [] var edges = [] for(var i=0; i<loops.length; ++i) { var loop = loops[i] var offset = points.length for(var j=0; j<loop.length; ++j) { points.push(loop[j]) edges.push([ offset+j, offset+(j+1)%loop.length ]) } } //Then we run snap rounding to clean up self intersections and duplicate verts var clean = 'clean' in options ? true : !!options.clean if(clean) { cleanPSLG(points, edges) } //Finally, we return the resulting PSLG return { points: points, edges: edges } }
javascript
function polygonToPSLG(loops, options) { if(!Array.isArray(loops)) { throw new Error('poly-to-pslg: Error, invalid polygon') } if(loops.length === 0) { return { points: [], edges: [] } } options = options || {} var nested = true if('nested' in options) { nested = !!options.nested } else if(loops[0].length === 2 && typeof loops[0][0] === 'number') { //Hack: If use doesn't pass in a loop, then try to guess if it is nested nested = false } if(!nested) { loops = [loops] } //First we just unroll all the points in the dumb/obvious way var points = [] var edges = [] for(var i=0; i<loops.length; ++i) { var loop = loops[i] var offset = points.length for(var j=0; j<loop.length; ++j) { points.push(loop[j]) edges.push([ offset+j, offset+(j+1)%loop.length ]) } } //Then we run snap rounding to clean up self intersections and duplicate verts var clean = 'clean' in options ? true : !!options.clean if(clean) { cleanPSLG(points, edges) } //Finally, we return the resulting PSLG return { points: points, edges: edges } }
[ "function", "polygonToPSLG", "(", "loops", ",", "options", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "loops", ")", ")", "{", "throw", "new", "Error", "(", "'poly-to-pslg: Error, invalid polygon'", ")", "}", "if", "(", "loops", ".", "length", "===", "0", ")", "{", "return", "{", "points", ":", "[", "]", ",", "edges", ":", "[", "]", "}", "}", "options", "=", "options", "||", "{", "}", "var", "nested", "=", "true", "if", "(", "'nested'", "in", "options", ")", "{", "nested", "=", "!", "!", "options", ".", "nested", "}", "else", "if", "(", "loops", "[", "0", "]", ".", "length", "===", "2", "&&", "typeof", "loops", "[", "0", "]", "[", "0", "]", "===", "'number'", ")", "{", "//Hack: If use doesn't pass in a loop, then try to guess if it is nested", "nested", "=", "false", "}", "if", "(", "!", "nested", ")", "{", "loops", "=", "[", "loops", "]", "}", "//First we just unroll all the points in the dumb/obvious way", "var", "points", "=", "[", "]", "var", "edges", "=", "[", "]", "for", "(", "var", "i", "=", "0", ";", "i", "<", "loops", ".", "length", ";", "++", "i", ")", "{", "var", "loop", "=", "loops", "[", "i", "]", "var", "offset", "=", "points", ".", "length", "for", "(", "var", "j", "=", "0", ";", "j", "<", "loop", ".", "length", ";", "++", "j", ")", "{", "points", ".", "push", "(", "loop", "[", "j", "]", ")", "edges", ".", "push", "(", "[", "offset", "+", "j", ",", "offset", "+", "(", "j", "+", "1", ")", "%", "loop", ".", "length", "]", ")", "}", "}", "//Then we run snap rounding to clean up self intersections and duplicate verts", "var", "clean", "=", "'clean'", "in", "options", "?", "true", ":", "!", "!", "options", ".", "clean", "if", "(", "clean", ")", "{", "cleanPSLG", "(", "points", ",", "edges", ")", "}", "//Finally, we return the resulting PSLG", "return", "{", "points", ":", "points", ",", "edges", ":", "edges", "}", "}" ]
Converts a polygon to a planar straight line graph
[ "Converts", "a", "polygon", "to", "a", "planar", "straight", "line", "graph" ]
186c2e164049009d2d89078d83065f3f7c86b182
https://github.com/mikolalysenko/poly-to-pslg/blob/186c2e164049009d2d89078d83065f3f7c86b182/poly-to-pslg.js#L8-L55
38,486
JS-DevTools/sourcemapify
lib/index.js
sourcemapify
function sourcemapify (browserify, options) { options = options || browserify._options || {}; function write (data) { if (options.base) { // Determine the relative path // from the bundle file's directory to the source file let base = path.resolve(process.cwd(), options.base); data.sourceFile = path.relative(base, data.file); } if (options.root) { // Prepend the root path to the file path data.sourceFile = joinURL(options.root, data.sourceFile); } // Output normalized URL paths data.sourceFile = normalizeSeparators(data.sourceFile); this.queue(data); } // Add our transform stream to Browserify's "debug" pipeline // https://github.com/substack/node-browserify#bpipeline configurePipeline(); browserify.on("reset", configurePipeline); function configurePipeline () { browserify.pipeline.get("debug").push(new Through(write)); } return this; }
javascript
function sourcemapify (browserify, options) { options = options || browserify._options || {}; function write (data) { if (options.base) { // Determine the relative path // from the bundle file's directory to the source file let base = path.resolve(process.cwd(), options.base); data.sourceFile = path.relative(base, data.file); } if (options.root) { // Prepend the root path to the file path data.sourceFile = joinURL(options.root, data.sourceFile); } // Output normalized URL paths data.sourceFile = normalizeSeparators(data.sourceFile); this.queue(data); } // Add our transform stream to Browserify's "debug" pipeline // https://github.com/substack/node-browserify#bpipeline configurePipeline(); browserify.on("reset", configurePipeline); function configurePipeline () { browserify.pipeline.get("debug").push(new Through(write)); } return this; }
[ "function", "sourcemapify", "(", "browserify", ",", "options", ")", "{", "options", "=", "options", "||", "browserify", ".", "_options", "||", "{", "}", ";", "function", "write", "(", "data", ")", "{", "if", "(", "options", ".", "base", ")", "{", "// Determine the relative path", "// from the bundle file's directory to the source file", "let", "base", "=", "path", ".", "resolve", "(", "process", ".", "cwd", "(", ")", ",", "options", ".", "base", ")", ";", "data", ".", "sourceFile", "=", "path", ".", "relative", "(", "base", ",", "data", ".", "file", ")", ";", "}", "if", "(", "options", ".", "root", ")", "{", "// Prepend the root path to the file path", "data", ".", "sourceFile", "=", "joinURL", "(", "options", ".", "root", ",", "data", ".", "sourceFile", ")", ";", "}", "// Output normalized URL paths", "data", ".", "sourceFile", "=", "normalizeSeparators", "(", "data", ".", "sourceFile", ")", ";", "this", ".", "queue", "(", "data", ")", ";", "}", "// Add our transform stream to Browserify's \"debug\" pipeline", "// https://github.com/substack/node-browserify#bpipeline", "configurePipeline", "(", ")", ";", "browserify", ".", "on", "(", "\"reset\"", ",", "configurePipeline", ")", ";", "function", "configurePipeline", "(", ")", "{", "browserify", ".", "pipeline", ".", "get", "(", "\"debug\"", ")", ".", "push", "(", "new", "Through", "(", "write", ")", ")", ";", "}", "return", "this", ";", "}" ]
Transforms the browserify sourcemap @param {object} browserify - The Browserify instance @param {object} [options] - Plugin options
[ "Transforms", "the", "browserify", "sourcemap" ]
2e1d838ab6ff766a762c32097855125b3ed7bd80
https://github.com/JS-DevTools/sourcemapify/blob/2e1d838ab6ff766a762c32097855125b3ed7bd80/lib/index.js#L14-L45
38,487
JS-DevTools/sourcemapify
lib/index.js
joinURL
function joinURL (urlA, urlB) { urlA = urlA || ""; urlB = urlB || ""; let endsWithASlash = urlA.substr(-1) === "/" || urlA.substr(-1) === "\\"; let startsWithASlash = urlB[0] === "/" || urlB[0] === "\\"; if (endsWithASlash || startsWithASlash) { return urlA + urlB; } else { return urlA + "/" + urlB; } }
javascript
function joinURL (urlA, urlB) { urlA = urlA || ""; urlB = urlB || ""; let endsWithASlash = urlA.substr(-1) === "/" || urlA.substr(-1) === "\\"; let startsWithASlash = urlB[0] === "/" || urlB[0] === "\\"; if (endsWithASlash || startsWithASlash) { return urlA + urlB; } else { return urlA + "/" + urlB; } }
[ "function", "joinURL", "(", "urlA", ",", "urlB", ")", "{", "urlA", "=", "urlA", "||", "\"\"", ";", "urlB", "=", "urlB", "||", "\"\"", ";", "let", "endsWithASlash", "=", "urlA", ".", "substr", "(", "-", "1", ")", "===", "\"/\"", "||", "urlA", ".", "substr", "(", "-", "1", ")", "===", "\"\\\\\"", ";", "let", "startsWithASlash", "=", "urlB", "[", "0", "]", "===", "\"/\"", "||", "urlB", "[", "0", "]", "===", "\"\\\\\"", ";", "if", "(", "endsWithASlash", "||", "startsWithASlash", ")", "{", "return", "urlA", "+", "urlB", ";", "}", "else", "{", "return", "urlA", "+", "\"/\"", "+", "urlB", ";", "}", "}" ]
Joins two URL paths, possibly adding a separator. @param {string} urlA @param {string} urlB @returns {string}
[ "Joins", "two", "URL", "paths", "possibly", "adding", "a", "separator", "." ]
2e1d838ab6ff766a762c32097855125b3ed7bd80
https://github.com/JS-DevTools/sourcemapify/blob/2e1d838ab6ff766a762c32097855125b3ed7bd80/lib/index.js#L54-L67
38,488
ragingwind/electron-togglify-window
index.js
ToggleAnimation
function ToggleAnimation(target, animation) { var preset = { hide: { hide: 'hide', focus: 'show', restore: 'show', blur: 'hide' }, scale: { hide: 'minimize', focus: 'focus', restore: 'restore', } }; this._preset = preset[animation]; this._target = target; if (!this._target) { throw new Error('Invalid BrowserWindow instance'); } else if (!this._preset) { throw new Error('Unknown type of animation for toggle'); } }
javascript
function ToggleAnimation(target, animation) { var preset = { hide: { hide: 'hide', focus: 'show', restore: 'show', blur: 'hide' }, scale: { hide: 'minimize', focus: 'focus', restore: 'restore', } }; this._preset = preset[animation]; this._target = target; if (!this._target) { throw new Error('Invalid BrowserWindow instance'); } else if (!this._preset) { throw new Error('Unknown type of animation for toggle'); } }
[ "function", "ToggleAnimation", "(", "target", ",", "animation", ")", "{", "var", "preset", "=", "{", "hide", ":", "{", "hide", ":", "'hide'", ",", "focus", ":", "'show'", ",", "restore", ":", "'show'", ",", "blur", ":", "'hide'", "}", ",", "scale", ":", "{", "hide", ":", "'minimize'", ",", "focus", ":", "'focus'", ",", "restore", ":", "'restore'", ",", "}", "}", ";", "this", ".", "_preset", "=", "preset", "[", "animation", "]", ";", "this", ".", "_target", "=", "target", ";", "if", "(", "!", "this", ".", "_target", ")", "{", "throw", "new", "Error", "(", "'Invalid BrowserWindow instance'", ")", ";", "}", "else", "if", "(", "!", "this", ".", "_preset", ")", "{", "throw", "new", "Error", "(", "'Unknown type of animation for toggle'", ")", ";", "}", "}" ]
Delegate function for animation of window set toggle
[ "Delegate", "function", "for", "animation", "of", "window", "set", "toggle" ]
e9781f67f79e8d2a082dba4cb31b29bdbb874df7
https://github.com/ragingwind/electron-togglify-window/blob/e9781f67f79e8d2a082dba4cb31b29bdbb874df7/index.js#L6-L29
38,489
ragingwind/electron-togglify-window
index.js
togglify
function togglify(win, opts) { // extend options for toggle window opts = oassign({ animation: 'hide' }, opts); win._toggleAction = new ToggleAnimation(win, opts.animation); // patch toggle function to window win.toggle = function () { if (this.isVisible() && this.isFocused()) { this._toggleAction.hide(); } else if (this.isVisible() && !this.isFocused()) { this._toggleAction.focus(); } else if (this.isMinimized() || !this.isVisible()) { this._toggleAction.restore(); } }; // bind event for default action win.on('blur', function () { if (win.isVisible()) { this._toggleAction.blur(); } }); return win; }
javascript
function togglify(win, opts) { // extend options for toggle window opts = oassign({ animation: 'hide' }, opts); win._toggleAction = new ToggleAnimation(win, opts.animation); // patch toggle function to window win.toggle = function () { if (this.isVisible() && this.isFocused()) { this._toggleAction.hide(); } else if (this.isVisible() && !this.isFocused()) { this._toggleAction.focus(); } else if (this.isMinimized() || !this.isVisible()) { this._toggleAction.restore(); } }; // bind event for default action win.on('blur', function () { if (win.isVisible()) { this._toggleAction.blur(); } }); return win; }
[ "function", "togglify", "(", "win", ",", "opts", ")", "{", "// extend options for toggle window", "opts", "=", "oassign", "(", "{", "animation", ":", "'hide'", "}", ",", "opts", ")", ";", "win", ".", "_toggleAction", "=", "new", "ToggleAnimation", "(", "win", ",", "opts", ".", "animation", ")", ";", "// patch toggle function to window", "win", ".", "toggle", "=", "function", "(", ")", "{", "if", "(", "this", ".", "isVisible", "(", ")", "&&", "this", ".", "isFocused", "(", ")", ")", "{", "this", ".", "_toggleAction", ".", "hide", "(", ")", ";", "}", "else", "if", "(", "this", ".", "isVisible", "(", ")", "&&", "!", "this", ".", "isFocused", "(", ")", ")", "{", "this", ".", "_toggleAction", ".", "focus", "(", ")", ";", "}", "else", "if", "(", "this", ".", "isMinimized", "(", ")", "||", "!", "this", ".", "isVisible", "(", ")", ")", "{", "this", ".", "_toggleAction", ".", "restore", "(", ")", ";", "}", "}", ";", "// bind event for default action", "win", ".", "on", "(", "'blur'", ",", "function", "(", ")", "{", "if", "(", "win", ".", "isVisible", "(", ")", ")", "{", "this", ".", "_toggleAction", ".", "blur", "(", ")", ";", "}", "}", ")", ";", "return", "win", ";", "}" ]
Set window to be able to togggle
[ "Set", "window", "to", "be", "able", "to", "togggle" ]
e9781f67f79e8d2a082dba4cb31b29bdbb874df7
https://github.com/ragingwind/electron-togglify-window/blob/e9781f67f79e8d2a082dba4cb31b29bdbb874df7/index.js#L55-L82
38,490
rootsdev/gedcomx-js
src/core/SourceCitation.js
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof SourceCitation)){ return new SourceCitation(json); } // If the given object is already an instance then just return it. DON'T copy it. if(SourceCitation.isInstance(json)){ return json; } this.init(json); }
javascript
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof SourceCitation)){ return new SourceCitation(json); } // If the given object is already an instance then just return it. DON'T copy it. if(SourceCitation.isInstance(json)){ return json; } this.init(json); }
[ "function", "(", "json", ")", "{", "// Protect against forgetting the new keyword when calling the constructor", "if", "(", "!", "(", "this", "instanceof", "SourceCitation", ")", ")", "{", "return", "new", "SourceCitation", "(", "json", ")", ";", "}", "// If the given object is already an instance then just return it. DON'T copy it.", "if", "(", "SourceCitation", ".", "isInstance", "(", "json", ")", ")", "{", "return", "json", ";", "}", "this", ".", "init", "(", "json", ")", ";", "}" ]
A source citation. @see {@link https://github.com/FamilySearch/gedcomx/blob/master/specifications/json-format-specification.md#source-citation|GEDCOM X JSON Spec} @class @extends ExtensibleData @apram {Object} [json]
[ "A", "source", "citation", "." ]
08b2fcde96f1e301c78561bfb7a8b0cac606e26e
https://github.com/rootsdev/gedcomx-js/blob/08b2fcde96f1e301c78561bfb7a8b0cac606e26e/src/core/SourceCitation.js#L13-L26
38,491
lroche/karma-jasmine-bridge
lib/Spec.js
wrapper
function wrapper(matcherName, legacyMatcher){ return function(util, customEqualityTesters){ return { compare: function(actual, expected){ var scope = {actual: actual}, message, result; result = legacyMatcher.call(scope, expected) message = scope.message && scope.message()[result ? 1 : 0]; return { pass:result, message : message } } } } }
javascript
function wrapper(matcherName, legacyMatcher){ return function(util, customEqualityTesters){ return { compare: function(actual, expected){ var scope = {actual: actual}, message, result; result = legacyMatcher.call(scope, expected) message = scope.message && scope.message()[result ? 1 : 0]; return { pass:result, message : message } } } } }
[ "function", "wrapper", "(", "matcherName", ",", "legacyMatcher", ")", "{", "return", "function", "(", "util", ",", "customEqualityTesters", ")", "{", "return", "{", "compare", ":", "function", "(", "actual", ",", "expected", ")", "{", "var", "scope", "=", "{", "actual", ":", "actual", "}", ",", "message", ",", "result", ";", "result", "=", "legacyMatcher", ".", "call", "(", "scope", ",", "expected", ")", "message", "=", "scope", ".", "message", "&&", "scope", ".", "message", "(", ")", "[", "result", "?", "1", ":", "0", "]", ";", "return", "{", "pass", ":", "result", ",", "message", ":", "message", "}", "}", "}", "}", "}" ]
Wraps Jasmine2 matcher to be compliant with Jasmine 1 API.
[ "Wraps", "Jasmine2", "matcher", "to", "be", "compliant", "with", "Jasmine", "1", "API", "." ]
eda799fab2bb09f7876d31420955583e6791d27c
https://github.com/lroche/karma-jasmine-bridge/blob/eda799fab2bb09f7876d31420955583e6791d27c/lib/Spec.js#L135-L151
38,492
rowanmanning/chic
lib/chic.js
applySuperMethod
function applySuperMethod (fn, sup) { return function () { var prev, result; prev = this.sup; this.sup = sup; result = fn.apply(this, arguments); this.sup = prev; if (typeof this.sup === 'undefined') { delete this.sup; } return result; }; }
javascript
function applySuperMethod (fn, sup) { return function () { var prev, result; prev = this.sup; this.sup = sup; result = fn.apply(this, arguments); this.sup = prev; if (typeof this.sup === 'undefined') { delete this.sup; } return result; }; }
[ "function", "applySuperMethod", "(", "fn", ",", "sup", ")", "{", "return", "function", "(", ")", "{", "var", "prev", ",", "result", ";", "prev", "=", "this", ".", "sup", ";", "this", ".", "sup", "=", "sup", ";", "result", "=", "fn", ".", "apply", "(", "this", ",", "arguments", ")", ";", "this", ".", "sup", "=", "prev", ";", "if", "(", "typeof", "this", ".", "sup", "===", "'undefined'", ")", "{", "delete", "this", ".", "sup", ";", "}", "return", "result", ";", "}", ";", "}" ]
Apply a super-method to a function. `this.sup` is set to `sup` inside calls to `fn`.
[ "Apply", "a", "super", "-", "method", "to", "a", "function", ".", "this", ".", "sup", "is", "set", "to", "sup", "inside", "calls", "to", "fn", "." ]
c5839c2e1e2be1cf13e86e828f5059c57954d5e8
https://github.com/rowanmanning/chic/blob/c5839c2e1e2be1cf13e86e828f5059c57954d5e8/lib/chic.js#L27-L39
38,493
ipanli/xlsxtojson
index.js
parseCommandLine
function parseCommandLine(args) { var parsed_cmds = []; if (args.length <= 2) { parsed_cmds.push(defaultCommand()); } else { var cli = args.slice(2); var pos = 0; var cmd; cli.forEach(function(element, index, array) { //replace alias name with real name. if (element.indexOf('--') === -1 && element.indexOf('-') === 0) { cli[index] = alias_map[element]; } //parse command and args if (cli[index].indexOf('--') === -1) { cmd.args.push(cli[index]); } else { if (keys[cli[index]] == "undefined") { throw new Error("not support command:" + cli[index]); }; pos = index; cmd = commands[cli[index]]; if (typeof cmd.args == 'undefined') { cmd.args = []; }; parsed_cmds.push(cmd); } }); }; return parsed_cmds; }
javascript
function parseCommandLine(args) { var parsed_cmds = []; if (args.length <= 2) { parsed_cmds.push(defaultCommand()); } else { var cli = args.slice(2); var pos = 0; var cmd; cli.forEach(function(element, index, array) { //replace alias name with real name. if (element.indexOf('--') === -1 && element.indexOf('-') === 0) { cli[index] = alias_map[element]; } //parse command and args if (cli[index].indexOf('--') === -1) { cmd.args.push(cli[index]); } else { if (keys[cli[index]] == "undefined") { throw new Error("not support command:" + cli[index]); }; pos = index; cmd = commands[cli[index]]; if (typeof cmd.args == 'undefined') { cmd.args = []; }; parsed_cmds.push(cmd); } }); }; return parsed_cmds; }
[ "function", "parseCommandLine", "(", "args", ")", "{", "var", "parsed_cmds", "=", "[", "]", ";", "if", "(", "args", ".", "length", "<=", "2", ")", "{", "parsed_cmds", ".", "push", "(", "defaultCommand", "(", ")", ")", ";", "}", "else", "{", "var", "cli", "=", "args", ".", "slice", "(", "2", ")", ";", "var", "pos", "=", "0", ";", "var", "cmd", ";", "cli", ".", "forEach", "(", "function", "(", "element", ",", "index", ",", "array", ")", "{", "//replace alias name with real name.", "if", "(", "element", ".", "indexOf", "(", "'--'", ")", "===", "-", "1", "&&", "element", ".", "indexOf", "(", "'-'", ")", "===", "0", ")", "{", "cli", "[", "index", "]", "=", "alias_map", "[", "element", "]", ";", "}", "//parse command and args", "if", "(", "cli", "[", "index", "]", ".", "indexOf", "(", "'--'", ")", "===", "-", "1", ")", "{", "cmd", ".", "args", ".", "push", "(", "cli", "[", "index", "]", ")", ";", "}", "else", "{", "if", "(", "keys", "[", "cli", "[", "index", "]", "]", "==", "\"undefined\"", ")", "{", "throw", "new", "Error", "(", "\"not support command:\"", "+", "cli", "[", "index", "]", ")", ";", "}", ";", "pos", "=", "index", ";", "cmd", "=", "commands", "[", "cli", "[", "index", "]", "]", ";", "if", "(", "typeof", "cmd", ".", "args", "==", "'undefined'", ")", "{", "cmd", ".", "args", "=", "[", "]", ";", "}", ";", "parsed_cmds", ".", "push", "(", "cmd", ")", ";", "}", "}", ")", ";", "}", ";", "return", "parsed_cmds", ";", "}" ]
parse command line args
[ "parse", "command", "line", "args" ]
7432f133d584d6f32eb2bf722de084e2416bc468
https://github.com/ipanli/xlsxtojson/blob/7432f133d584d6f32eb2bf722de084e2416bc468/index.js#L120-L160
38,494
ipanli/xlsxtojson
index.js
defaultCommand
function defaultCommand() { if (keys.length <= 0) { throw new Error("Error: there is no command at all!"); }; for (var p in commands) { if (commands[p]["default"]) { return commands[p]; }; }; if (keys["--help"]) { return commands["--help"]; } else { return commands[keys[0]]; }; }
javascript
function defaultCommand() { if (keys.length <= 0) { throw new Error("Error: there is no command at all!"); }; for (var p in commands) { if (commands[p]["default"]) { return commands[p]; }; }; if (keys["--help"]) { return commands["--help"]; } else { return commands[keys[0]]; }; }
[ "function", "defaultCommand", "(", ")", "{", "if", "(", "keys", ".", "length", "<=", "0", ")", "{", "throw", "new", "Error", "(", "\"Error: there is no command at all!\"", ")", ";", "}", ";", "for", "(", "var", "p", "in", "commands", ")", "{", "if", "(", "commands", "[", "p", "]", "[", "\"default\"", "]", ")", "{", "return", "commands", "[", "p", "]", ";", "}", ";", "}", ";", "if", "(", "keys", "[", "\"--help\"", "]", ")", "{", "return", "commands", "[", "\"--help\"", "]", ";", "}", "else", "{", "return", "commands", "[", "keys", "[", "0", "]", "]", ";", "}", ";", "}" ]
default command when no command line argas provided.
[ "default", "command", "when", "no", "command", "line", "argas", "provided", "." ]
7432f133d584d6f32eb2bf722de084e2416bc468
https://github.com/ipanli/xlsxtojson/blob/7432f133d584d6f32eb2bf722de084e2416bc468/index.js#L165-L181
38,495
smagch/simple-lru
simple-lru.js
Entry
function Entry(key, val, index) { this.key = key; this.val = val; this.index = index; }
javascript
function Entry(key, val, index) { this.key = key; this.val = val; this.index = index; }
[ "function", "Entry", "(", "key", ",", "val", ",", "index", ")", "{", "this", ".", "key", "=", "key", ";", "this", ".", "val", "=", "val", ";", "this", ".", "index", "=", "index", ";", "}" ]
Cache entry instance @param {String} @param {any} @param {Number} @api private
[ "Cache", "entry", "instance" ]
b32d8e55a190c969419d84669a1228c8705bfca2
https://github.com/smagch/simple-lru/blob/b32d8e55a190c969419d84669a1228c8705bfca2/simple-lru.js#L92-L96
38,496
smagch/simple-lru
simple-lru.js
function (key, val) { var entry = this._byKey.get(key); // reuse entry if the key exists if (entry) { this._touch(entry); entry.val = val; return; } entry = new Entry(key, val, this._head++); this._byKey.set(key, entry); this._byOrder[entry.index] = entry; this._len++; this._trim(); }
javascript
function (key, val) { var entry = this._byKey.get(key); // reuse entry if the key exists if (entry) { this._touch(entry); entry.val = val; return; } entry = new Entry(key, val, this._head++); this._byKey.set(key, entry); this._byOrder[entry.index] = entry; this._len++; this._trim(); }
[ "function", "(", "key", ",", "val", ")", "{", "var", "entry", "=", "this", ".", "_byKey", ".", "get", "(", "key", ")", ";", "// reuse entry if the key exists", "if", "(", "entry", ")", "{", "this", ".", "_touch", "(", "entry", ")", ";", "entry", ".", "val", "=", "val", ";", "return", ";", "}", "entry", "=", "new", "Entry", "(", "key", ",", "val", ",", "this", ".", "_head", "++", ")", ";", "this", ".", "_byKey", ".", "set", "(", "key", ",", "entry", ")", ";", "this", ".", "_byOrder", "[", "entry", ".", "index", "]", "=", "entry", ";", "this", ".", "_len", "++", ";", "this", ".", "_trim", "(", ")", ";", "}" ]
Set cache by key @param {String} unique string key @param {String|Object|Number} any value
[ "Set", "cache", "by", "key" ]
b32d8e55a190c969419d84669a1228c8705bfca2
https://github.com/smagch/simple-lru/blob/b32d8e55a190c969419d84669a1228c8705bfca2/simple-lru.js#L126-L141
38,497
smagch/simple-lru
simple-lru.js
function (key) { var entry = this._byKey.del(key); if (!entry) return; delete this._byOrder[entry.index]; this._len--; if (this._len === 0) { this._head = this._tail = 0; } else { // update most index if it was most lecently used entry if (entry.index === this._head - 1) this._pop(); // update least index if it was least lecently used entry if (entry.index === this._tail) this._shift(); } return entry.val; }
javascript
function (key) { var entry = this._byKey.del(key); if (!entry) return; delete this._byOrder[entry.index]; this._len--; if (this._len === 0) { this._head = this._tail = 0; } else { // update most index if it was most lecently used entry if (entry.index === this._head - 1) this._pop(); // update least index if it was least lecently used entry if (entry.index === this._tail) this._shift(); } return entry.val; }
[ "function", "(", "key", ")", "{", "var", "entry", "=", "this", ".", "_byKey", ".", "del", "(", "key", ")", ";", "if", "(", "!", "entry", ")", "return", ";", "delete", "this", ".", "_byOrder", "[", "entry", ".", "index", "]", ";", "this", ".", "_len", "--", ";", "if", "(", "this", ".", "_len", "===", "0", ")", "{", "this", ".", "_head", "=", "this", ".", "_tail", "=", "0", ";", "}", "else", "{", "// update most index if it was most lecently used entry", "if", "(", "entry", ".", "index", "===", "this", ".", "_head", "-", "1", ")", "this", ".", "_pop", "(", ")", ";", "// update least index if it was least lecently used entry", "if", "(", "entry", ".", "index", "===", "this", ".", "_tail", ")", "this", ".", "_shift", "(", ")", ";", "}", "return", "entry", ".", "val", ";", "}" ]
delete cache by key @param {String} @return {String|Object|Number} cached value
[ "delete", "cache", "by", "key" ]
b32d8e55a190c969419d84669a1228c8705bfca2
https://github.com/smagch/simple-lru/blob/b32d8e55a190c969419d84669a1228c8705bfca2/simple-lru.js#L149-L166
38,498
smagch/simple-lru
simple-lru.js
function (key) { var entry = this._byKey.get(key); if (entry) { this._touch(entry); return entry.val; } }
javascript
function (key) { var entry = this._byKey.get(key); if (entry) { this._touch(entry); return entry.val; } }
[ "function", "(", "key", ")", "{", "var", "entry", "=", "this", ".", "_byKey", ".", "get", "(", "key", ")", ";", "if", "(", "entry", ")", "{", "this", ".", "_touch", "(", "entry", ")", ";", "return", "entry", ".", "val", ";", "}", "}" ]
get cache by key @param {String} @return {any} cache if it exists
[ "get", "cache", "by", "key" ]
b32d8e55a190c969419d84669a1228c8705bfca2
https://github.com/smagch/simple-lru/blob/b32d8e55a190c969419d84669a1228c8705bfca2/simple-lru.js#L174-L180
38,499
smagch/simple-lru
simple-lru.js
function (max) { if (typeof max !== 'number') return this._max; if (max < 1) throw new TypeError('max should be a positive number'); var shrink = (this._max || 0) > max; this._max = max; if (shrink) this._trim(); }
javascript
function (max) { if (typeof max !== 'number') return this._max; if (max < 1) throw new TypeError('max should be a positive number'); var shrink = (this._max || 0) > max; this._max = max; if (shrink) this._trim(); }
[ "function", "(", "max", ")", "{", "if", "(", "typeof", "max", "!==", "'number'", ")", "return", "this", ".", "_max", ";", "if", "(", "max", "<", "1", ")", "throw", "new", "TypeError", "(", "'max should be a positive number'", ")", ";", "var", "shrink", "=", "(", "this", ".", "_max", "||", "0", ")", ">", "max", ";", "this", ".", "_max", "=", "max", ";", "if", "(", "shrink", ")", "this", ".", "_trim", "(", ")", ";", "}" ]
Getter|Setter function of "max" option @param {Number} if setter
[ "Getter|Setter", "function", "of", "max", "option" ]
b32d8e55a190c969419d84669a1228c8705bfca2
https://github.com/smagch/simple-lru/blob/b32d8e55a190c969419d84669a1228c8705bfca2/simple-lru.js#L222-L228