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
33,600
jonschlinkert/templates
lib/plugins/context.js
setHelperOptions
function setHelperOptions(context, key) { var optsHelper = context.options.helper || {}; if (optsHelper.hasOwnProperty(key)) { context.helper.options = optsHelper[key]; } }
javascript
function setHelperOptions(context, key) { var optsHelper = context.options.helper || {}; if (optsHelper.hasOwnProperty(key)) { context.helper.options = optsHelper[key]; } }
[ "function", "setHelperOptions", "(", "context", ",", "key", ")", "{", "var", "optsHelper", "=", "context", ".", "options", ".", "helper", "||", "{", "}", ";", "if", "(", "optsHelper", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "context", ".", "h...
Update context in a helper so that `this.helper.options` is the options for that specific helper. @param {Object} `context` @param {String} `key` @api public
[ "Update", "context", "in", "a", "helper", "so", "that", "this", ".", "helper", ".", "options", "is", "the", "options", "for", "that", "specific", "helper", "." ]
f030d2c2906ea9a703868f83574151badb427573
https://github.com/jonschlinkert/templates/blob/f030d2c2906ea9a703868f83574151badb427573/lib/plugins/context.js#L120-L125
33,601
jonschlinkert/templates
lib/plugins/context.js
Context
function Context(app, view, context, helpers) { this.helper = {}; this.helper.options = createHelperOptions(app, view, helpers); this.context = context; utils.define(this.context, 'view', view); this.options = utils.merge({}, app.options, view.options, this.helper.options); // make `this.optio...
javascript
function Context(app, view, context, helpers) { this.helper = {}; this.helper.options = createHelperOptions(app, view, helpers); this.context = context; utils.define(this.context, 'view', view); this.options = utils.merge({}, app.options, view.options, this.helper.options); // make `this.optio...
[ "function", "Context", "(", "app", ",", "view", ",", "context", ",", "helpers", ")", "{", "this", ".", "helper", "=", "{", "}", ";", "this", ".", "helper", ".", "options", "=", "createHelperOptions", "(", "app", ",", "view", ",", "helpers", ")", ";",...
Create a new context object to expose inside helpers. ```js app.helper('lowercase', function(str) { // the 'this' object is the _helper_ context console.log(this); // 'this.app' => the application instance, e.g. templates, assemble, verb etc. // 'this.view' => the current view being rendered // 'this.helper' => helper...
[ "Create", "a", "new", "context", "object", "to", "expose", "inside", "helpers", "." ]
f030d2c2906ea9a703868f83574151badb427573
https://github.com/jonschlinkert/templates/blob/f030d2c2906ea9a703868f83574151badb427573/lib/plugins/context.js#L147-L167
33,602
jonschlinkert/templates
lib/plugins/context.js
decorate
function decorate(obj) { utils.define(obj, 'merge', function() { var args = [].concat.apply([], [].slice.call(arguments)); var len = args.length; var idx = -1; while (++idx < len) { var val = args[idx]; if (!utils.isObject(val)) continue; if (val.hasOwnProperty('hash...
javascript
function decorate(obj) { utils.define(obj, 'merge', function() { var args = [].concat.apply([], [].slice.call(arguments)); var len = args.length; var idx = -1; while (++idx < len) { var val = args[idx]; if (!utils.isObject(val)) continue; if (val.hasOwnProperty('hash...
[ "function", "decorate", "(", "obj", ")", "{", "utils", ".", "define", "(", "obj", ",", "'merge'", ",", "function", "(", ")", "{", "var", "args", "=", "[", "]", ".", "concat", ".", "apply", "(", "[", "]", ",", "[", "]", ".", "slice", ".", "call"...
Decorate the given object with `merge`, `set` and `get` methods
[ "Decorate", "the", "given", "object", "with", "merge", "set", "and", "get", "methods" ]
f030d2c2906ea9a703868f83574151badb427573
https://github.com/jonschlinkert/templates/blob/f030d2c2906ea9a703868f83574151badb427573/lib/plugins/context.js#L247-L278
33,603
jonschlinkert/templates
lib/plugins/context.js
mergePartials
function mergePartials(options) { var opts = utils.merge({}, this.options, options); var names = opts.mergeTypes || this.viewTypes.partial; var partials = {}; var self = this; names.forEach(function(name) { var collection = self.views[name]; for (var key in collection) { var vie...
javascript
function mergePartials(options) { var opts = utils.merge({}, this.options, options); var names = opts.mergeTypes || this.viewTypes.partial; var partials = {}; var self = this; names.forEach(function(name) { var collection = self.views[name]; for (var key in collection) { var vie...
[ "function", "mergePartials", "(", "options", ")", "{", "var", "opts", "=", "utils", ".", "merge", "(", "{", "}", ",", "this", ".", "options", ",", "options", ")", ";", "var", "names", "=", "opts", ".", "mergeTypes", "||", "this", ".", "viewTypes", "....
Merge "partials" view types. This is necessary for template engines have no support for partials or only support one type of partials. @name .mergePartials @param {Object} `options` Optionally pass an array of `viewTypes` to include on `options.viewTypes` @return {Object} Merged partials @api public
[ "Merge", "partials", "view", "types", ".", "This", "is", "necessary", "for", "template", "engines", "have", "no", "support", "for", "partials", "or", "only", "support", "one", "type", "of", "partials", "." ]
f030d2c2906ea9a703868f83574151badb427573
https://github.com/jonschlinkert/templates/blob/f030d2c2906ea9a703868f83574151badb427573/lib/plugins/context.js#L322-L351
33,604
jeneser/rsa-node
src/index.js
FixEncryptLength
function FixEncryptLength(text) { var len = text.length; var stdLens = [256, 512, 1024, 2048, 4096]; var stdLen, i, j; for (i = 0; i < stdLens.length; i++) { stdLen = stdLens[i]; if (len === stdLen) { return text; } else if (len < stdLen) { var times = stdLen - len; var preText = '...
javascript
function FixEncryptLength(text) { var len = text.length; var stdLens = [256, 512, 1024, 2048, 4096]; var stdLen, i, j; for (i = 0; i < stdLens.length; i++) { stdLen = stdLens[i]; if (len === stdLen) { return text; } else if (len < stdLen) { var times = stdLen - len; var preText = '...
[ "function", "FixEncryptLength", "(", "text", ")", "{", "var", "len", "=", "text", ".", "length", ";", "var", "stdLens", "=", "[", "256", ",", "512", ",", "1024", ",", "2048", ",", "4096", "]", ";", "var", "stdLen", ",", "i", ",", "j", ";", "for",...
If the length of the encrypted text is not enough,add 0 in front
[ "If", "the", "length", "of", "the", "encrypted", "text", "is", "not", "enough", "add", "0", "in", "front" ]
7a54643b63259d44f7ff475ec0c1270f40171b01
https://github.com/jeneser/rsa-node/blob/7a54643b63259d44f7ff475ec0c1270f40171b01/src/index.js#L838-L856
33,605
jonschlinkert/templates
lib/group.js
Group
function Group(config) { if (!(this instanceof Group)) { return new Group(config); } Base.call(this, config); this.is('Group'); this.use(utils.option()); this.use(utils.plugin()); this.init(); }
javascript
function Group(config) { if (!(this instanceof Group)) { return new Group(config); } Base.call(this, config); this.is('Group'); this.use(utils.option()); this.use(utils.plugin()); this.init(); }
[ "function", "Group", "(", "config", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Group", ")", ")", "{", "return", "new", "Group", "(", "config", ")", ";", "}", "Base", ".", "call", "(", "this", ",", "config", ")", ";", "this", ".", "is",...
Create an instance of `Group` with the given `options`. ```js var group = new Group({ 'foo': { items: [1,2,3] } }); ``` @param {Object} `options` @api public
[ "Create", "an", "instance", "of", "Group", "with", "the", "given", "options", "." ]
f030d2c2906ea9a703868f83574151badb427573
https://github.com/jonschlinkert/templates/blob/f030d2c2906ea9a703868f83574151badb427573/lib/group.js#L25-L35
33,606
jonschlinkert/templates
lib/group.js
handleErrors
function handleErrors(group, val) { if (utils.isObject(val)) { var List = group.List; var keys = Object.keys(List.prototype); keys.forEach(function(key) { if (typeof val[key] !== 'undefined') return; utils.define(val, key, function() { throw new Error(key + ' can only be used with an...
javascript
function handleErrors(group, val) { if (utils.isObject(val)) { var List = group.List; var keys = Object.keys(List.prototype); keys.forEach(function(key) { if (typeof val[key] !== 'undefined') return; utils.define(val, key, function() { throw new Error(key + ' can only be used with an...
[ "function", "handleErrors", "(", "group", ",", "val", ")", "{", "if", "(", "utils", ".", "isObject", "(", "val", ")", ")", "{", "var", "List", "=", "group", ".", "List", ";", "var", "keys", "=", "Object", ".", "keys", "(", "List", ".", "prototype",...
When `get` returns a non-Array object, we decorate noop `List` methods onto the object to throw errors when list methods are used, since list array methods do not work on groups. @param {Object} `group` @param {Object} `val` Value returned from `group.get()`
[ "When", "get", "returns", "a", "non", "-", "Array", "object", "we", "decorate", "noop", "List", "methods", "onto", "the", "object", "to", "throw", "errors", "when", "list", "methods", "are", "used", "since", "list", "array", "methods", "do", "not", "work",...
f030d2c2906ea9a703868f83574151badb427573
https://github.com/jonschlinkert/templates/blob/f030d2c2906ea9a703868f83574151badb427573/lib/group.js#L93-L106
33,607
wikimedia/KafkaSSE
lib/utils.js
objectFactory
function objectFactory(data) { // if we are given an object Object, no-op and return it now. if (_.isPlainObject(data)) { return data; } // If we are given a byte Buffer, parse it as utf-8 if (data instanceof Buffer) { data = data.toString('utf-8'); } // If we now have a st...
javascript
function objectFactory(data) { // if we are given an object Object, no-op and return it now. if (_.isPlainObject(data)) { return data; } // If we are given a byte Buffer, parse it as utf-8 if (data instanceof Buffer) { data = data.toString('utf-8'); } // If we now have a st...
[ "function", "objectFactory", "(", "data", ")", "{", "// if we are given an object Object, no-op and return it now.", "if", "(", "_", ".", "isPlainObject", "(", "data", ")", ")", "{", "return", "data", ";", "}", "// If we are given a byte Buffer, parse it as utf-8", "if", ...
Converts a utf-8 byte buffer or a JSON string into an object and returns it.
[ "Converts", "a", "utf", "-", "8", "byte", "buffer", "or", "a", "JSON", "string", "into", "an", "object", "and", "returns", "it", "." ]
eb4568b0d2929057771508afd74ac83884252c95
https://github.com/wikimedia/KafkaSSE/blob/eb4568b0d2929057771508afd74ac83884252c95/lib/utils.js#L16-L40
33,608
wikimedia/KafkaSSE
lib/utils.js
createKafkaConsumerAsync
function createKafkaConsumerAsync(kafkaConfig) { let topicConfig = {}; if ('default_topic_config' in kafkaConfig) { topicConfig = kafkaConfig.default_topic_config; delete kafkaConfig.default_topic_config; } const consumer = P.promisifyAll( new kafka.KafkaConsumer(kafkaConfig, to...
javascript
function createKafkaConsumerAsync(kafkaConfig) { let topicConfig = {}; if ('default_topic_config' in kafkaConfig) { topicConfig = kafkaConfig.default_topic_config; delete kafkaConfig.default_topic_config; } const consumer = P.promisifyAll( new kafka.KafkaConsumer(kafkaConfig, to...
[ "function", "createKafkaConsumerAsync", "(", "kafkaConfig", ")", "{", "let", "topicConfig", "=", "{", "}", ";", "if", "(", "'default_topic_config'", "in", "kafkaConfig", ")", "{", "topicConfig", "=", "kafkaConfig", ".", "default_topic_config", ";", "delete", "kafk...
Returns a Promise of a promisified and connected rdkafka.KafkaConsumer. @param {Object} kafkaConfig @return {Promise<KafkaConsumer>} Promisified KafkaConsumer
[ "Returns", "a", "Promise", "of", "a", "promisified", "and", "connected", "rdkafka", ".", "KafkaConsumer", "." ]
eb4568b0d2929057771508afd74ac83884252c95
https://github.com/wikimedia/KafkaSSE/blob/eb4568b0d2929057771508afd74ac83884252c95/lib/utils.js#L49-L62
33,609
wikimedia/KafkaSSE
lib/utils.js
getAvailableTopics
function getAvailableTopics(topicsInfo, allowedTopics) { const existentTopics = topicsInfo.map( e => e.name ) .filter(t => t !== '__consumer_offsets'); if (allowedTopics) { return existentTopics.filter(t => _.includes(allowedTopics, t)); } else { return existentTopics; ...
javascript
function getAvailableTopics(topicsInfo, allowedTopics) { const existentTopics = topicsInfo.map( e => e.name ) .filter(t => t !== '__consumer_offsets'); if (allowedTopics) { return existentTopics.filter(t => _.includes(allowedTopics, t)); } else { return existentTopics; ...
[ "function", "getAvailableTopics", "(", "topicsInfo", ",", "allowedTopics", ")", "{", "const", "existentTopics", "=", "topicsInfo", ".", "map", "(", "e", "=>", "e", ".", "name", ")", ".", "filter", "(", "t", "=>", "t", "!==", "'__consumer_offsets'", ")", ";...
Return the intersection of existent topics and allowedTopics, or just all existent topics if allowedTopics is undefined. @param {Array} topicsInfo topic metadata object, _metadata.topics. @param {Array} allowedTopics topics allowed to be consumed. @return {Array} available topics
[ "Return", "the", "intersection", "of", "existent", "topics", "and", "allowedTopics", "or", "just", "all", "existent", "topics", "if", "allowedTopics", "is", "undefined", "." ]
eb4568b0d2929057771508afd74ac83884252c95
https://github.com/wikimedia/KafkaSSE/blob/eb4568b0d2929057771508afd74ac83884252c95/lib/utils.js#L73-L85
33,610
wikimedia/KafkaSSE
lib/utils.js
assignmentsForTimesAsync
function assignmentsForTimesAsync(kafkaConsumer, assignments) { const assignmentsWithTimestamps = assignments.filter(a => 'timestamp' in a && !('offset' in a)).map((a) => { return {topic: a.topic, partition: a.partition, offset: a.timestamp }; }); // If there were no timestamps to resolve, just ret...
javascript
function assignmentsForTimesAsync(kafkaConsumer, assignments) { const assignmentsWithTimestamps = assignments.filter(a => 'timestamp' in a && !('offset' in a)).map((a) => { return {topic: a.topic, partition: a.partition, offset: a.timestamp }; }); // If there were no timestamps to resolve, just ret...
[ "function", "assignmentsForTimesAsync", "(", "kafkaConsumer", ",", "assignments", ")", "{", "const", "assignmentsWithTimestamps", "=", "assignments", ".", "filter", "(", "a", "=>", "'timestamp'", "in", "a", "&&", "!", "(", "'offset'", "in", "a", ")", ")", ".",...
Given a a Kafka assignemnts array, this will look for any occurances of 'timestamp' instead of 'offset'. For those found, it will issue a offsetsForTimes request on the kafkaConsumer. The returned offsets will be merged with any provided non-timestamp based assignments, and returned as a Promise of assignments array ...
[ "Given", "a", "a", "Kafka", "assignemnts", "array", "this", "will", "look", "for", "any", "occurances", "of", "timestamp", "instead", "of", "offset", ".", "For", "those", "found", "it", "will", "issue", "a", "offsetsForTimes", "request", "on", "the", "kafkaC...
eb4568b0d2929057771508afd74ac83884252c95
https://github.com/wikimedia/KafkaSSE/blob/eb4568b0d2929057771508afd74ac83884252c95/lib/utils.js#L249-L274
33,611
wikimedia/KafkaSSE
lib/utils.js
deserializeKafkaMessage
function deserializeKafkaMessage(kafkaMessage) { kafkaMessage.message = objectFactory(kafkaMessage.value); kafkaMessage.message._kafka = { topic: kafkaMessage.topic, partition: kafkaMessage.partition, offset: kafkaMessage.offset, timestamp: kafkaMessage.timestamp || null,...
javascript
function deserializeKafkaMessage(kafkaMessage) { kafkaMessage.message = objectFactory(kafkaMessage.value); kafkaMessage.message._kafka = { topic: kafkaMessage.topic, partition: kafkaMessage.partition, offset: kafkaMessage.offset, timestamp: kafkaMessage.timestamp || null,...
[ "function", "deserializeKafkaMessage", "(", "kafkaMessage", ")", "{", "kafkaMessage", ".", "message", "=", "objectFactory", "(", "kafkaMessage", ".", "value", ")", ";", "kafkaMessage", ".", "message", ".", "_kafka", "=", "{", "topic", ":", "kafkaMessage", ".", ...
Parses kafkaMessage.message as a JSON string and then augments the object with kafka message metadata. in the message._kafka sub object. @param {KafkaMesssage} kafkaMessage @return {Object}
[ "Parses", "kafkaMessage", ".", "message", "as", "a", "JSON", "string", "and", "then", "augments", "the", "object", "with", "kafka", "message", "metadata", ".", "in", "the", "message", ".", "_kafka", "sub", "object", "." ]
eb4568b0d2929057771508afd74ac83884252c95
https://github.com/wikimedia/KafkaSSE/blob/eb4568b0d2929057771508afd74ac83884252c95/lib/utils.js#L286-L298
33,612
jonschlinkert/templates
lib/plugins/render.js
findView
function findView(app, name) { var keys = app.viewTypes.renderable; var len = keys.length; var i = -1; var res = null; while (++i < len) { res = app.find(name, keys[i]); if (res) { break; } } return res; }
javascript
function findView(app, name) { var keys = app.viewTypes.renderable; var len = keys.length; var i = -1; var res = null; while (++i < len) { res = app.find(name, keys[i]); if (res) { break; } } return res; }
[ "function", "findView", "(", "app", ",", "name", ")", "{", "var", "keys", "=", "app", ".", "viewTypes", ".", "renderable", ";", "var", "len", "=", "keys", ".", "length", ";", "var", "i", "=", "-", "1", ";", "var", "res", "=", "null", ";", "while"...
Iterates over `renderable` view collections and returns the first view that matches the given `view` name
[ "Iterates", "over", "renderable", "view", "collections", "and", "returns", "the", "first", "view", "that", "matches", "the", "given", "view", "name" ]
f030d2c2906ea9a703868f83574151badb427573
https://github.com/jonschlinkert/templates/blob/f030d2c2906ea9a703868f83574151badb427573/lib/plugins/render.js#L38-L51
33,613
jonschlinkert/templates
lib/plugins/render.js
getView
function getView(app, view) { if (typeof view !== 'string') { return view; } if (app.isCollection) { view = app.getView(view); } else if (app.isList) { view = app.getItem(view); } else { view = findView(app, view); } return view; }
javascript
function getView(app, view) { if (typeof view !== 'string') { return view; } if (app.isCollection) { view = app.getView(view); } else if (app.isList) { view = app.getItem(view); } else { view = findView(app, view); } return view; }
[ "function", "getView", "(", "app", ",", "view", ")", "{", "if", "(", "typeof", "view", "!==", "'string'", ")", "{", "return", "view", ";", "}", "if", "(", "app", ".", "isCollection", ")", "{", "view", "=", "app", ".", "getView", "(", "view", ")", ...
Get a view from the specified collection, or list, or iterate over view collections until the view is found.
[ "Get", "a", "view", "from", "the", "specified", "collection", "or", "list", "or", "iterate", "over", "view", "collections", "until", "the", "view", "is", "found", "." ]
f030d2c2906ea9a703868f83574151badb427573
https://github.com/jonschlinkert/templates/blob/f030d2c2906ea9a703868f83574151badb427573/lib/plugins/render.js#L59-L73
33,614
audiojs/audio-generator
direct.js
Generator
function Generator (fn, opts) { if (fn instanceof Function) { if (typeof opts === 'number') { opts = {duration: opts}; } else { opts = opts || {}; } opts.generate = fn; } else { opts = fn || {}; } //sort out arguments opts = extend({ //total duration of a stream duration: Infinity, //tim...
javascript
function Generator (fn, opts) { if (fn instanceof Function) { if (typeof opts === 'number') { opts = {duration: opts}; } else { opts = opts || {}; } opts.generate = fn; } else { opts = fn || {}; } //sort out arguments opts = extend({ //total duration of a stream duration: Infinity, //tim...
[ "function", "Generator", "(", "fn", ",", "opts", ")", "{", "if", "(", "fn", "instanceof", "Function", ")", "{", "if", "(", "typeof", "opts", "===", "'number'", ")", "{", "opts", "=", "{", "duration", ":", "opts", "}", ";", "}", "else", "{", "opts",...
Sync map constructor @constructor
[ "Sync", "map", "constructor" ]
74f71214f6dbc227c7427d0e8410d8fc7301dcd7
https://github.com/audiojs/audio-generator/blob/74f71214f6dbc227c7427d0e8410d8fc7301dcd7/direct.js#L18-L106
33,615
Hustle/parse-mockdb
src/parse-mockdb.js
deserializeQueryParam
function deserializeQueryParam(param) { if (!!param && (typeof param === 'object')) { if (param.__type === 'Date') { return new Date(param.iso); } } return param; }
javascript
function deserializeQueryParam(param) { if (!!param && (typeof param === 'object')) { if (param.__type === 'Date') { return new Date(param.iso); } } return param; }
[ "function", "deserializeQueryParam", "(", "param", ")", "{", "if", "(", "!", "!", "param", "&&", "(", "typeof", "param", "===", "'object'", ")", ")", "{", "if", "(", "param", ".", "__type", "===", "'Date'", ")", "{", "return", "new", "Date", "(", "pa...
Deserialize an encoded query parameter if necessary
[ "Deserialize", "an", "encoded", "query", "parameter", "if", "necessary" ]
b33a113debcba3c80477b50c7fae557f5941d494
https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L47-L54
33,616
Hustle/parse-mockdb
src/parse-mockdb.js
ensureArray
function ensureArray(object, key) { if (!object[key]) { object[key] = []; } if (!Array.isArray(object[key])) { throw new Error("Can't perform array operation on non-array field"); } }
javascript
function ensureArray(object, key) { if (!object[key]) { object[key] = []; } if (!Array.isArray(object[key])) { throw new Error("Can't perform array operation on non-array field"); } }
[ "function", "ensureArray", "(", "object", ",", "key", ")", "{", "if", "(", "!", "object", "[", "key", "]", ")", "{", "object", "[", "key", "]", "=", "[", "]", ";", "}", "if", "(", "!", "Array", ".", "isArray", "(", "object", "[", "key", "]", ...
Ensures `object` has an array at `key`. Creates array if `key` doesn't exist. Will throw if value for `key` exists and is not Array.
[ "Ensures", "object", "has", "an", "array", "at", "key", ".", "Creates", "array", "if", "key", "doesn", "t", "exist", ".", "Will", "throw", "if", "value", "for", "key", "exists", "and", "is", "not", "Array", "." ]
b33a113debcba3c80477b50c7fae557f5941d494
https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L104-L111
33,617
Hustle/parse-mockdb
src/parse-mockdb.js
registerHook
function registerHook(className, hookType, hookFn) { if (!hooks[className]) { hooks[className] = {}; } hooks[className][hookType] = hookFn; }
javascript
function registerHook(className, hookType, hookFn) { if (!hooks[className]) { hooks[className] = {}; } hooks[className][hookType] = hookFn; }
[ "function", "registerHook", "(", "className", ",", "hookType", ",", "hookFn", ")", "{", "if", "(", "!", "hooks", "[", "className", "]", ")", "{", "hooks", "[", "className", "]", "=", "{", "}", ";", "}", "hooks", "[", "className", "]", "[", "hookType"...
Registers a hook on a class denoted by className. @param {string} className The name of the class to register hook on. @param {string} hookType One of 'beforeSave', 'afterSave', 'beforeDelete', 'afterDelete' @param {function} hookFn Function that will be called with `this` bound to hydrated model. Must return a promis...
[ "Registers", "a", "hook", "on", "a", "class", "denoted", "by", "className", "." ]
b33a113debcba3c80477b50c7fae557f5941d494
https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L205-L211
33,618
Hustle/parse-mockdb
src/parse-mockdb.js
getHook
function getHook(className, hookType) { if (hooks[className] && hooks[className][hookType]) { return hooks[className][hookType]; } return undefined; }
javascript
function getHook(className, hookType) { if (hooks[className] && hooks[className][hookType]) { return hooks[className][hookType]; } return undefined; }
[ "function", "getHook", "(", "className", ",", "hookType", ")", "{", "if", "(", "hooks", "[", "className", "]", "&&", "hooks", "[", "className", "]", "[", "hookType", "]", ")", "{", "return", "hooks", "[", "className", "]", "[", "hookType", "]", ";", ...
Retrieves a previously registered hook. @param {string} className The name of the class to get the hook on. @param {string} hookType One of 'beforeSave', 'afterSave', 'beforeDelete', 'afterDelete'
[ "Retrieves", "a", "previously", "registered", "hook", "." ]
b33a113debcba3c80477b50c7fae557f5941d494
https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L219-L224
33,619
Hustle/parse-mockdb
src/parse-mockdb.js
extractOps
function extractOps(data) { const ops = {}; _.forIn(data, (attribute, key) => { if (isOp(attribute)) { ops[key] = attribute; delete data[key]; } }); return ops; }
javascript
function extractOps(data) { const ops = {}; _.forIn(data, (attribute, key) => { if (isOp(attribute)) { ops[key] = attribute; delete data[key]; } }); return ops; }
[ "function", "extractOps", "(", "data", ")", "{", "const", "ops", "=", "{", "}", ";", "_", ".", "forIn", "(", "data", ",", "(", "attribute", ",", "key", ")", "=>", "{", "if", "(", "isOp", "(", "attribute", ")", ")", "{", "ops", "[", "key", "]", ...
Destructive. Takes data for update operation and removes all atomic operations. Returns the extracted ops.
[ "Destructive", ".", "Takes", "data", "for", "update", "operation", "and", "removes", "all", "atomic", "operations", ".", "Returns", "the", "extracted", "ops", "." ]
b33a113debcba3c80477b50c7fae557f5941d494
https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L242-L253
33,620
Hustle/parse-mockdb
src/parse-mockdb.js
applyOps
function applyOps(data, ops, className) { debugPrint('OPS', ops); _.forIn(ops, (value, key) => { const operator = value.__op; if (operator in UPDATE_OPERATORS) { UPDATE_OPERATORS[operator](data, key, value, className); } else { throw new Error(`Unknown update operator: ${key}`); } ...
javascript
function applyOps(data, ops, className) { debugPrint('OPS', ops); _.forIn(ops, (value, key) => { const operator = value.__op; if (operator in UPDATE_OPERATORS) { UPDATE_OPERATORS[operator](data, key, value, className); } else { throw new Error(`Unknown update operator: ${key}`); } ...
[ "function", "applyOps", "(", "data", ",", "ops", ",", "className", ")", "{", "debugPrint", "(", "'OPS'", ",", "ops", ")", ";", "_", ".", "forIn", "(", "ops", ",", "(", "value", ",", "key", ")", "=>", "{", "const", "operator", "=", "value", ".", "...
Destructive. Applies all the update `ops` to `data`. Throws on unknown update operator.
[ "Destructive", ".", "Applies", "all", "the", "update", "ops", "to", "data", ".", "Throws", "on", "unknown", "update", "operator", "." ]
b33a113debcba3c80477b50c7fae557f5941d494
https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L257-L272
33,621
Hustle/parse-mockdb
src/parse-mockdb.js
queryFilter
function queryFilter(where) { if (where.$or) { return object => _.reduce(where.$or, (result, subclause) => result || queryFilter(subclause)(object), false); } // Go through each key in where clause return object => _.reduce(where, (result, whereParams, key) => { const match = evaluateObje...
javascript
function queryFilter(where) { if (where.$or) { return object => _.reduce(where.$or, (result, subclause) => result || queryFilter(subclause)(object), false); } // Go through each key in where clause return object => _.reduce(where, (result, whereParams, key) => { const match = evaluateObje...
[ "function", "queryFilter", "(", "where", ")", "{", "if", "(", "where", ".", "$or", ")", "{", "return", "object", "=>", "_", ".", "reduce", "(", "where", ".", "$or", ",", "(", "result", ",", "subclause", ")", "=>", "result", "||", "queryFilter", "(", ...
Returns a function that filters query matches on a where clause
[ "Returns", "a", "function", "that", "filters", "query", "matches", "on", "a", "where", "clause" ]
b33a113debcba3c80477b50c7fae557f5941d494
https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L445-L457
33,622
Hustle/parse-mockdb
src/parse-mockdb.js
fetchObjectByPointer
function fetchObjectByPointer(pointer) { const collection = getCollection(pointer.className); const storedItem = collection[pointer.objectId]; if (storedItem === undefined) { return undefined; } return Object.assign( { __type: 'Object', className: pointer.className }, _.cloneDeep(storedItem) )...
javascript
function fetchObjectByPointer(pointer) { const collection = getCollection(pointer.className); const storedItem = collection[pointer.objectId]; if (storedItem === undefined) { return undefined; } return Object.assign( { __type: 'Object', className: pointer.className }, _.cloneDeep(storedItem) )...
[ "function", "fetchObjectByPointer", "(", "pointer", ")", "{", "const", "collection", "=", "getCollection", "(", "pointer", ".", "className", ")", ";", "const", "storedItem", "=", "collection", "[", "pointer", ".", "objectId", "]", ";", "if", "(", "storedItem",...
Given an object, a pointer, or a JSON representation of a Parse Object, return a fully fetched version of the Object.
[ "Given", "an", "object", "a", "pointer", "or", "a", "JSON", "representation", "of", "a", "Parse", "Object", "return", "a", "fully", "fetched", "version", "of", "the", "Object", "." ]
b33a113debcba3c80477b50c7fae557f5941d494
https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L512-L524
33,623
Hustle/parse-mockdb
src/parse-mockdb.js
includePaths
function includePaths(object, pathsRemaining) { debugPrint('INCLUDE', { object, pathsRemaining }); const path = pathsRemaining.shift(); const target = object && object[path]; if (target) { if (Array.isArray(target)) { object[path] = target.map(pointer => { const fetched = fetchObjectByPointer...
javascript
function includePaths(object, pathsRemaining) { debugPrint('INCLUDE', { object, pathsRemaining }); const path = pathsRemaining.shift(); const target = object && object[path]; if (target) { if (Array.isArray(target)) { object[path] = target.map(pointer => { const fetched = fetchObjectByPointer...
[ "function", "includePaths", "(", "object", ",", "pathsRemaining", ")", "{", "debugPrint", "(", "'INCLUDE'", ",", "{", "object", ",", "pathsRemaining", "}", ")", ";", "const", "path", "=", "pathsRemaining", ".", "shift", "(", ")", ";", "const", "target", "=...
Recursive function that traverses an include path and replaces pointers with fully fetched objects
[ "Recursive", "function", "that", "traverses", "an", "include", "path", "and", "replaces", "pointers", "with", "fully", "fetched", "objects" ]
b33a113debcba3c80477b50c7fae557f5941d494
https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L530-L551
33,624
Hustle/parse-mockdb
src/parse-mockdb.js
sortQueryresults
function sortQueryresults(matches, order) { const orderArray = order.split(',').map(k => { let dir = 'asc'; let key = k; if (k.charAt(0) === '-') { key = k.substring(1); dir = 'desc'; } return [item => deserializeQueryParam(item[key]), dir]; }); const keys = orderArray.map(_.fir...
javascript
function sortQueryresults(matches, order) { const orderArray = order.split(',').map(k => { let dir = 'asc'; let key = k; if (k.charAt(0) === '-') { key = k.substring(1); dir = 'desc'; } return [item => deserializeQueryParam(item[key]), dir]; }); const keys = orderArray.map(_.fir...
[ "function", "sortQueryresults", "(", "matches", ",", "order", ")", "{", "const", "orderArray", "=", "order", ".", "split", "(", "','", ")", ".", "map", "(", "k", "=>", "{", "let", "dir", "=", "'asc'", ";", "let", "key", "=", "k", ";", "if", "(", ...
Sort query results if necessary
[ "Sort", "query", "results", "if", "necessary" ]
b33a113debcba3c80477b50c7fae557f5941d494
https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L578-L595
33,625
Hustle/parse-mockdb
src/parse-mockdb.js
runHook
function runHook(className, hookType, data) { let hook = getHook(className, hookType); if (hook) { const hydrate = (rawData) => { const modelData = Object.assign({}, rawData, { className }); const modelJSON = _.mapValues(modelData, // Convert dates into JSON loadable representations ...
javascript
function runHook(className, hookType, data) { let hook = getHook(className, hookType); if (hook) { const hydrate = (rawData) => { const modelData = Object.assign({}, rawData, { className }); const modelJSON = _.mapValues(modelData, // Convert dates into JSON loadable representations ...
[ "function", "runHook", "(", "className", ",", "hookType", ",", "data", ")", "{", "let", "hook", "=", "getHook", "(", "className", ",", "hookType", ")", ";", "if", "(", "hook", ")", "{", "const", "hydrate", "=", "(", "rawData", ")", "=>", "{", "const"...
Executes a registered hook with data provided. Hydrates the data into an instance of the class named by `className` param and binds it to the function to be run. @param {string} className The name of the class to get the hook on. @param {string} hookType One of 'beforeSave', 'afterSave', 'beforeDelete', 'afterDelete'...
[ "Executes", "a", "registered", "hook", "with", "data", "provided", "." ]
b33a113debcba3c80477b50c7fae557f5941d494
https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/parse-mockdb.js#L680-L714
33,626
CiscoDevNet/node-sparkbot
sparkbot/webhook.js
compareWebhooks
function compareWebhooks(webhook, name, targetUrl, resource, event, filter, secret) { if ((webhook.name !== name) || (webhook.targetUrl !== targetUrl) || (webhook.resource !== resource) || (webhook.event !== event)) { return false; } // they look pretty identifty, let's check optional fields if (filter) { i...
javascript
function compareWebhooks(webhook, name, targetUrl, resource, event, filter, secret) { if ((webhook.name !== name) || (webhook.targetUrl !== targetUrl) || (webhook.resource !== resource) || (webhook.event !== event)) { return false; } // they look pretty identifty, let's check optional fields if (filter) { i...
[ "function", "compareWebhooks", "(", "webhook", ",", "name", ",", "targetUrl", ",", "resource", ",", "event", ",", "filter", ",", "secret", ")", "{", "if", "(", "(", "webhook", ".", "name", "!==", "name", ")", "||", "(", "webhook", ".", "targetUrl", "!=...
returns true if webhooks are identical
[ "returns", "true", "if", "webhooks", "are", "identical" ]
d307b2955b7258cf34089041ac12dc48f96db5ca
https://github.com/CiscoDevNet/node-sparkbot/blob/d307b2955b7258cf34089041ac12dc48f96db5ca/sparkbot/webhook.js#L483-L518
33,627
Vincit/dodo.js
lib/errors/http-error.js
HTTPError
function HTTPError(statusCode, data) { Error.call(this); Error.captureStackTrace(this, this.constructor); /** * Human-readable error name. * * @type {String} */ this.name = http.STATUS_CODES[statusCode]; /** * HTTP status code. * * @type {Number} */ this.statusCode = statusCode; ...
javascript
function HTTPError(statusCode, data) { Error.call(this); Error.captureStackTrace(this, this.constructor); /** * Human-readable error name. * * @type {String} */ this.name = http.STATUS_CODES[statusCode]; /** * HTTP status code. * * @type {Number} */ this.statusCode = statusCode; ...
[ "function", "HTTPError", "(", "statusCode", ",", "data", ")", "{", "Error", ".", "call", "(", "this", ")", ";", "Error", ".", "captureStackTrace", "(", "this", ",", "this", ".", "constructor", ")", ";", "/**\n * Human-readable error name.\n *\n * @type {Stri...
Base class for errors. @param {Number} statusCode HTTP status code. @param {*=} data Any additional data. @extends Error @constructor
[ "Base", "class", "for", "errors", "." ]
01c4b7a1139af8442dad945bfb21d8bc8ba4031b
https://github.com/Vincit/dodo.js/blob/01c4b7a1139af8442dad945bfb21d8bc8ba4031b/lib/errors/http-error.js#L18-L47
33,628
Vincit/dodo.js
lib/app/plugins.js
function (config) { return _.map(config.features, function(featureDef) { var feature = null , featurePath = null; var featureId = featureDef.$featureId || featureDef.feature; // Try to require the feature from each path listed in `config.featurePaths`. for (var i = 0; i < config.fe...
javascript
function (config) { return _.map(config.features, function(featureDef) { var feature = null , featurePath = null; var featureId = featureDef.$featureId || featureDef.feature; // Try to require the feature from each path listed in `config.featurePaths`. for (var i = 0; i < config.fe...
[ "function", "(", "config", ")", "{", "return", "_", ".", "map", "(", "config", ".", "features", ",", "function", "(", "featureDef", ")", "{", "var", "feature", "=", "null", ",", "featurePath", "=", "null", ";", "var", "featureId", "=", "featureDef", "....
Load features of configuration to get plugin tasks etc.
[ "Load", "features", "of", "configuration", "to", "get", "plugin", "tasks", "etc", "." ]
01c4b7a1139af8442dad945bfb21d8bc8ba4031b
https://github.com/Vincit/dodo.js/blob/01c4b7a1139af8442dad945bfb21d8bc8ba4031b/lib/app/plugins.js#L22-L54
33,629
Hustle/parse-mockdb
src/crypto.js
randomHexString
function randomHexString(size) { if (size === 0) { throw new Error('Zero-length randomHexString is useless.'); } if (size % 2 !== 0) { throw new Error('randomHexString size must be divisible by 2.'); } return crypto.randomBytes(size / 2).toString('hex'); }
javascript
function randomHexString(size) { if (size === 0) { throw new Error('Zero-length randomHexString is useless.'); } if (size % 2 !== 0) { throw new Error('randomHexString size must be divisible by 2.'); } return crypto.randomBytes(size / 2).toString('hex'); }
[ "function", "randomHexString", "(", "size", ")", "{", "if", "(", "size", "===", "0", ")", "{", "throw", "new", "Error", "(", "'Zero-length randomHexString is useless.'", ")", ";", "}", "if", "(", "size", "%", "2", "!==", "0", ")", "{", "throw", "new", ...
Returns a new random hex string of the given even size.
[ "Returns", "a", "new", "random", "hex", "string", "of", "the", "given", "even", "size", "." ]
b33a113debcba3c80477b50c7fae557f5941d494
https://github.com/Hustle/parse-mockdb/blob/b33a113debcba3c80477b50c7fae557f5941d494/src/crypto.js#L5-L13
33,630
erikschlegel/React-Twitter-Typeahead
lib/js/react-typeahead.js
function () { var defaultMinLength = 2, config = {}; if(!this.props.bloodhound) this.props.bloodhound = {}; if(!this.props.typeahead) this.props.typeahead = {}; if(!this.props.datasource) this.props.datasource = {}; var defaults = { bloodhound: { ...
javascript
function () { var defaultMinLength = 2, config = {}; if(!this.props.bloodhound) this.props.bloodhound = {}; if(!this.props.typeahead) this.props.typeahead = {}; if(!this.props.datasource) this.props.datasource = {}; var defaults = { bloodhound: { ...
[ "function", "(", ")", "{", "var", "defaultMinLength", "=", "2", ",", "config", "=", "{", "}", ";", "if", "(", "!", "this", ".", "props", ".", "bloodhound", ")", "this", ".", "props", ".", "bloodhound", "=", "{", "}", ";", "if", "(", "!", "this", ...
'initOptions' method This method sets up the typeahead with initial config parameters. The first set is default and the other set is defined by the
[ "initOptions", "method", "This", "method", "sets", "up", "the", "typeahead", "with", "initial", "config", "parameters", ".", "The", "first", "set", "is", "default", "and", "the", "other", "set", "is", "defined", "by", "the" ]
d0fe9fb751ae113b44a3a8dcd5d29efbf2476713
https://github.com/erikschlegel/React-Twitter-Typeahead/blob/d0fe9fb751ae113b44a3a8dcd5d29efbf2476713/lib/js/react-typeahead.js#L13-L44
33,631
erikschlegel/React-Twitter-Typeahead
lib/js/react-typeahead.js
function () { var self = this, options = this.initOptions(); var remoteCall = new Bloodhound(options.bloodhound); options.datasource.source = remoteCall; var typeaheadInput = React.findDOMNode(self); if(typeaheadInput) this.typeahead = $(typeaheadInput).type...
javascript
function () { var self = this, options = this.initOptions(); var remoteCall = new Bloodhound(options.bloodhound); options.datasource.source = remoteCall; var typeaheadInput = React.findDOMNode(self); if(typeaheadInput) this.typeahead = $(typeaheadInput).type...
[ "function", "(", ")", "{", "var", "self", "=", "this", ",", "options", "=", "this", ".", "initOptions", "(", ")", ";", "var", "remoteCall", "=", "new", "Bloodhound", "(", "options", ".", "bloodhound", ")", ";", "options", ".", "datasource", ".", "sourc...
'componentDidMount' method Initializes react with the typeahead component.
[ "componentDidMount", "method", "Initializes", "react", "with", "the", "typeahead", "component", "." ]
d0fe9fb751ae113b44a3a8dcd5d29efbf2476713
https://github.com/erikschlegel/React-Twitter-Typeahead/blob/d0fe9fb751ae113b44a3a8dcd5d29efbf2476713/lib/js/react-typeahead.js#L65-L76
33,632
uber-node/zero-config
read-datacenter.js
readFileOrError
function readFileOrError(uri) { var content; try { content = fs.readFileSync(uri, 'utf8'); } catch (err) { return Result.Err(err); } return Result.Ok(content); }
javascript
function readFileOrError(uri) { var content; try { content = fs.readFileSync(uri, 'utf8'); } catch (err) { return Result.Err(err); } return Result.Ok(content); }
[ "function", "readFileOrError", "(", "uri", ")", "{", "var", "content", ";", "try", "{", "content", "=", "fs", ".", "readFileSync", "(", "uri", ",", "'utf8'", ")", ";", "}", "catch", "(", "err", ")", "{", "return", "Result", ".", "Err", "(", "err", ...
break try catch into small function to avoid v8 de-optimization
[ "break", "try", "catch", "into", "small", "function", "to", "avoid", "v8", "de", "-", "optimization" ]
214e3da207e3f3648f2070ee895b1345ef4415cf
https://github.com/uber-node/zero-config/blob/214e3da207e3f3648f2070ee895b1345ef4415cf/read-datacenter.js#L60-L69
33,633
nyxtom/salient
lib/salient/graph/document.js
DocumentGraph
function DocumentGraph(options) { this.options = object.extend(defaultOptions, options || {}); this._gloss = new Glossary(); // Parse redis cluster configuration in the form of: // "host:port,host:port,host:port" if (this.options.redisCluster) { var addresses = this.options.redisCluster...
javascript
function DocumentGraph(options) { this.options = object.extend(defaultOptions, options || {}); this._gloss = new Glossary(); // Parse redis cluster configuration in the form of: // "host:port,host:port,host:port" if (this.options.redisCluster) { var addresses = this.options.redisCluster...
[ "function", "DocumentGraph", "(", "options", ")", "{", "this", ".", "options", "=", "object", ".", "extend", "(", "defaultOptions", ",", "options", "||", "{", "}", ")", ";", "this", ".", "_gloss", "=", "new", "Glossary", "(", ")", ";", "// Parse redis cl...
DocumentGraph represents a client for processing documents in order to process document text in order to build a graph of connections between document ids, text, parts of speech context and the language as it is presented through the data.
[ "DocumentGraph", "represents", "a", "client", "for", "processing", "documents", "in", "order", "to", "process", "document", "text", "in", "order", "to", "build", "a", "graph", "of", "connections", "between", "document", "ids", "text", "parts", "of", "speech", ...
56e3e6cded9e5f97d9536aacdcaa588849e6a259
https://github.com/nyxtom/salient/blob/56e3e6cded9e5f97d9536aacdcaa588849e6a259/lib/salient/graph/document.js#L45-L77
33,634
nyxtom/salient
lib/salient/graph/document.js
function(err, results) { if (err) { callback(err); return; } var keyFrequency = parseInt(results[0]); var docFrequency = parseInt(results[1]); var keyDocFrequency = results[2]; // ensure that key frequency is relative to the given documen...
javascript
function(err, results) { if (err) { callback(err); return; } var keyFrequency = parseInt(results[0]); var docFrequency = parseInt(results[1]); var keyDocFrequency = results[2]; // ensure that key frequency is relative to the given documen...
[ "function", "(", "err", ",", "results", ")", "{", "if", "(", "err", ")", "{", "callback", "(", "err", ")", ";", "return", ";", "}", "var", "keyFrequency", "=", "parseInt", "(", "results", "[", "0", "]", ")", ";", "var", "docFrequency", "=", "parseI...
Executes and handles results returned from the multi redis command below
[ "Executes", "and", "handles", "results", "returned", "from", "the", "multi", "redis", "command", "below" ]
56e3e6cded9e5f97d9536aacdcaa588849e6a259
https://github.com/nyxtom/salient/blob/56e3e6cded9e5f97d9536aacdcaa588849e6a259/lib/salient/graph/document.js#L709-L735
33,635
fandogh/nuxt-helpers
lib/axios/plugin.js
onError
function onError(e) { if (!inBrowser) { return {}; } let response = {}; if (e.response) { response = e.response.data; } throw Object.assign({ statusCode: 500, message: 'Request error' }, response); }
javascript
function onError(e) { if (!inBrowser) { return {}; } let response = {}; if (e.response) { response = e.response.data; } throw Object.assign({ statusCode: 500, message: 'Request error' }, response); }
[ "function", "onError", "(", "e", ")", "{", "if", "(", "!", "inBrowser", ")", "{", "return", "{", "}", ";", "}", "let", "response", "=", "{", "}", ";", "if", "(", "e", ".", "response", ")", "{", "response", "=", "e", ".", "response", ".", "data"...
Throw nice http errors & keep SSR safe
[ "Throw", "nice", "http", "errors", "&", "keep", "SSR", "safe" ]
0a4b22fae2737fe452b82681e04a6a34fc591ac2
https://github.com/fandogh/nuxt-helpers/blob/0a4b22fae2737fe452b82681e04a6a34fc591ac2/lib/axios/plugin.js#L14-L28
33,636
Vincit/dodo.js
lib/app/express/main.js
function(config) { var app = null; try { app = module.exports.createApp(config); } catch (err) { // wrap also synchronous error to promise to have consistent API for catching all errors return Promise.reject(err); } return module.exports.startApp(app); }
javascript
function(config) { var app = null; try { app = module.exports.createApp(config); } catch (err) { // wrap also synchronous error to promise to have consistent API for catching all errors return Promise.reject(err); } return module.exports.startApp(app); }
[ "function", "(", "config", ")", "{", "var", "app", "=", "null", ";", "try", "{", "app", "=", "module", ".", "exports", ".", "createApp", "(", "config", ")", ";", "}", "catch", "(", "err", ")", "{", "// wrap also synchronous error to promise to have consisten...
Creates and starts the server with the given config. @param {Object} config The config object for a service. See README.md for documentation about config files. @returns {Promise}
[ "Creates", "and", "starts", "the", "server", "with", "the", "given", "config", "." ]
01c4b7a1139af8442dad945bfb21d8bc8ba4031b
https://github.com/Vincit/dodo.js/blob/01c4b7a1139af8442dad945bfb21d8bc8ba4031b/lib/app/express/main.js#L130-L139
33,637
Vincit/dodo.js
lib/app/express/main.js
function(app) { var config = app.config; var testing = config.profile === 'testing'; var starterPromise = startServer(app).then(logStartup); if (!testing) { starterPromise = starterPromise.catch(logError); } return starterPromise; }
javascript
function(app) { var config = app.config; var testing = config.profile === 'testing'; var starterPromise = startServer(app).then(logStartup); if (!testing) { starterPromise = starterPromise.catch(logError); } return starterPromise; }
[ "function", "(", "app", ")", "{", "var", "config", "=", "app", ".", "config", ";", "var", "testing", "=", "config", ".", "profile", "===", "'testing'", ";", "var", "starterPromise", "=", "startServer", "(", "app", ")", ".", "then", "(", "logStartup", "...
Starts the given app. @param {Object} app An app instance created using `createApp`. @returns {Promise}
[ "Starts", "the", "given", "app", "." ]
01c4b7a1139af8442dad945bfb21d8bc8ba4031b
https://github.com/Vincit/dodo.js/blob/01c4b7a1139af8442dad945bfb21d8bc8ba4031b/lib/app/express/main.js#L149-L157
33,638
ethjs/ethjs-signer
src/index.js
recover
function recover(rawTx, v, r, s) { const rawTransaction = typeof(rawTx) === 'string' ? new Buffer(stripHexPrefix(rawTx), 'hex') : rawTx; const signedTransaction = rlp.decode(rawTransaction); const raw = []; transactionFields.forEach((fieldInfo, fieldIndex) => { raw[fieldIndex] = signedTransaction[fieldInde...
javascript
function recover(rawTx, v, r, s) { const rawTransaction = typeof(rawTx) === 'string' ? new Buffer(stripHexPrefix(rawTx), 'hex') : rawTx; const signedTransaction = rlp.decode(rawTransaction); const raw = []; transactionFields.forEach((fieldInfo, fieldIndex) => { raw[fieldIndex] = signedTransaction[fieldInde...
[ "function", "recover", "(", "rawTx", ",", "v", ",", "r", ",", "s", ")", "{", "const", "rawTransaction", "=", "typeof", "(", "rawTx", ")", "===", "'string'", "?", "new", "Buffer", "(", "stripHexPrefix", "(", "rawTx", ")", ",", "'hex'", ")", ":", "rawT...
ECDSA public key recovery from a rawTransaction @method recover @param {String|Buffer} rawTransaction either a hex string or buffer instance @param {Number} v @param {Buffer} r @param {Buffer} s @return {Buffer} publicKey
[ "ECDSA", "public", "key", "recovery", "from", "a", "rawTransaction" ]
8739b3eb08714da5749175f3f5c1096e3046fe87
https://github.com/ethjs/ethjs-signer/blob/8739b3eb08714da5749175f3f5c1096e3046fe87/src/index.js#L44-L55
33,639
ethjs/ethjs-signer
src/index.js
sign
function sign(transaction, privateKey, toObject) { if (typeof transaction !== 'object' || transaction === null) { throw new Error(`[ethjs-signer] transaction input must be a type 'object', got '${typeof(transaction)}'`); } if (typeof privateKey !== 'string') { throw new Error('[ethjs-signer] private key input must ...
javascript
function sign(transaction, privateKey, toObject) { if (typeof transaction !== 'object' || transaction === null) { throw new Error(`[ethjs-signer] transaction input must be a type 'object', got '${typeof(transaction)}'`); } if (typeof privateKey !== 'string') { throw new Error('[ethjs-signer] private key input must ...
[ "function", "sign", "(", "transaction", ",", "privateKey", ",", "toObject", ")", "{", "if", "(", "typeof", "transaction", "!==", "'object'", "||", "transaction", "===", "null", ")", "{", "throw", "new", "Error", "(", "`", "${", "typeof", "(", "transaction"...
Will sign a raw transaction and return it either as a serlized hex string or raw tx object. @method sign @param {Object} transaction a valid transaction object @param {String} privateKey a valid 32 byte prefixed hex string private key @param {Boolean} toObject **Optional** @returns {String|Object} output either a seri...
[ "Will", "sign", "a", "raw", "transaction", "and", "return", "it", "either", "as", "a", "serlized", "hex", "string", "or", "raw", "tx", "object", "." ]
8739b3eb08714da5749175f3f5c1096e3046fe87
https://github.com/ethjs/ethjs-signer/blob/8739b3eb08714da5749175f3f5c1096e3046fe87/src/index.js#L67-L113
33,640
powmedia/mongoose-fixtures
mongoose_fixtures.js
insertCollection
function insertCollection(modelName, data, db, callback) { callback = callback || {}; //Counters for managing callbacks var tasks = { total: 0, done: 0 }; //Load model var Model = db.model(modelName); //Clear existing collection Model.collection.remove(function(err) { ...
javascript
function insertCollection(modelName, data, db, callback) { callback = callback || {}; //Counters for managing callbacks var tasks = { total: 0, done: 0 }; //Load model var Model = db.model(modelName); //Clear existing collection Model.collection.remove(function(err) { ...
[ "function", "insertCollection", "(", "modelName", ",", "data", ",", "db", ",", "callback", ")", "{", "callback", "=", "callback", "||", "{", "}", ";", "//Counters for managing callbacks", "var", "tasks", "=", "{", "total", ":", "0", ",", "done", ":", "0", ...
Clears a collection and inserts the given data as new documents @param {String} The name of the model e.g. User, Post etc. @param {Object} The data to insert, as an array or object. E.g.: { user1: {name: 'Alex'}, user2: {name: 'Bob'} } or: [ {name: 'Alex'}, {name:'Bob'} ] @param {Connection} The mongoose co...
[ "Clears", "a", "collection", "and", "inserts", "the", "given", "data", "as", "new", "documents" ]
29e4ff333913636dfee96ed6a9a40bef4551f60d
https://github.com/powmedia/mongoose-fixtures/blob/29e4ff333913636dfee96ed6a9a40bef4551f60d/mongoose_fixtures.js#L66-L108
33,641
powmedia/mongoose-fixtures
mongoose_fixtures.js
loadObject
function loadObject(data, db, callback) { callback = callback || function() {}; var iterator = function(modelName, next){ insertCollection(modelName, data[modelName], db, next); }; async.forEachSeries(Object.keys(data), iterator, callback); }
javascript
function loadObject(data, db, callback) { callback = callback || function() {}; var iterator = function(modelName, next){ insertCollection(modelName, data[modelName], db, next); }; async.forEachSeries(Object.keys(data), iterator, callback); }
[ "function", "loadObject", "(", "data", ",", "db", ",", "callback", ")", "{", "callback", "=", "callback", "||", "function", "(", ")", "{", "}", ";", "var", "iterator", "=", "function", "(", "modelName", ",", "next", ")", "{", "insertCollection", "(", "...
Loads fixtures from object data @param {Object} The data to load, keyed by the Mongoose model name e.g.: { User: [{name: 'Alex'}, {name: 'Bob'}] } @param {Connection} The mongoose connection to use @param {Function} Callback
[ "Loads", "fixtures", "from", "object", "data" ]
29e4ff333913636dfee96ed6a9a40bef4551f60d
https://github.com/powmedia/mongoose-fixtures/blob/29e4ff333913636dfee96ed6a9a40bef4551f60d/mongoose_fixtures.js#L119-L125
33,642
powmedia/mongoose-fixtures
mongoose_fixtures.js
loadFile
function loadFile(file, db, callback) { callback = callback || function() {}; if (file.substr(0, 1) !== '/') { var parentPath = module.parent.filename.split('/'); parentPath.pop(); file = parentPath.join('/') + '/' + file; } load(require(file), db, callback); }
javascript
function loadFile(file, db, callback) { callback = callback || function() {}; if (file.substr(0, 1) !== '/') { var parentPath = module.parent.filename.split('/'); parentPath.pop(); file = parentPath.join('/') + '/' + file; } load(require(file), db, callback); }
[ "function", "loadFile", "(", "file", ",", "db", ",", "callback", ")", "{", "callback", "=", "callback", "||", "function", "(", ")", "{", "}", ";", "if", "(", "file", ".", "substr", "(", "0", ",", "1", ")", "!==", "'/'", ")", "{", "var", "parentPa...
Loads fixtures from one file TODO: Add callback option @param {String} The full path to the file to load @param {Connection} The mongoose connection to use @param {Function} Callback
[ "Loads", "fixtures", "from", "one", "file" ]
29e4ff333913636dfee96ed6a9a40bef4551f60d
https://github.com/powmedia/mongoose-fixtures/blob/29e4ff333913636dfee96ed6a9a40bef4551f60d/mongoose_fixtures.js#L137-L147
33,643
powmedia/mongoose-fixtures
mongoose_fixtures.js
loadDir
function loadDir(dir, db, callback) { callback = callback || function() {}; //Get the absolute dir path if a relative path was given if (dir.substr(0, 1) !== '/') { var parentPath = module.parent.filename.split('/'); parentPath.pop(); dir = parentPath.join('/') + '/' + dir; ...
javascript
function loadDir(dir, db, callback) { callback = callback || function() {}; //Get the absolute dir path if a relative path was given if (dir.substr(0, 1) !== '/') { var parentPath = module.parent.filename.split('/'); parentPath.pop(); dir = parentPath.join('/') + '/' + dir; ...
[ "function", "loadDir", "(", "dir", ",", "db", ",", "callback", ")", "{", "callback", "=", "callback", "||", "function", "(", ")", "{", "}", ";", "//Get the absolute dir path if a relative path was given", "if", "(", "dir", ".", "substr", "(", "0", ",", "1", ...
Loads fixtures from all files in a directory TODO: Add callback option @param {String} The directory path to load e.g. 'data/fixtures' or '../data' @param {Connection} The mongoose connection to use @param {Function} Callback
[ "Loads", "fixtures", "from", "all", "files", "in", "a", "directory" ]
29e4ff333913636dfee96ed6a9a40bef4551f60d
https://github.com/powmedia/mongoose-fixtures/blob/29e4ff333913636dfee96ed6a9a40bef4551f60d/mongoose_fixtures.js#L159-L178
33,644
cultureamp/elm-css-modules-loader
ci/publishElmRelease.js
tagElmRelease
async function tagElmRelease(config, context) { function exec(command) { context.logger.log(`Running: ${command}`); execSync(command); } const elmPackageJson = JSON.parse(fs.readFileSync('elm.json')); await tag(elmPackageJson.version); const repositoryUrl = await getGitAuthUrl(config); await push(r...
javascript
async function tagElmRelease(config, context) { function exec(command) { context.logger.log(`Running: ${command}`); execSync(command); } const elmPackageJson = JSON.parse(fs.readFileSync('elm.json')); await tag(elmPackageJson.version); const repositoryUrl = await getGitAuthUrl(config); await push(r...
[ "async", "function", "tagElmRelease", "(", "config", ",", "context", ")", "{", "function", "exec", "(", "command", ")", "{", "context", ".", "logger", ".", "log", "(", "`", "${", "command", "}", "`", ")", ";", "execSync", "(", "command", ")", ";", "}...
A semantic release "publish" plugin to create tags and run `elm-package publish`.
[ "A", "semantic", "release", "publish", "plugin", "to", "create", "tags", "and", "run", "elm", "-", "package", "publish", "." ]
93a702e272bed758128b11ee14cb849de0ffa7a2
https://github.com/cultureamp/elm-css-modules-loader/blob/93a702e272bed758128b11ee14cb849de0ffa7a2/ci/publishElmRelease.js#L9-L28
33,645
mongodb-js/dataset-generator
lib/schema/entry.js
Entry
function Entry (content, name, parent) { if (!(this instanceof Entry)) return new Entry(content, name, parent); this._parent = parent; // parent can be a Document or ArrayField this._schema = parent._schema; // the root Document this._name = name; // the field name supplied by the user this._hidden = isHidde...
javascript
function Entry (content, name, parent) { if (!(this instanceof Entry)) return new Entry(content, name, parent); this._parent = parent; // parent can be a Document or ArrayField this._schema = parent._schema; // the root Document this._name = name; // the field name supplied by the user this._hidden = isHidde...
[ "function", "Entry", "(", "content", ",", "name", ",", "parent", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Entry", ")", ")", "return", "new", "Entry", "(", "content", ",", "name", ",", "parent", ")", ";", "this", ".", "_parent", "=", "p...
High level representation of all fields in template schemas @class @abstract @memberOf module:schema @param {*} content @param {string} name @param {(Entry|Schema)} parent
[ "High", "level", "representation", "of", "all", "fields", "in", "template", "schemas" ]
0f56410970a8dc03433477966dafa16a5cbd9cda
https://github.com/mongodb-js/dataset-generator/blob/0f56410970a8dc03433477966dafa16a5cbd9cda/lib/schema/entry.js#L12-L24
33,646
hoodiehq/hoodie-store-client
lib/remove.js
remove
function remove (state, prefix, objectsOrIds, change) { if (Array.isArray(objectsOrIds)) { return Promise.all(objectsOrIds.map(markAsDeleted.bind(null, state, change))) .then(function (docs) { return updateMany(state, docs, null, prefix) }) } return markAsDeleted(state, change, objectsOrIds) ...
javascript
function remove (state, prefix, objectsOrIds, change) { if (Array.isArray(objectsOrIds)) { return Promise.all(objectsOrIds.map(markAsDeleted.bind(null, state, change))) .then(function (docs) { return updateMany(state, docs, null, prefix) }) } return markAsDeleted(state, change, objectsOrIds) ...
[ "function", "remove", "(", "state", ",", "prefix", ",", "objectsOrIds", ",", "change", ")", "{", "if", "(", "Array", ".", "isArray", "(", "objectsOrIds", ")", ")", "{", "return", "Promise", ".", "all", "(", "objectsOrIds", ".", "map", "(", "markAsDeleted...
removes existing object @param {String} prefix optional id prefix @param {Object|Function} objectsOrIds id or object with `._id` property @param {Object|Function} [change] Change properties or function that changes existing object @return {Promise}
[ "removes", "existing", "object" ]
a0043e6b73a5ee90675fb02be78edfceef94a6b1
https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/remove.js#L17-L31
33,647
mongodb-js/dataset-generator
lib/schema/field.js
Field
function Field (field, name, parent) { if (!(this instanceof Field)) return new Field(field, name, parent); debug('field <%s> being built from <%s>', name, field); Entry.call(this, field, name, parent); this._context = parent._context; this._this = parent._this; if (typeof this._content !== 'string') { ...
javascript
function Field (field, name, parent) { if (!(this instanceof Field)) return new Field(field, name, parent); debug('field <%s> being built from <%s>', name, field); Entry.call(this, field, name, parent); this._context = parent._context; this._this = parent._this; if (typeof this._content !== 'string') { ...
[ "function", "Field", "(", "field", ",", "name", ",", "parent", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Field", ")", ")", "return", "new", "Field", "(", "field", ",", "name", ",", "parent", ")", ";", "debug", "(", "'field <%s> being built ...
Internal representation of non-object non-array fields in template schema @class @augments {Entry} @memberOf module:schema @param {(string|number|boolean)} field @param {string} name @param {Entry} parent
[ "Internal", "representation", "of", "non", "-", "object", "non", "-", "array", "fields", "in", "template", "schema" ]
0f56410970a8dc03433477966dafa16a5cbd9cda
https://github.com/mongodb-js/dataset-generator/blob/0f56410970a8dc03433477966dafa16a5cbd9cda/lib/schema/field.js#L19-L34
33,648
gmetais/grunt-yellowlabtools
tasks/lib/conditions.js
function(results) { var globalScoreSum = 0; var globalScoreCount = 0; var rulesScoresSum = {}; var rulesScoresCount = {}; var rulesValuesSum = {}; var rulesValuesCount = {}; results.forEach(function(result) { // Global score globalScoreSum += result.scoreProfiles....
javascript
function(results) { var globalScoreSum = 0; var globalScoreCount = 0; var rulesScoresSum = {}; var rulesScoresCount = {}; var rulesValuesSum = {}; var rulesValuesCount = {}; results.forEach(function(result) { // Global score globalScoreSum += result.scoreProfiles....
[ "function", "(", "results", ")", "{", "var", "globalScoreSum", "=", "0", ";", "var", "globalScoreCount", "=", "0", ";", "var", "rulesScoresSum", "=", "{", "}", ";", "var", "rulesScoresCount", "=", "{", "}", ";", "var", "rulesValuesSum", "=", "{", "}", ...
Gets every score or value from all results and calculates their average NOT USED FOR THE MOMENT
[ "Gets", "every", "score", "or", "value", "from", "all", "results", "and", "calculates", "their", "average", "NOT", "USED", "FOR", "THE", "MOMENT" ]
cf6f73e060529c75c636289337288fda58dc1e9b
https://github.com/gmetais/grunt-yellowlabtools/blob/cf6f73e060529c75c636289337288fda58dc1e9b/tasks/lib/conditions.js#L152-L208
33,649
gmetais/grunt-yellowlabtools
tasks/lib/conditions.js
function(phrasesArray) { var deferred = Q.defer(); if (phrasesArray === undefined) { phrasesArray = []; } // Default conditionsObject var conditionsObject = { atLeastOneUrl: { ruleScores: [], ruleValues: [], ignoredRules: [] } }; ...
javascript
function(phrasesArray) { var deferred = Q.defer(); if (phrasesArray === undefined) { phrasesArray = []; } // Default conditionsObject var conditionsObject = { atLeastOneUrl: { ruleScores: [], ruleValues: [], ignoredRules: [] } }; ...
[ "function", "(", "phrasesArray", ")", "{", "var", "deferred", "=", "Q", ".", "defer", "(", ")", ";", "if", "(", "phrasesArray", "===", "undefined", ")", "{", "phrasesArray", "=", "[", "]", ";", "}", "// Default conditionsObject", "var", "conditionsObject", ...
Reads an array of phrases, understand them and transform them into a conditionsObject
[ "Reads", "an", "array", "of", "phrases", "understand", "them", "and", "transform", "them", "into", "a", "conditionsObject" ]
cf6f73e060529c75c636289337288fda58dc1e9b
https://github.com/gmetais/grunt-yellowlabtools/blob/cf6f73e060529c75c636289337288fda58dc1e9b/tasks/lib/conditions.js#L212-L268
33,650
christophertrudel/node_acl_knex
lib/knex-backend.js
function(bucket, key, cb){ contract(arguments) .params('string', 'string|number', 'function') .end() ; var table = ''; if (bucket.indexOf('allows') != -1) { table = this.prefix + this.buckets.permissions; this.db .select('key', 'value') .from(table) .where({'key': bucket}) .then(f...
javascript
function(bucket, key, cb){ contract(arguments) .params('string', 'string|number', 'function') .end() ; var table = ''; if (bucket.indexOf('allows') != -1) { table = this.prefix + this.buckets.permissions; this.db .select('key', 'value') .from(table) .where({'key': bucket}) .then(f...
[ "function", "(", "bucket", ",", "key", ",", "cb", ")", "{", "contract", "(", "arguments", ")", ".", "params", "(", "'string'", ",", "'string|number'", ",", "'function'", ")", ".", "end", "(", ")", ";", "var", "table", "=", "''", ";", "if", "(", "bu...
Gets the contents at the bucket's key.
[ "Gets", "the", "contents", "at", "the", "bucket", "s", "key", "." ]
38585647267553fbd6e117aca172585d62069fae
https://github.com/christophertrudel/node_acl_knex/blob/38585647267553fbd6e117aca172585d62069fae/lib/knex-backend.js#L57-L89
33,651
christophertrudel/node_acl_knex
lib/knex-backend.js
function(bucket, keys, cb){ contract(arguments) .params('string', 'array', 'function') .end() ; var table = ''; if (bucket.indexOf('allows') != -1) { table = this.prefix + this.buckets.permissions; this.db .select('key', 'value') .from(table) .where({'key': bucket}) .then(function...
javascript
function(bucket, keys, cb){ contract(arguments) .params('string', 'array', 'function') .end() ; var table = ''; if (bucket.indexOf('allows') != -1) { table = this.prefix + this.buckets.permissions; this.db .select('key', 'value') .from(table) .where({'key': bucket}) .then(function...
[ "function", "(", "bucket", ",", "keys", ",", "cb", ")", "{", "contract", "(", "arguments", ")", ".", "params", "(", "'string'", ",", "'array'", ",", "'function'", ")", ".", "end", "(", ")", ";", "var", "table", "=", "''", ";", "if", "(", "bucket", ...
Returns the union of the values in the given keys.
[ "Returns", "the", "union", "of", "the", "values", "in", "the", "given", "keys", "." ]
38585647267553fbd6e117aca172585d62069fae
https://github.com/christophertrudel/node_acl_knex/blob/38585647267553fbd6e117aca172585d62069fae/lib/knex-backend.js#L94-L139
33,652
christophertrudel/node_acl_knex
lib/knex-backend.js
function(transaction, bucket, key, values){ contract(arguments) .params('array', 'string', 'string|number','string|array|number') .end() ; var self = this; var table = ''; values = Array.isArray(values) ? values : [values]; // we always want to have an array for values transaction.push(function(...
javascript
function(transaction, bucket, key, values){ contract(arguments) .params('array', 'string', 'string|number','string|array|number') .end() ; var self = this; var table = ''; values = Array.isArray(values) ? values : [values]; // we always want to have an array for values transaction.push(function(...
[ "function", "(", "transaction", ",", "bucket", ",", "key", ",", "values", ")", "{", "contract", "(", "arguments", ")", ".", "params", "(", "'array'", ",", "'string'", ",", "'string|number'", ",", "'string|array|number'", ")", ".", "end", "(", ")", ";", "...
Adds values to a given key inside a table.
[ "Adds", "values", "to", "a", "given", "key", "inside", "a", "table", "." ]
38585647267553fbd6e117aca172585d62069fae
https://github.com/christophertrudel/node_acl_knex/blob/38585647267553fbd6e117aca172585d62069fae/lib/knex-backend.js#L144-L220
33,653
christophertrudel/node_acl_knex
lib/knex-backend.js
function(transaction, bucket, key, values){ contract(arguments) .params('array', 'string', 'string|number','string|array') .end() ; var self = this; var table = ''; values = Array.isArray(values) ? values : [values]; // we always want to have an array for values transaction.push(function(cb){ ...
javascript
function(transaction, bucket, key, values){ contract(arguments) .params('array', 'string', 'string|number','string|array') .end() ; var self = this; var table = ''; values = Array.isArray(values) ? values : [values]; // we always want to have an array for values transaction.push(function(cb){ ...
[ "function", "(", "transaction", ",", "bucket", ",", "key", ",", "values", ")", "{", "contract", "(", "arguments", ")", ".", "params", "(", "'array'", ",", "'string'", ",", "'string|number'", ",", "'string|array'", ")", ".", "end", "(", ")", ";", "var", ...
Removes values from a given key inside a bucket.
[ "Removes", "values", "from", "a", "given", "key", "inside", "a", "bucket", "." ]
38585647267553fbd6e117aca172585d62069fae
https://github.com/christophertrudel/node_acl_knex/blob/38585647267553fbd6e117aca172585d62069fae/lib/knex-backend.js#L286-L351
33,654
hoodiehq/hoodie-store-client
lib/find-all.js
findAll
function findAll (state, prefix, filter) { var options = { include_docs: true } if (prefix) { options.startkey = prefix options.endkey = prefix + '\uffff' } return state.db.allDocs(options) .then(function (res) { var objects = res.rows .filter(isntDesignDoc) .map(function (row...
javascript
function findAll (state, prefix, filter) { var options = { include_docs: true } if (prefix) { options.startkey = prefix options.endkey = prefix + '\uffff' } return state.db.allDocs(options) .then(function (res) { var objects = res.rows .filter(isntDesignDoc) .map(function (row...
[ "function", "findAll", "(", "state", ",", "prefix", ",", "filter", ")", "{", "var", "options", "=", "{", "include_docs", ":", "true", "}", "if", "(", "prefix", ")", "{", "options", ".", "startkey", "=", "prefix", "options", ".", "endkey", "=", "prefix"...
finds all existing objects in local database. @param {String} prefix optional id prefix @param {Function} [filter] Function returning `true` for any object to be returned. @return {Promise}
[ "finds", "all", "existing", "objects", "in", "local", "database", "." ]
a0043e6b73a5ee90675fb02be78edfceef94a6b1
https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/find-all.js#L14-L37
33,655
bojand/json-schema-deref-sync
lib/index.js
getRefSchema
function getRefSchema (refVal, refType, parent, options, state) { const loader = getLoader(refType, options) if (refType && loader) { let newVal let oldBasePath let loaderValue let filePath let fullRefFilePath if (refType === 'file') { filePath = utils.getRefFilePath(refVal) ful...
javascript
function getRefSchema (refVal, refType, parent, options, state) { const loader = getLoader(refType, options) if (refType && loader) { let newVal let oldBasePath let loaderValue let filePath let fullRefFilePath if (refType === 'file') { filePath = utils.getRefFilePath(refVal) ful...
[ "function", "getRefSchema", "(", "refVal", ",", "refType", ",", "parent", ",", "options", ",", "state", ")", "{", "const", "loader", "=", "getLoader", "(", "refType", ",", "options", ")", "if", "(", "refType", "&&", "loader", ")", "{", "let", "newVal", ...
Returns the reference schema that refVal points to. If the ref val points to a ref within a file, the file is loaded and fully derefed, before we get the pointing property. Derefed files are cached. @param refVal @param refType @param parent @param options @param state @private
[ "Returns", "the", "reference", "schema", "that", "refVal", "points", "to", ".", "If", "the", "ref", "val", "points", "to", "a", "ref", "within", "a", "file", "the", "file", "is", "loaded", "and", "fully", "derefed", "before", "we", "get", "the", "pointin...
10b1b3b94ffa27d8312537bbf540a59ac7aeaf27
https://github.com/bojand/json-schema-deref-sync/blob/10b1b3b94ffa27d8312537bbf540a59ac7aeaf27/lib/index.js#L36-L101
33,656
bojand/json-schema-deref-sync
lib/index.js
addToHistory
function addToHistory (state, type, value) { let dest if (type === 'file') { dest = utils.getRefFilePath(value) } else { if (value === '#') { return false } dest = state.current.concat(`:${value}`) } if (dest) { dest = dest.toLowerCase() if (state.history.indexOf(dest) >= 0) { ...
javascript
function addToHistory (state, type, value) { let dest if (type === 'file') { dest = utils.getRefFilePath(value) } else { if (value === '#') { return false } dest = state.current.concat(`:${value}`) } if (dest) { dest = dest.toLowerCase() if (state.history.indexOf(dest) >= 0) { ...
[ "function", "addToHistory", "(", "state", ",", "type", ",", "value", ")", "{", "let", "dest", "if", "(", "type", "===", "'file'", ")", "{", "dest", "=", "utils", ".", "getRefFilePath", "(", "value", ")", "}", "else", "{", "if", "(", "value", "===", ...
Add to state history @param {Object} state the state @param {String} type ref type @param {String} value ref value @private
[ "Add", "to", "state", "history" ]
10b1b3b94ffa27d8312537bbf540a59ac7aeaf27
https://github.com/bojand/json-schema-deref-sync/blob/10b1b3b94ffa27d8312537bbf540a59ac7aeaf27/lib/index.js#L110-L131
33,657
bojand/json-schema-deref-sync
lib/index.js
setCurrent
function setCurrent (state, type, value) { let dest if (type === 'file') { dest = utils.getRefFilePath(value) } if (dest) { state.current = dest } }
javascript
function setCurrent (state, type, value) { let dest if (type === 'file') { dest = utils.getRefFilePath(value) } if (dest) { state.current = dest } }
[ "function", "setCurrent", "(", "state", ",", "type", ",", "value", ")", "{", "let", "dest", "if", "(", "type", "===", "'file'", ")", "{", "dest", "=", "utils", ".", "getRefFilePath", "(", "value", ")", "}", "if", "(", "dest", ")", "{", "state", "."...
Set the current into state @param {Object} state the state @param {String} type ref type @param {String} value ref value @private
[ "Set", "the", "current", "into", "state" ]
10b1b3b94ffa27d8312537bbf540a59ac7aeaf27
https://github.com/bojand/json-schema-deref-sync/blob/10b1b3b94ffa27d8312537bbf540a59ac7aeaf27/lib/index.js#L140-L149
33,658
bojand/json-schema-deref-sync
lib/index.js
checkLocalCircular
function checkLocalCircular (schema) { const dag = new DAG() const locals = traverse(schema).reduce(function (acc, node) { if (!_.isNull(node) && !_.isUndefined(null) && typeof node.$ref === 'string') { const refType = utils.getRefType(node) if (refType === 'local') { const value = utils.get...
javascript
function checkLocalCircular (schema) { const dag = new DAG() const locals = traverse(schema).reduce(function (acc, node) { if (!_.isNull(node) && !_.isUndefined(null) && typeof node.$ref === 'string') { const refType = utils.getRefType(node) if (refType === 'local') { const value = utils.get...
[ "function", "checkLocalCircular", "(", "schema", ")", "{", "const", "dag", "=", "new", "DAG", "(", ")", "const", "locals", "=", "traverse", "(", "schema", ")", ".", "reduce", "(", "function", "(", "acc", ",", "node", ")", "{", "if", "(", "!", "_", ...
Check the schema for local circular refs using DAG @param {Object} schema the schema @return {Error|undefined} <code>Error</code> if circular ref, <code>undefined</code> otherwise if OK @private
[ "Check", "the", "schema", "for", "local", "circular", "refs", "using", "DAG" ]
10b1b3b94ffa27d8312537bbf540a59ac7aeaf27
https://github.com/bojand/json-schema-deref-sync/blob/10b1b3b94ffa27d8312537bbf540a59ac7aeaf27/lib/index.js#L157-L201
33,659
tykeal/ep_ldapauth
lib/MyLdapAuth.js
MyLdapAuth
function MyLdapAuth(opts) { this.opts = opts; assert.ok(opts.url); assert.ok(opts.searchBase); assert.ok(opts.searchFilter); // optional option: tls_ca this.log = opts.log4js && opts.log4js.getLogger('ldapauth'); var clientOpts = {url: opts.url}; if (opts.log4js && opts.verbose) { clientOpts.log4...
javascript
function MyLdapAuth(opts) { this.opts = opts; assert.ok(opts.url); assert.ok(opts.searchBase); assert.ok(opts.searchFilter); // optional option: tls_ca this.log = opts.log4js && opts.log4js.getLogger('ldapauth'); var clientOpts = {url: opts.url}; if (opts.log4js && opts.verbose) { clientOpts.log4...
[ "function", "MyLdapAuth", "(", "opts", ")", "{", "this", ".", "opts", "=", "opts", ";", "assert", ".", "ok", "(", "opts", ".", "url", ")", ";", "assert", ".", "ok", "(", "opts", ".", "searchBase", ")", ";", "assert", ".", "ok", "(", "opts", ".", ...
Create the MyLdapAuth class which is a former super class of LdapAuth until I ended up having to reimplement too much of it @param opts {Object} config options. Keys (required, unless stated otherwise) are: url {String} E.g. 'ldaps://ldap.example.com:663' adminDn {String} E.g. 'uid=myapp,ou=users,o=example.com' adminP...
[ "Create", "the", "MyLdapAuth", "class", "which", "is", "a", "former", "super", "class", "of", "LdapAuth", "until", "I", "ended", "up", "having", "to", "reimplement", "too", "much", "of", "it" ]
8ae8249334461720fe1d83b31f977c61870c878e
https://github.com/tykeal/ep_ldapauth/blob/8ae8249334461720fe1d83b31f977c61870c878e/lib/MyLdapAuth.js#L39-L53
33,660
hoodiehq/hoodie-store-client
lib/push.js
push
function push (state, docsOrIds) { var pushedObjects = [] var errors = state.db.constructor.Errors return Promise.resolve(state.remote) .then(function (remote) { return new Promise(function (resolve, reject) { if (Array.isArray(docsOrIds)) { docsOrIds = docsOrIds.map(toId) } else { ...
javascript
function push (state, docsOrIds) { var pushedObjects = [] var errors = state.db.constructor.Errors return Promise.resolve(state.remote) .then(function (remote) { return new Promise(function (resolve, reject) { if (Array.isArray(docsOrIds)) { docsOrIds = docsOrIds.map(toId) } else { ...
[ "function", "push", "(", "state", ",", "docsOrIds", ")", "{", "var", "pushedObjects", "=", "[", "]", "var", "errors", "=", "state", ".", "db", ".", "constructor", ".", "Errors", "return", "Promise", ".", "resolve", "(", "state", ".", "remote", ")", "."...
pushes one or multiple objects from local to remote database @param {StringOrObject} docsOrIds object or ID of object or array of objects/ids (all optional) @return {Promise}
[ "pushes", "one", "or", "multiple", "objects", "from", "local", "to", "remote", "database" ]
a0043e6b73a5ee90675fb02be78edfceef94a6b1
https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/push.js#L14-L56
33,661
hoodiehq/hoodie-store-client
lib/with-id-prefix.js
withIdPrefix
function withIdPrefix (state, prefix) { var emitter = new EventEmitter() var api = { add: require('./add').bind(null, state, prefix), find: require('./find').bind(null, state, prefix), findAll: require('./find-all').bind(null, state, prefix), findOrAdd: require('./find-or-add').bind(null, state, pr...
javascript
function withIdPrefix (state, prefix) { var emitter = new EventEmitter() var api = { add: require('./add').bind(null, state, prefix), find: require('./find').bind(null, state, prefix), findAll: require('./find-all').bind(null, state, prefix), findOrAdd: require('./find-or-add').bind(null, state, pr...
[ "function", "withIdPrefix", "(", "state", ",", "prefix", ")", "{", "var", "emitter", "=", "new", "EventEmitter", "(", ")", "var", "api", "=", "{", "add", ":", "require", "(", "'./add'", ")", ".", "bind", "(", "null", ",", "state", ",", "prefix", ")",...
returns API with all CRUD methods scoped to id prefix @param {String} prefix String all ID’s are implicitly prefixed or expected to be prefixed with.
[ "returns", "API", "with", "all", "CRUD", "methods", "scoped", "to", "id", "prefix" ]
a0043e6b73a5ee90675fb02be78edfceef94a6b1
https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/with-id-prefix.js#L12-L44
33,662
bojand/json-schema-deref-sync
lib/utils.js
getRefValue
function getRefValue (ref) { const thing = ref ? (ref.value ? ref.value : ref) : null if (thing && thing.$ref && typeof thing.$ref === 'string') { return thing.$ref } }
javascript
function getRefValue (ref) { const thing = ref ? (ref.value ? ref.value : ref) : null if (thing && thing.$ref && typeof thing.$ref === 'string') { return thing.$ref } }
[ "function", "getRefValue", "(", "ref", ")", "{", "const", "thing", "=", "ref", "?", "(", "ref", ".", "value", "?", "ref", ".", "value", ":", "ref", ")", ":", "null", "if", "(", "thing", "&&", "thing", ".", "$ref", "&&", "typeof", "thing", ".", "$...
Gets the ref value of a search result from prop-search or ref object @param ref The search result object from prop-search @returns {*} The value of $ref or undefined if not present in search object @private
[ "Gets", "the", "ref", "value", "of", "a", "search", "result", "from", "prop", "-", "search", "or", "ref", "object" ]
10b1b3b94ffa27d8312537bbf540a59ac7aeaf27
https://github.com/bojand/json-schema-deref-sync/blob/10b1b3b94ffa27d8312537bbf540a59ac7aeaf27/lib/utils.js#L13-L18
33,663
bojand/json-schema-deref-sync
lib/utils.js
getRefPathValue
function getRefPathValue (schema, refPath) { let rpath = refPath const hashIndex = refPath.indexOf('#') if (hashIndex >= 0) { rpath = refPath.substring(hashIndex) if (rpath.length > 1) { rpath = refPath.substring(1) } else { rpath = '' } } // Walk through each /-separated path com...
javascript
function getRefPathValue (schema, refPath) { let rpath = refPath const hashIndex = refPath.indexOf('#') if (hashIndex >= 0) { rpath = refPath.substring(hashIndex) if (rpath.length > 1) { rpath = refPath.substring(1) } else { rpath = '' } } // Walk through each /-separated path com...
[ "function", "getRefPathValue", "(", "schema", ",", "refPath", ")", "{", "let", "rpath", "=", "refPath", "const", "hashIndex", "=", "refPath", ".", "indexOf", "(", "'#'", ")", "if", "(", "hashIndex", ">=", "0", ")", "{", "rpath", "=", "refPath", ".", "s...
Gets the value at the ref path within schema @param schema the (root) json schema to search @param refPath string ref path to get within the schema. Ex. `#/definitions/id` @returns {*} Returns the value at the path location or undefined if not found within the given schema @private
[ "Gets", "the", "value", "at", "the", "ref", "path", "within", "schema" ]
10b1b3b94ffa27d8312537bbf540a59ac7aeaf27
https://github.com/bojand/json-schema-deref-sync/blob/10b1b3b94ffa27d8312537bbf540a59ac7aeaf27/lib/utils.js#L68-L86
33,664
yahoo/mendel
packages/mendel-generator-prune/index.js
pruneModules
function pruneModules(bundle, doneBundles, registry, generator) { const {groups} = generator.options; groups.forEach(group => { const bundles = group.map(bundleId => { return doneBundles.find(b => b.id === bundleId); }).filter(Boolean); pruneGroup(bundles); }); }
javascript
function pruneModules(bundle, doneBundles, registry, generator) { const {groups} = generator.options; groups.forEach(group => { const bundles = group.map(bundleId => { return doneBundles.find(b => b.id === bundleId); }).filter(Boolean); pruneGroup(bundles); }); }
[ "function", "pruneModules", "(", "bundle", ",", "doneBundles", ",", "registry", ",", "generator", ")", "{", "const", "{", "groups", "}", "=", "generator", ".", "options", ";", "groups", ".", "forEach", "(", "group", "=>", "{", "const", "bundles", "=", "g...
First argument is not needed; just to make it look like normal generator API
[ "First", "argument", "is", "not", "needed", ";", "just", "to", "make", "it", "look", "like", "normal", "generator", "API" ]
4c3d296248fb2a96f0d079eb70702298a44be9bd
https://github.com/yahoo/mendel/blob/4c3d296248fb2a96f0d079eb70702298a44be9bd/packages/mendel-generator-prune/index.js#L4-L12
33,665
hoodiehq/hoodie-store-client
lib/find.js
find
function find (state, prefix, objectsOrIds) { return Array.isArray(objectsOrIds) ? findMany(state, objectsOrIds, prefix) : findOne(state, objectsOrIds, prefix) }
javascript
function find (state, prefix, objectsOrIds) { return Array.isArray(objectsOrIds) ? findMany(state, objectsOrIds, prefix) : findOne(state, objectsOrIds, prefix) }
[ "function", "find", "(", "state", ",", "prefix", ",", "objectsOrIds", ")", "{", "return", "Array", ".", "isArray", "(", "objectsOrIds", ")", "?", "findMany", "(", "state", ",", "objectsOrIds", ",", "prefix", ")", ":", "findOne", "(", "state", ",", "objec...
finds existing object in local database @param {String} prefix optional id prefix @param {String|Object|Object[]} objectsOrIds Id of object or object with `._id` property @return {Promise}
[ "finds", "existing", "object", "in", "local", "database" ]
a0043e6b73a5ee90675fb02be78edfceef94a6b1
https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/find.js#L14-L18
33,666
Robert-W/grunt-ftp-push
tasks/ftp_push.js
getCredentials
function getCredentials(gruntOptions) { if (gruntOptions.authKey && grunt.file.exists('.ftpauth')) { return JSON.parse(grunt.file.read('.ftpauth'))[gruntOptions.authKey]; } else if (gruntOptions.username && gruntOptions.password) { return { username: gruntOptions.username, password: gruntOptions.pas...
javascript
function getCredentials(gruntOptions) { if (gruntOptions.authKey && grunt.file.exists('.ftpauth')) { return JSON.parse(grunt.file.read('.ftpauth'))[gruntOptions.authKey]; } else if (gruntOptions.username && gruntOptions.password) { return { username: gruntOptions.username, password: gruntOptions.pas...
[ "function", "getCredentials", "(", "gruntOptions", ")", "{", "if", "(", "gruntOptions", ".", "authKey", "&&", "grunt", ".", "file", ".", "exists", "(", "'.ftpauth'", ")", ")", "{", "return", "JSON", ".", "parse", "(", "grunt", ".", "file", ".", "read", ...
Based off of whats in the options, create a credentials object @param {object} options - grunt options provided to the plugin @return {object} {username: '...', password: '...'}
[ "Based", "off", "of", "whats", "in", "the", "options", "create", "a", "credentials", "object" ]
aa3f520c6422d94bcaab69f21f44e26f635c5014
https://github.com/Robert-W/grunt-ftp-push/blob/aa3f520c6422d94bcaab69f21f44e26f635c5014/tasks/ftp_push.js#L27-L37
33,667
Robert-W/grunt-ftp-push
tasks/ftp_push.js
pushDirectories
function pushDirectories(directories, callback) { var index = 0; /** * Recursive helper used as callback for server.raw(mkd) * @param {error} err - Error message if something went wrong */ var processDir = function processDir (err) { // Fail if any error other then 550 is present, 550 is ...
javascript
function pushDirectories(directories, callback) { var index = 0; /** * Recursive helper used as callback for server.raw(mkd) * @param {error} err - Error message if something went wrong */ var processDir = function processDir (err) { // Fail if any error other then 550 is present, 550 is ...
[ "function", "pushDirectories", "(", "directories", ",", "callback", ")", "{", "var", "index", "=", "0", ";", "/**\n * Recursive helper used as callback for server.raw(mkd)\n * @param {error} err - Error message if something went wrong\n */", "var", "processDir", "=", "func...
Helper function that uses a recursive style for creating directories until none remain @param {array} directories - Array of directory paths that will be necessary to upload files @param {function} callback - function to trigger when all directories have been created
[ "Helper", "function", "that", "uses", "a", "recursive", "style", "for", "creating", "directories", "until", "none", "remain" ]
aa3f520c6422d94bcaab69f21f44e26f635c5014
https://github.com/Robert-W/grunt-ftp-push/blob/aa3f520c6422d94bcaab69f21f44e26f635c5014/tasks/ftp_push.js#L44-L75
33,668
Robert-W/grunt-ftp-push
tasks/ftp_push.js
uploadFiles
function uploadFiles(files) { var index = 0, file = files[index]; /** * Recursive helper used as callback for server.raw(put) * @param {error} err - Error message if something went wrong */ var processFile = function processFile (err) { if (err) { grunt.log.warn(messages.f...
javascript
function uploadFiles(files) { var index = 0, file = files[index]; /** * Recursive helper used as callback for server.raw(put) * @param {error} err - Error message if something went wrong */ var processFile = function processFile (err) { if (err) { grunt.log.warn(messages.f...
[ "function", "uploadFiles", "(", "files", ")", "{", "var", "index", "=", "0", ",", "file", "=", "files", "[", "index", "]", ";", "/**\n * Recursive helper used as callback for server.raw(put)\n * @param {error} err - Error message if something went wrong\n */", "var", ...
Helper function that uses a recursive style for uploading files until none remain @param {object[]} files - Array of file objects to upload, {src: '...', dest: '...'}
[ "Helper", "function", "that", "uses", "a", "recursive", "style", "for", "uploading", "files", "until", "none", "remain" ]
aa3f520c6422d94bcaab69f21f44e26f635c5014
https://github.com/Robert-W/grunt-ftp-push/blob/aa3f520c6422d94bcaab69f21f44e26f635c5014/tasks/ftp_push.js#L81-L117
33,669
marcello3d/node-licensecheck
urltolicense.js
getLicenseFromUrl
function getLicenseFromUrl (url) { var regex = { opensource: /(http(s)?:\/\/)?(www.)?opensource.org\/licenses\/([A-Za-z0-9\-._]+)$/, spdx: /(http(s)?:\/\/)?(www.)?spdx.org\/licenses\/([A-Za-z0-9\-._]+)$/ } for (var re in regex) { var tokens = url.match(regex[re]) if (tokens) { var license ...
javascript
function getLicenseFromUrl (url) { var regex = { opensource: /(http(s)?:\/\/)?(www.)?opensource.org\/licenses\/([A-Za-z0-9\-._]+)$/, spdx: /(http(s)?:\/\/)?(www.)?spdx.org\/licenses\/([A-Za-z0-9\-._]+)$/ } for (var re in regex) { var tokens = url.match(regex[re]) if (tokens) { var license ...
[ "function", "getLicenseFromUrl", "(", "url", ")", "{", "var", "regex", "=", "{", "opensource", ":", "/", "(http(s)?:\\/\\/)?(www.)?opensource.org\\/licenses\\/([A-Za-z0-9\\-._]+)$", "/", ",", "spdx", ":", "/", "(http(s)?:\\/\\/)?(www.)?spdx.org\\/licenses\\/([A-Za-z0-9\\-._]+)$...
Find license name from license url
[ "Find", "license", "name", "from", "license", "url" ]
406af818a1a50dbcc8c3a04f46e9d5ed03cf11f7
https://github.com/marcello3d/node-licensecheck/blob/406af818a1a50dbcc8c3a04f46e9d5ed03cf11f7/urltolicense.js#L5-L30
33,670
cultureamp/elm-css-modules-loader
ci/prepareElmRelease.js
prepareElmRelease
async function prepareElmRelease(config, context) { function exec(command) { context.logger.log(`Running: ${command}`); execSync(command, { shell: '/bin/bash' }); } exec(`yarn elm diff`); exec(`yes | yarn elm bump`); }
javascript
async function prepareElmRelease(config, context) { function exec(command) { context.logger.log(`Running: ${command}`); execSync(command, { shell: '/bin/bash' }); } exec(`yarn elm diff`); exec(`yes | yarn elm bump`); }
[ "async", "function", "prepareElmRelease", "(", "config", ",", "context", ")", "{", "function", "exec", "(", "command", ")", "{", "context", ".", "logger", ".", "log", "(", "`", "${", "command", "}", "`", ")", ";", "execSync", "(", "command", ",", "{", ...
A semantic release "prepare" plugin to update elm-package.json
[ "A", "semantic", "release", "prepare", "plugin", "to", "update", "elm", "-", "package", ".", "json" ]
93a702e272bed758128b11ee14cb849de0ffa7a2
https://github.com/cultureamp/elm-css-modules-loader/blob/93a702e272bed758128b11ee14cb849de0ffa7a2/ci/prepareElmRelease.js#L6-L14
33,671
hoodiehq/hoodie-store-client
lib/update.js
update
function update (state, prefix, objectsOrIds, change) { if (typeof objectsOrIds !== 'object' && !change) { return Promise.reject( new Error('Must provide change') ) } return Array.isArray(objectsOrIds) ? updateMany(state, objectsOrIds, change, prefix) : updateOne(state, objectsOrIds, change...
javascript
function update (state, prefix, objectsOrIds, change) { if (typeof objectsOrIds !== 'object' && !change) { return Promise.reject( new Error('Must provide change') ) } return Array.isArray(objectsOrIds) ? updateMany(state, objectsOrIds, change, prefix) : updateOne(state, objectsOrIds, change...
[ "function", "update", "(", "state", ",", "prefix", ",", "objectsOrIds", ",", "change", ")", "{", "if", "(", "typeof", "objectsOrIds", "!==", "'object'", "&&", "!", "change", ")", "{", "return", "Promise", ".", "reject", "(", "new", "Error", "(", "'Must p...
updates existing object. @param {String} prefix optional id prefix @param {String|Object|Object[]} objectsOrIds id or object (or array of objects) with `._id` property @param {Object|Function} [change] Changed properties or function that changes existing object @return {Pro...
[ "updates", "existing", "object", "." ]
a0043e6b73a5ee90675fb02be78edfceef94a6b1
https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/update.js#L17-L27
33,672
mathigon/boost.js
src/colour.js
getColourAt
function getColourAt(gradient, p) { p = clamp(p, 0, 0.9999); // FIXME let r = Math.floor(p * (gradient.length - 1)); let q = p * (gradient.length - 1) - r; return Colour.mix(gradient[r + 1], gradient[r], q); }
javascript
function getColourAt(gradient, p) { p = clamp(p, 0, 0.9999); // FIXME let r = Math.floor(p * (gradient.length - 1)); let q = p * (gradient.length - 1) - r; return Colour.mix(gradient[r + 1], gradient[r], q); }
[ "function", "getColourAt", "(", "gradient", ",", "p", ")", "{", "p", "=", "clamp", "(", "p", ",", "0", ",", "0.9999", ")", ";", "// FIXME", "let", "r", "=", "Math", ".", "floor", "(", "p", "*", "(", "gradient", ".", "length", "-", "1", ")", ")"...
Gets the colour of a multi-step gradient at a given percentage p
[ "Gets", "the", "colour", "of", "a", "multi", "-", "step", "gradient", "at", "a", "given", "percentage", "p" ]
ceffceacffe35de461d6e90f48e058f826d63bb2
https://github.com/mathigon/boost.js/blob/ceffceacffe35de461d6e90f48e058f826d63bb2/src/colour.js#L34-L39
33,673
marcello3d/node-licensecheck
index.js
matchLicense
function matchLicense (licenseString) { // Find all textual matches on license text. var normalized = normalizeText(licenseString) var matchingLicenses = [] var license // Check matches of normalized license content against signatures. for (var i = 0; i < licenses.length; i++) { license = licenses[i] ...
javascript
function matchLicense (licenseString) { // Find all textual matches on license text. var normalized = normalizeText(licenseString) var matchingLicenses = [] var license // Check matches of normalized license content against signatures. for (var i = 0; i < licenses.length; i++) { license = licenses[i] ...
[ "function", "matchLicense", "(", "licenseString", ")", "{", "// Find all textual matches on license text.", "var", "normalized", "=", "normalizeText", "(", "licenseString", ")", "var", "matchingLicenses", "=", "[", "]", "var", "license", "// Check matches of normalized lice...
Match a license body or license id against known set of licenses.
[ "Match", "a", "license", "body", "or", "license", "id", "against", "known", "set", "of", "licenses", "." ]
406af818a1a50dbcc8c3a04f46e9d5ed03cf11f7
https://github.com/marcello3d/node-licensecheck/blob/406af818a1a50dbcc8c3a04f46e9d5ed03cf11f7/index.js#L24-L62
33,674
marcello3d/node-licensecheck
index.js
getJsonLicense
function getJsonLicense (json) { var license = 'nomatch' if (typeof json === 'string') { license = matchLicense(json) || 'nomatch' } else { if (json.url) { license = { name: json.type, url: json.url } } else { license = matchLicense(json.type) } } return license }
javascript
function getJsonLicense (json) { var license = 'nomatch' if (typeof json === 'string') { license = matchLicense(json) || 'nomatch' } else { if (json.url) { license = { name: json.type, url: json.url } } else { license = matchLicense(json.type) } } return license }
[ "function", "getJsonLicense", "(", "json", ")", "{", "var", "license", "=", "'nomatch'", "if", "(", "typeof", "json", "===", "'string'", ")", "{", "license", "=", "matchLicense", "(", "json", ")", "||", "'nomatch'", "}", "else", "{", "if", "(", "json", ...
Convert package.json format to a known license. If a developer specifies just the name, we check it against SPDX, according to NPM guidelines. If they supply a URL, we just link to it, preserving name and exact link.
[ "Convert", "package", ".", "json", "format", "to", "a", "known", "license", ".", "If", "a", "developer", "specifies", "just", "the", "name", "we", "check", "it", "against", "SPDX", "according", "to", "NPM", "guidelines", ".", "If", "they", "supply", "a", ...
406af818a1a50dbcc8c3a04f46e9d5ed03cf11f7
https://github.com/marcello3d/node-licensecheck/blob/406af818a1a50dbcc8c3a04f46e9d5ed03cf11f7/index.js#L98-L110
33,675
hoodiehq/hoodie-store-client
lib/off.js
off
function off (state, eventName, handler) { state.emitter.removeListener(eventName, handler) return state.api }
javascript
function off (state, eventName, handler) { state.emitter.removeListener(eventName, handler) return state.api }
[ "function", "off", "(", "state", ",", "eventName", ",", "handler", ")", "{", "state", ".", "emitter", ".", "removeListener", "(", "eventName", ",", "handler", ")", "return", "state", ".", "api", "}" ]
removes a listener for the specified event It will unsubscribe at most, one instance of a listener for a particular event. If any single listener has subcribed multiple times to the same event, then `off` must be called multiple times. Supported events: - `add` - `update` - `remove` - `change` @param {String} even...
[ "removes", "a", "listener", "for", "the", "specified", "event" ]
a0043e6b73a5ee90675fb02be78edfceef94a6b1
https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/off.js#L20-L24
33,676
jantimon/svg-placeholder
lib/svg-generator.js
calculateScaledFontSize
function calculateScaledFontSize(width, height) { return Math.round(Math.max(12, Math.min(Math.min(width, height) * 0.75, (0.75 * Math.max(width, height)) / 12))); }
javascript
function calculateScaledFontSize(width, height) { return Math.round(Math.max(12, Math.min(Math.min(width, height) * 0.75, (0.75 * Math.max(width, height)) / 12))); }
[ "function", "calculateScaledFontSize", "(", "width", ",", "height", ")", "{", "return", "Math", ".", "round", "(", "Math", ".", "max", "(", "12", ",", "Math", ".", "min", "(", "Math", ".", "min", "(", "width", ",", "height", ")", "*", "0.75", ",", ...
Calculate a font which works well for the given width and height @param width {Number} the width of the image @param height {Number} the height of the image @returns {Number} fontSize
[ "Calculate", "a", "font", "which", "works", "well", "for", "the", "given", "width", "and", "height" ]
c9b2b1429d20a4ade9bbb26fd42a48279e809d5a
https://github.com/jantimon/svg-placeholder/blob/c9b2b1429d20a4ade9bbb26fd42a48279e809d5a/lib/svg-generator.js#L9-L11
33,677
hoodiehq/hoodie-store-client
lib/update-or-add.js
updateOrAdd
function updateOrAdd (state, prefix, idOrObjectOrArray, newObject) { return Array.isArray(idOrObjectOrArray) ? updateOrAddMany(state, idOrObjectOrArray, prefix) : updateOrAddOne(state, idOrObjectOrArray, newObject, prefix) }
javascript
function updateOrAdd (state, prefix, idOrObjectOrArray, newObject) { return Array.isArray(idOrObjectOrArray) ? updateOrAddMany(state, idOrObjectOrArray, prefix) : updateOrAddOne(state, idOrObjectOrArray, newObject, prefix) }
[ "function", "updateOrAdd", "(", "state", ",", "prefix", ",", "idOrObjectOrArray", ",", "newObject", ")", "{", "return", "Array", ".", "isArray", "(", "idOrObjectOrArray", ")", "?", "updateOrAddMany", "(", "state", ",", "idOrObjectOrArray", ",", "prefix", ")", ...
updates existing object, or creates otherwise. @param {String} prefix optional id prefix @param {String|Object|Object[]} - id or object with `._id` property, or array of properties @param {Object} [properties] If id passed, properties for new or existing object @return {Promise}
[ "updates", "existing", "object", "or", "creates", "otherwise", "." ]
a0043e6b73a5ee90675fb02be78edfceef94a6b1
https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/update-or-add.js#L16-L20
33,678
4ib3r/StompBrokerJS
lib/stomp-utils.js
sendFrame
function sendFrame(socket, _frame) { var frame = _frame; if (!_frame.hasOwnProperty('toString')) { frame = new Frame({ 'command': _frame.command, 'headers': _frame.headers, 'body': _frame.body }); } socket.send(frame.toStringOrBuffer()); return true; }
javascript
function sendFrame(socket, _frame) { var frame = _frame; if (!_frame.hasOwnProperty('toString')) { frame = new Frame({ 'command': _frame.command, 'headers': _frame.headers, 'body': _frame.body }); } socket.send(frame.toStringOrBuffer()); return true; }
[ "function", "sendFrame", "(", "socket", ",", "_frame", ")", "{", "var", "frame", "=", "_frame", ";", "if", "(", "!", "_frame", ".", "hasOwnProperty", "(", "'toString'", ")", ")", "{", "frame", "=", "new", "Frame", "(", "{", "'command'", ":", "_frame", ...
Send frame with socket
[ "Send", "frame", "with", "socket" ]
8d8de4b5232c6fe456ee99237e9f731ce3846ed4
https://github.com/4ib3r/StompBrokerJS/blob/8d8de4b5232c6fe456ee99237e9f731ce3846ed4/lib/stomp-utils.js#L9-L22
33,679
4ib3r/StompBrokerJS
lib/stomp-utils.js
parseCommand
function parseCommand(data) { var command, str = data.toString('utf8', 0, data.length); command = str.split('\n'); return command[0]; }
javascript
function parseCommand(data) { var command, str = data.toString('utf8', 0, data.length); command = str.split('\n'); return command[0]; }
[ "function", "parseCommand", "(", "data", ")", "{", "var", "command", ",", "str", "=", "data", ".", "toString", "(", "'utf8'", ",", "0", ",", "data", ".", "length", ")", ";", "command", "=", "str", ".", "split", "(", "'\\n'", ")", ";", "return", "co...
Parse single command
[ "Parse", "single", "command" ]
8d8de4b5232c6fe456ee99237e9f731ce3846ed4
https://github.com/4ib3r/StompBrokerJS/blob/8d8de4b5232c6fe456ee99237e9f731ce3846ed4/lib/stomp-utils.js#L25-L31
33,680
hoodiehq/hoodie-store-client
lib/update-all.js
updateAll
function updateAll (state, prefix, changedProperties) { var type = typeof changedProperties var docs if (type !== 'object' && type !== 'function') { return Promise.reject(new Error('Must provide object or function')) } var options = { include_docs: true } if (prefix) { options.startkey = pr...
javascript
function updateAll (state, prefix, changedProperties) { var type = typeof changedProperties var docs if (type !== 'object' && type !== 'function') { return Promise.reject(new Error('Must provide object or function')) } var options = { include_docs: true } if (prefix) { options.startkey = pr...
[ "function", "updateAll", "(", "state", ",", "prefix", ",", "changedProperties", ")", "{", "var", "type", "=", "typeof", "changedProperties", "var", "docs", "if", "(", "type", "!==", "'object'", "&&", "type", "!==", "'function'", ")", "{", "return", "Promise"...
updates all existing docs @param {String} prefix optional id prefix @param {Object|Function} change changed properties or function that alters passed doc @return {Promise}
[ "updates", "all", "existing", "docs" ]
a0043e6b73a5ee90675fb02be78edfceef94a6b1
https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/update-all.js#L19-L59
33,681
hoodiehq/hoodie-store-client
lib/add.js
add
function add (state, prefix, properties) { return Array.isArray(properties) ? addMany(state, properties, prefix) : addOne(state, properties, prefix) }
javascript
function add (state, prefix, properties) { return Array.isArray(properties) ? addMany(state, properties, prefix) : addOne(state, properties, prefix) }
[ "function", "add", "(", "state", ",", "prefix", ",", "properties", ")", "{", "return", "Array", ".", "isArray", "(", "properties", ")", "?", "addMany", "(", "state", ",", "properties", ",", "prefix", ")", ":", "addOne", "(", "state", ",", "properties", ...
adds one or multiple objects to local database @param {String} prefix optional id prefix @param {Object|Object[]} properties Properties of one or multiple objects @return {Promise}
[ "adds", "one", "or", "multiple", "objects", "to", "local", "database" ]
a0043e6b73a5ee90675fb02be78edfceef94a6b1
https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/add.js#L14-L18
33,682
hoodiehq/hoodie-store-client
lib/remove-all.js
removeAll
function removeAll (state, prefix, filter) { var docs var options = { include_docs: true } if (prefix) { options.startkey = prefix options.endkey = prefix + '\uffff' } return state.db.allDocs(options) .then(function (res) { docs = res.rows .filter(isntDesignDoc) .map(functi...
javascript
function removeAll (state, prefix, filter) { var docs var options = { include_docs: true } if (prefix) { options.startkey = prefix options.endkey = prefix + '\uffff' } return state.db.allDocs(options) .then(function (res) { docs = res.rows .filter(isntDesignDoc) .map(functi...
[ "function", "removeAll", "(", "state", ",", "prefix", ",", "filter", ")", "{", "var", "docs", "var", "options", "=", "{", "include_docs", ":", "true", "}", "if", "(", "prefix", ")", "{", "options", ".", "startkey", "=", "prefix", "options", ".", "endke...
removes all existing docs @param {String} prefix optional id prefix @param {Function} [filter] Function returning `true` for any doc to be removed. @return {Promise}
[ "removes", "all", "existing", "docs" ]
a0043e6b73a5ee90675fb02be78edfceef94a6b1
https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/remove-all.js#L15-L47
33,683
yahoo/mendel
packages/mendel-manifest-extract-bundles/manifest-extract.js
visitBundle
function visitBundle(file) { if (visitedIndexes[file]) { return; } visitedIndexes[file] = true; // walk deps var bundle = manifest.bundles[manifest.indexes[file]]; bundle.data.forEach(function(module) { Object.keys(module.deps).forEach(function(key...
javascript
function visitBundle(file) { if (visitedIndexes[file]) { return; } visitedIndexes[file] = true; // walk deps var bundle = manifest.bundles[manifest.indexes[file]]; bundle.data.forEach(function(module) { Object.keys(module.deps).forEach(function(key...
[ "function", "visitBundle", "(", "file", ")", "{", "if", "(", "visitedIndexes", "[", "file", "]", ")", "{", "return", ";", "}", "visitedIndexes", "[", "file", "]", "=", "true", ";", "// walk deps", "var", "bundle", "=", "manifest", ".", "bundles", "[", ...
recursive function to visit bundle and it's deps
[ "recursive", "function", "to", "visit", "bundle", "and", "it", "s", "deps" ]
4c3d296248fb2a96f0d079eb70702298a44be9bd
https://github.com/yahoo/mendel/blob/4c3d296248fb2a96f0d079eb70702298a44be9bd/packages/mendel-manifest-extract-bundles/manifest-extract.js#L122-L137
33,684
mongodb-js/dataset-generator
lib/schema/array.js
ArrayField
function ArrayField (array, name, parent) { if (!(this instanceof ArrayField)) return new ArrayField(array, name, parent); debug('array <%s> being built', name); Entry.call(this, array, name, parent); this._context = parent._context; this._this = parent._this; this._currVal = {}; var data = this._content...
javascript
function ArrayField (array, name, parent) { if (!(this instanceof ArrayField)) return new ArrayField(array, name, parent); debug('array <%s> being built', name); Entry.call(this, array, name, parent); this._context = parent._context; this._this = parent._this; this._currVal = {}; var data = this._content...
[ "function", "ArrayField", "(", "array", ",", "name", ",", "parent", ")", "{", "if", "(", "!", "(", "this", "instanceof", "ArrayField", ")", ")", "return", "new", "ArrayField", "(", "array", ",", "name", ",", "parent", ")", ";", "debug", "(", "'array <%...
Internal representation of Arrays in template schema @class @augments {Entry} @memberOf module:schema @param {!Array} array Raw user-supplied array @param {string} name Key corresponding to the field @param {!Entry} parent Immediate enclosing Entry
[ "Internal", "representation", "of", "Arrays", "in", "template", "schema" ]
0f56410970a8dc03433477966dafa16a5cbd9cda
https://github.com/mongodb-js/dataset-generator/blob/0f56410970a8dc03433477966dafa16a5cbd9cda/lib/schema/array.js#L20-L64
33,685
hoodiehq/hoodie-store-client
lib/find-or-add.js
findOrAdd
function findOrAdd (state, prefix, idOrObjectOrArray, properties) { return Array.isArray(idOrObjectOrArray) ? findOrAddMany(state, idOrObjectOrArray, prefix) : findOrAddOne(state, idOrObjectOrArray, properties, prefix) }
javascript
function findOrAdd (state, prefix, idOrObjectOrArray, properties) { return Array.isArray(idOrObjectOrArray) ? findOrAddMany(state, idOrObjectOrArray, prefix) : findOrAddOne(state, idOrObjectOrArray, properties, prefix) }
[ "function", "findOrAdd", "(", "state", ",", "prefix", ",", "idOrObjectOrArray", ",", "properties", ")", "{", "return", "Array", ".", "isArray", "(", "idOrObjectOrArray", ")", "?", "findOrAddMany", "(", "state", ",", "idOrObjectOrArray", ",", "prefix", ")", ":"...
tries to find object in local database, otherwise creates new one with passed properties. @param {String} prefix optional id prefix @param {String|Object|Object[]} idOrObject id or object with `._id` property @param {Object} [properties] Optional properties if id passed as fi...
[ "tries", "to", "find", "object", "in", "local", "database", "otherwise", "creates", "new", "one", "with", "passed", "properties", "." ]
a0043e6b73a5ee90675fb02be78edfceef94a6b1
https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/find-or-add.js#L16-L20
33,686
hoodiehq/hoodie-store-client
lib/pull.js
pull
function pull (state, docsOrIds) { var pulledObjects = [] var errors = state.db.constructor.Errors return Promise.resolve(state.remote) .then(function (remote) { return new Promise(function (resolve, reject) { if (Array.isArray(docsOrIds)) { docsOrIds = docsOrIds.map(toId) } else { ...
javascript
function pull (state, docsOrIds) { var pulledObjects = [] var errors = state.db.constructor.Errors return Promise.resolve(state.remote) .then(function (remote) { return new Promise(function (resolve, reject) { if (Array.isArray(docsOrIds)) { docsOrIds = docsOrIds.map(toId) } else { ...
[ "function", "pull", "(", "state", ",", "docsOrIds", ")", "{", "var", "pulledObjects", "=", "[", "]", "var", "errors", "=", "state", ".", "db", ".", "constructor", ".", "Errors", "return", "Promise", ".", "resolve", "(", "state", ".", "remote", ")", "."...
pulls one or multiple objects from remote to local database @param {StringOrObject} docsOrIds object or ID of object or array of objects/ids (all optional) @return {Promise}
[ "pulls", "one", "or", "multiple", "objects", "from", "remote", "to", "local", "database" ]
a0043e6b73a5ee90675fb02be78edfceef94a6b1
https://github.com/hoodiehq/hoodie-store-client/blob/a0043e6b73a5ee90675fb02be78edfceef94a6b1/lib/pull.js#L13-L53
33,687
mongodb-js/dataset-generator
lib/schema/index.js
Schema
function Schema (sc, size) { if (!(this instanceof Schema)) return new Schema(sc); debug('======BUILDING PHASE======'); helpers.validate(sc); debug('schema size=%d being built', size); this._schema = this; this._document = helpers.build(sc, '$root', this); this._state = { // serve as global state inde...
javascript
function Schema (sc, size) { if (!(this instanceof Schema)) return new Schema(sc); debug('======BUILDING PHASE======'); helpers.validate(sc); debug('schema size=%d being built', size); this._schema = this; this._document = helpers.build(sc, '$root', this); this._state = { // serve as global state inde...
[ "function", "Schema", "(", "sc", ",", "size", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Schema", ")", ")", "return", "new", "Schema", "(", "sc", ")", ";", "debug", "(", "'======BUILDING PHASE======'", ")", ";", "helpers", ".", "validate", "...
Internal representation of a user-defined schema @class @memberOf module:schema @param {object} sc @param {number} size
[ "Internal", "representation", "of", "a", "user", "-", "defined", "schema" ]
0f56410970a8dc03433477966dafa16a5cbd9cda
https://github.com/mongodb-js/dataset-generator/blob/0f56410970a8dc03433477966dafa16a5cbd9cda/lib/schema/index.js#L17-L30
33,688
jrieken/gulp-tsb
gulpfile.js
reload
function reload(moduleName) { var id = require.resolve(moduleName); var mod = require.cache[id]; if (mod) { var base = path.dirname(mod.filename); // expunge each module cache entry beneath this folder var stack = [mod]; while (stack.length) { var mod = st...
javascript
function reload(moduleName) { var id = require.resolve(moduleName); var mod = require.cache[id]; if (mod) { var base = path.dirname(mod.filename); // expunge each module cache entry beneath this folder var stack = [mod]; while (stack.length) { var mod = st...
[ "function", "reload", "(", "moduleName", ")", "{", "var", "id", "=", "require", ".", "resolve", "(", "moduleName", ")", ";", "var", "mod", "=", "require", ".", "cache", "[", "id", "]", ";", "if", "(", "mod", ")", "{", "var", "base", "=", "path", ...
reload a node module and any children beneath the same folder
[ "reload", "a", "node", "module", "and", "any", "children", "beneath", "the", "same", "folder" ]
35f134ab384f5575628b152faa910389581bb4d8
https://github.com/jrieken/gulp-tsb/blob/35f134ab384f5575628b152faa910389581bb4d8/gulpfile.js#L70-L101
33,689
jmreidy/grunt-mocha-webdriver
tasks/grunt-mocha-wd.js
extractConnectionInfo
function extractConnectionInfo(opts) { var params = {}; var defaultServer = opts.secureCommands ? { hostname: '127.0.0.1', port: 4445 } : { hostname: 'ondemand.saucelabs.com', port: 80 }; params.hostname = opts.hostname || defaultServer.hostname; params.p...
javascript
function extractConnectionInfo(opts) { var params = {}; var defaultServer = opts.secureCommands ? { hostname: '127.0.0.1', port: 4445 } : { hostname: 'ondemand.saucelabs.com', port: 80 }; params.hostname = opts.hostname || defaultServer.hostname; params.p...
[ "function", "extractConnectionInfo", "(", "opts", ")", "{", "var", "params", "=", "{", "}", ";", "var", "defaultServer", "=", "opts", ".", "secureCommands", "?", "{", "hostname", ":", "'127.0.0.1'", ",", "port", ":", "4445", "}", ":", "{", "hostname", ":...
Extracts wd connection params from grunt options Utility function that returns named params that can be used by wd.remote or wd.promiseChainRemote
[ "Extracts", "wd", "connection", "params", "from", "grunt", "options" ]
f904539e7828a25e818c444939979fdda9849ef2
https://github.com/jmreidy/grunt-mocha-webdriver/blob/f904539e7828a25e818c444939979fdda9849ef2/tasks/grunt-mocha-wd.js#L160-L177
33,690
jmreidy/grunt-mocha-webdriver
tasks/grunt-mocha-wd.js
initBrowser
function initBrowser(browserOpts, opts, mode, fileGroup, cb) { var funcName = opts.usePromises ? 'promiseChainRemote': 'remote'; var browser = wd[funcName](extractConnectionInfo(opts)); browser.browserTitle = browserOpts.browserTitle; browser.mode = mode; browser.mode = mode; if (opts.testName)...
javascript
function initBrowser(browserOpts, opts, mode, fileGroup, cb) { var funcName = opts.usePromises ? 'promiseChainRemote': 'remote'; var browser = wd[funcName](extractConnectionInfo(opts)); browser.browserTitle = browserOpts.browserTitle; browser.mode = mode; browser.mode = mode; if (opts.testName)...
[ "function", "initBrowser", "(", "browserOpts", ",", "opts", ",", "mode", ",", "fileGroup", ",", "cb", ")", "{", "var", "funcName", "=", "opts", ".", "usePromises", "?", "'promiseChainRemote'", ":", "'remote'", ";", "var", "browser", "=", "wd", "[", "funcNa...
Init a browser
[ "Init", "a", "browser" ]
f904539e7828a25e818c444939979fdda9849ef2
https://github.com/jmreidy/grunt-mocha-webdriver/blob/f904539e7828a25e818c444939979fdda9849ef2/tasks/grunt-mocha-wd.js#L182-L212
33,691
oncojs/oncogrid
src/Histogram.js
getLargestCount
function getLargestCount(domain, type) { var retVal = 1; for (var i = 0; i < domain.length; i++) { retVal = Math.max(retVal, type === 'cnv' ? domain[i].cnv : domain[i].count); } return retVal; }
javascript
function getLargestCount(domain, type) { var retVal = 1; for (var i = 0; i < domain.length; i++) { retVal = Math.max(retVal, type === 'cnv' ? domain[i].cnv : domain[i].count); } return retVal; }
[ "function", "getLargestCount", "(", "domain", ",", "type", ")", "{", "var", "retVal", "=", "1", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "domain", ".", "length", ";", "i", "++", ")", "{", "retVal", "=", "Math", ".", "max", "(", "re...
Want to find the maximum value so we can label the axis and scale the bars accordingly. No need to make this function public. @returns {number}
[ "Want", "to", "find", "the", "maximum", "value", "so", "we", "can", "label", "the", "axis", "and", "scale", "the", "bars", "accordingly", ".", "No", "need", "to", "make", "this", "function", "public", "." ]
5dfff05be9143e1f3ec1911997ae2cde8df998ac
https://github.com/oncojs/oncogrid/blob/5dfff05be9143e1f3ec1911997ae2cde8df998ac/src/Histogram.js#L26-L34
33,692
autonomoussoftware/metronome-contracts-js
lib/map-values/index.js
mapValues
function mapValues (obj, fn) { return Object.keys(obj).reduce(function (res, key) { res[key] = fn(obj[key], key, obj) return res }, {}) }
javascript
function mapValues (obj, fn) { return Object.keys(obj).reduce(function (res, key) { res[key] = fn(obj[key], key, obj) return res }, {}) }
[ "function", "mapValues", "(", "obj", ",", "fn", ")", "{", "return", "Object", ".", "keys", "(", "obj", ")", ".", "reduce", "(", "function", "(", "res", ",", "key", ")", "{", "res", "[", "key", "]", "=", "fn", "(", "obj", "[", "key", "]", ",", ...
Create a new object with the same keys and values mapped using provided fn. This is a simplified version of lodash.mapValues. @param {Object} obj The source object. @param {Function} fn The function to map the object's values. @returns {Object} The mapped object.
[ "Create", "a", "new", "object", "with", "the", "same", "keys", "and", "values", "mapped", "using", "provided", "fn", "." ]
84330c74f847161c24c9e3d5e60642950f68bfaa
https://github.com/autonomoussoftware/metronome-contracts-js/blob/84330c74f847161c24c9e3d5e60642950f68bfaa/lib/map-values/index.js#L12-L17
33,693
kwiksand/yobit
index.js
formatParameters
function formatParameters(params) { var sortedKeys = [], formattedParams = '' // sort the properties of the parameters sortedKeys = _.keys(params).sort() // create a string of key value pairs separated by '&' with '=' assignement for (i = 0; i < sortedKeys.length; i++) { if (i ...
javascript
function formatParameters(params) { var sortedKeys = [], formattedParams = '' // sort the properties of the parameters sortedKeys = _.keys(params).sort() // create a string of key value pairs separated by '&' with '=' assignement for (i = 0; i < sortedKeys.length; i++) { if (i ...
[ "function", "formatParameters", "(", "params", ")", "{", "var", "sortedKeys", "=", "[", "]", ",", "formattedParams", "=", "''", "// sort the properties of the parameters", "sortedKeys", "=", "_", ".", "keys", "(", "params", ")", ".", "sort", "(", ")", "// crea...
This method returns the parameters as key=value pairs separated by & sorted by the key @param {Object} params The object to encode @return {String} formatted parameters
[ "This", "method", "returns", "the", "parameters", "as", "key", "=", "value", "pairs", "separated", "by", "&", "sorted", "by", "the", "key" ]
e9fc16c9d7c80c632a220fbebf755914cbfdffde
https://github.com/kwiksand/yobit/blob/e9fc16c9d7c80c632a220fbebf755914cbfdffde/index.js#L106-L124
33,694
Losant/losant-mqtt-js
lib/device.js
Device
function Device(options) { EventEmitter.call(this); // Check required fields. if(!options || !options.id) { throw new Error('ID is required.'); } this.options = options; this.id = options.id; // Default the options and remove whitespace. options.id = (options.id || '').replace(/ /g, ''); optio...
javascript
function Device(options) { EventEmitter.call(this); // Check required fields. if(!options || !options.id) { throw new Error('ID is required.'); } this.options = options; this.id = options.id; // Default the options and remove whitespace. options.id = (options.id || '').replace(/ /g, ''); optio...
[ "function", "Device", "(", "options", ")", "{", "EventEmitter", ".", "call", "(", "this", ")", ";", "// Check required fields.", "if", "(", "!", "options", "||", "!", "options", ".", "id", ")", "{", "throw", "new", "Error", "(", "'ID is required.'", ")", ...
Device constructor.
[ "Device", "constructor", "." ]
4617e1545a98b1ecb9859bca99e95eb04a1ec196
https://github.com/Losant/losant-mqtt-js/blob/4617e1545a98b1ecb9859bca99e95eb04a1ec196/lib/device.js#L35-L88
33,695
treasonx/grunt-markdown
tasks/markdown.js
setTemplateContext
function setTemplateContext(contextArray) { var newTemplateContext = {}; contextArray.forEach(function(item) { var cleanString = item.slice(options.contextBinderMark.length, -options.contextBinderMark.length), separatedPairs = cleanString.split(':'); newTemplateContext[separatedP...
javascript
function setTemplateContext(contextArray) { var newTemplateContext = {}; contextArray.forEach(function(item) { var cleanString = item.slice(options.contextBinderMark.length, -options.contextBinderMark.length), separatedPairs = cleanString.split(':'); newTemplateContext[separatedP...
[ "function", "setTemplateContext", "(", "contextArray", ")", "{", "var", "newTemplateContext", "=", "{", "}", ";", "contextArray", ".", "forEach", "(", "function", "(", "item", ")", "{", "var", "cleanString", "=", "item", ".", "slice", "(", "options", ".", ...
Apply new template context option to Object
[ "Apply", "new", "template", "context", "option", "to", "Object" ]
ef4a8fd7a4f0335e27e1abccaf61f44b56b253d9
https://github.com/treasonx/grunt-markdown/blob/ef4a8fd7a4f0335e27e1abccaf61f44b56b253d9/tasks/markdown.js#L62-L72
33,696
treasonx/grunt-markdown
tasks/markdown.js
getTemplateContext
function getTemplateContext(file) { var sourceFile = grunt.file.read(file), hasTemplateContext = checkTemplateContext(sourceFile), pattern = new RegExp('(' + options.contextBinderMark + ')(.*?)(' + options.contextBinderMark + ')', 'g'), contextArray; if (!hasTemplateContext) { ...
javascript
function getTemplateContext(file) { var sourceFile = grunt.file.read(file), hasTemplateContext = checkTemplateContext(sourceFile), pattern = new RegExp('(' + options.contextBinderMark + ')(.*?)(' + options.contextBinderMark + ')', 'g'), contextArray; if (!hasTemplateContext) { ...
[ "function", "getTemplateContext", "(", "file", ")", "{", "var", "sourceFile", "=", "grunt", ".", "file", ".", "read", "(", "file", ")", ",", "hasTemplateContext", "=", "checkTemplateContext", "(", "sourceFile", ")", ",", "pattern", "=", "new", "RegExp", "(",...
Collect context items
[ "Collect", "context", "items" ]
ef4a8fd7a4f0335e27e1abccaf61f44b56b253d9
https://github.com/treasonx/grunt-markdown/blob/ef4a8fd7a4f0335e27e1abccaf61f44b56b253d9/tasks/markdown.js#L75-L87
33,697
treasonx/grunt-markdown
tasks/markdown.js
getWorkingPath
function getWorkingPath(file) { var completePath = JSON.stringify(file).slice(2,-2).split('/'), lastPathElement = completePath.pop(), fileDirectory = completePath.splice(lastPathElement).join('/'); return fileDirectory; }
javascript
function getWorkingPath(file) { var completePath = JSON.stringify(file).slice(2,-2).split('/'), lastPathElement = completePath.pop(), fileDirectory = completePath.splice(lastPathElement).join('/'); return fileDirectory; }
[ "function", "getWorkingPath", "(", "file", ")", "{", "var", "completePath", "=", "JSON", ".", "stringify", "(", "file", ")", ".", "slice", "(", "2", ",", "-", "2", ")", ".", "split", "(", "'/'", ")", ",", "lastPathElement", "=", "completePath", ".", ...
Get working path to automaticaly searching for default template.
[ "Get", "working", "path", "to", "automaticaly", "searching", "for", "default", "template", "." ]
ef4a8fd7a4f0335e27e1abccaf61f44b56b253d9
https://github.com/treasonx/grunt-markdown/blob/ef4a8fd7a4f0335e27e1abccaf61f44b56b253d9/tasks/markdown.js#L89-L96
33,698
treasonx/grunt-markdown
tasks/markdown.js
getTemplate
function getTemplate(workingPath) { var templateFile = grunt.file.expand({}, workingPath + '/*.' + options.autoTemplateFormat); return templateFile[0]; }
javascript
function getTemplate(workingPath) { var templateFile = grunt.file.expand({}, workingPath + '/*.' + options.autoTemplateFormat); return templateFile[0]; }
[ "function", "getTemplate", "(", "workingPath", ")", "{", "var", "templateFile", "=", "grunt", ".", "file", ".", "expand", "(", "{", "}", ",", "workingPath", "+", "'/*.'", "+", "options", ".", "autoTemplateFormat", ")", ";", "return", "templateFile", "[", "...
Automaticaly find temnplate in working directory.
[ "Automaticaly", "find", "temnplate", "in", "working", "directory", "." ]
ef4a8fd7a4f0335e27e1abccaf61f44b56b253d9
https://github.com/treasonx/grunt-markdown/blob/ef4a8fd7a4f0335e27e1abccaf61f44b56b253d9/tasks/markdown.js#L99-L104
33,699
yuki-torii/yuki-createjs
lib/easeljs-0.8.2.combined.js
DisplayProps
function DisplayProps(visible, alpha, shadow, compositeOperation, matrix) { this.setValues(visible, alpha, shadow, compositeOperation, matrix); // public properties: // assigned in the setValues method. /** * Property representing the alpha that will be applied to a display object. * @property alpha * ...
javascript
function DisplayProps(visible, alpha, shadow, compositeOperation, matrix) { this.setValues(visible, alpha, shadow, compositeOperation, matrix); // public properties: // assigned in the setValues method. /** * Property representing the alpha that will be applied to a display object. * @property alpha * ...
[ "function", "DisplayProps", "(", "visible", ",", "alpha", ",", "shadow", ",", "compositeOperation", ",", "matrix", ")", "{", "this", ".", "setValues", "(", "visible", ",", "alpha", ",", "shadow", ",", "compositeOperation", ",", "matrix", ")", ";", "// public...
Used for calculating and encapsulating display related properties. @class DisplayProps @param {Number} [visible=true] Visible value. @param {Number} [alpha=1] Alpha value. @param {Number} [shadow=null] A Shadow instance or null. @param {Number} [compositeOperation=null] A compositeOperation value or null. @param {Numbe...
[ "Used", "for", "calculating", "and", "encapsulating", "display", "related", "properties", "." ]
8b3b684782516cc63cd3b337742d90fe85285a90
https://github.com/yuki-torii/yuki-createjs/blob/8b3b684782516cc63cd3b337742d90fe85285a90/lib/easeljs-0.8.2.combined.js#L2142-L2178