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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
45,800 | solid/solid-auth-tls | src/auth.js | loginFromBrowser | function loginFromBrowser (endpoint, config) {
let uri
switch (endpoint) {
case AUTH_ENDPOINTS.PRIMARY:
uri = config.authEndpoint || window.location.origin + window.location.pathname
break
case AUTH_ENDPOINTS.SECONDARY:
uri = config.fallbackAuthEndpoint
break
}
return new Promi... | javascript | function loginFromBrowser (endpoint, config) {
let uri
switch (endpoint) {
case AUTH_ENDPOINTS.PRIMARY:
uri = config.authEndpoint || window.location.origin + window.location.pathname
break
case AUTH_ENDPOINTS.SECONDARY:
uri = config.fallbackAuthEndpoint
break
}
return new Promi... | [
"function",
"loginFromBrowser",
"(",
"endpoint",
",",
"config",
")",
"{",
"let",
"uri",
"switch",
"(",
"endpoint",
")",
"{",
"case",
"AUTH_ENDPOINTS",
".",
"PRIMARY",
":",
"uri",
"=",
"config",
".",
"authEndpoint",
"||",
"window",
".",
"location",
".",
"or... | Logs in to the specified endpoint from within the browser
@param {AUTH_ENDPOINTS} endpoint - the endpoint type
@param {@link module:config-default} config - the config object
@returns {(Promise<String>|Promise<null>)} the WebID as a string if the
client cert is recognized, otherwise null. | [
"Logs",
"in",
"to",
"the",
"specified",
"endpoint",
"from",
"within",
"the",
"browser"
] | a27dea9c29778db936adf48be8042895af3a8f43 | https://github.com/solid/solid-auth-tls/blob/a27dea9c29778db936adf48be8042895af3a8f43/src/auth.js#L73-L97 |
45,801 | solid/solid-auth-tls | src/auth.js | loginFromNode | function loginFromNode (endpoint, config) {
if (!(config.key && config.cert)) {
throw new Error('Must provide TLS key and cert when running in node')
}
let uri
switch (endpoint) {
case AUTH_ENDPOINTS.PRIMARY:
uri = config.authEndpoint
break
case AUTH_ENDPOINTS.SECONDARY:
uri = co... | javascript | function loginFromNode (endpoint, config) {
if (!(config.key && config.cert)) {
throw new Error('Must provide TLS key and cert when running in node')
}
let uri
switch (endpoint) {
case AUTH_ENDPOINTS.PRIMARY:
uri = config.authEndpoint
break
case AUTH_ENDPOINTS.SECONDARY:
uri = co... | [
"function",
"loginFromNode",
"(",
"endpoint",
",",
"config",
")",
"{",
"if",
"(",
"!",
"(",
"config",
".",
"key",
"&&",
"config",
".",
"cert",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Must provide TLS key and cert when running in node'",
")",
"}",
"let... | Logs in to the specified endpoint from within a Node.js environment
@param {AUTH_ENDPOINTS} endpoint - the endpoint type
@param {@link module:config-default} config - the config object
@returns {(Promise<String>|Promise<null>)} the WebID as a string if the
client cert is recognized, otherwise null. | [
"Logs",
"in",
"to",
"the",
"specified",
"endpoint",
"from",
"within",
"a",
"Node",
".",
"js",
"environment"
] | a27dea9c29778db936adf48be8042895af3a8f43 | https://github.com/solid/solid-auth-tls/blob/a27dea9c29778db936adf48be8042895af3a8f43/src/auth.js#L106-L153 |
45,802 | danigb/note.midi | index.js | midi | function midi (note) {
if ((typeof note === 'number' || typeof note === 'string') &&
note > 0 && note < 128) return +note
var p = Array.isArray(note) ? note : parse(note)
if (!p || p.length < 2) return null
return p[0] * 7 + p[1] * 12 + 12
} | javascript | function midi (note) {
if ((typeof note === 'number' || typeof note === 'string') &&
note > 0 && note < 128) return +note
var p = Array.isArray(note) ? note : parse(note)
if (!p || p.length < 2) return null
return p[0] * 7 + p[1] * 12 + 12
} | [
"function",
"midi",
"(",
"note",
")",
"{",
"if",
"(",
"(",
"typeof",
"note",
"===",
"'number'",
"||",
"typeof",
"note",
"===",
"'string'",
")",
"&&",
"note",
">",
"0",
"&&",
"note",
"<",
"128",
")",
"return",
"+",
"note",
"var",
"p",
"=",
"Array",
... | Get the midi number of a note
If the argument passed to this function is a valid midi number, it returns it
The note can be an string in scientific notation or
[array pitch notation](https://github.com/danigb/music.array.notation)
@name midi
@function
@param {String|Array} note - the note in string or array notation... | [
"Get",
"the",
"midi",
"number",
"of",
"a",
"note"
] | 4673847d157859995d51d10c8b853ee447fca448 | https://github.com/danigb/note.midi/blob/4673847d157859995d51d10c8b853ee447fca448/index.js#L24-L30 |
45,803 | cettia/cettia-protocol | lib/socket.js | find | function find() {
// If there is no remaining URI, fires `error` and `close` event as it means that all
// tries failed.
if (uris.length === 0) {
// Now that `connecting` event is being fired, there is no `error` and `close` event user
// added. Delays to fire them a little while.
... | javascript | function find() {
// If there is no remaining URI, fires `error` and `close` event as it means that all
// tries failed.
if (uris.length === 0) {
// Now that `connecting` event is being fired, there is no `error` and `close` event user
// added. Delays to fire them a little while.
... | [
"function",
"find",
"(",
")",
"{",
"// If there is no remaining URI, fires `error` and `close` event as it means that all",
"// tries failed.",
"if",
"(",
"uris",
".",
"length",
"===",
"0",
")",
"{",
"// Now that `connecting` event is being fired, there is no `error` and `close` even... | Starts a process to find a working transport. | [
"Starts",
"a",
"process",
"to",
"find",
"a",
"working",
"transport",
"."
] | 9af3b578a9ae7b33099932903b52faeb2ca92528 | https://github.com/cettia/cettia-protocol/blob/9af3b578a9ae7b33099932903b52faeb2ca92528/lib/socket.js#L120-L259 |
45,804 | cettia/cettia-protocol | lib/server.js | onevent | function onevent(event) {
// Event should have the following properties:
// * `id: string`: an event identifier.
// * `type: string`: an event type.
// * `data: any`: an event data.
// * `reply: boolean`: true if this event requires the reply.
// If the client sends a pl... | javascript | function onevent(event) {
// Event should have the following properties:
// * `id: string`: an event identifier.
// * `type: string`: an event type.
// * `data: any`: an event data.
// * `reply: boolean`: true if this event requires the reply.
// If the client sends a pl... | [
"function",
"onevent",
"(",
"event",
")",
"{",
"// Event should have the following properties:",
"// * `id: string`: an event identifier.",
"// * `type: string`: an event type.",
"// * `data: any`: an event data.",
"// * `reply: boolean`: true if this event requires the reply.",
"// If the cli... | When an event object is created from `text` or `binary` event. | [
"When",
"an",
"event",
"object",
"is",
"created",
"from",
"text",
"or",
"binary",
"event",
"."
] | 9af3b578a9ae7b33099932903b52faeb2ca92528 | https://github.com/cettia/cettia-protocol/blob/9af3b578a9ae7b33099932903b52faeb2ca92528/lib/server.js#L96-L124 |
45,805 | kidney/postcss-iconfont | src/index.js | insertGlyphsRules | function insertGlyphsRules(rule, result) {
// Reverse order
// make sure to insert the characters in ascending order
let glyphs = result.glyphs.slice(0);
let glyphLen = glyphs.length;
while (glyphLen--) {
let glyph = glyphs[glyphLen];
let node = postcss.rule({
selector: '... | javascript | function insertGlyphsRules(rule, result) {
// Reverse order
// make sure to insert the characters in ascending order
let glyphs = result.glyphs.slice(0);
let glyphLen = glyphs.length;
while (glyphLen--) {
let glyph = glyphs[glyphLen];
let node = postcss.rule({
selector: '... | [
"function",
"insertGlyphsRules",
"(",
"rule",
",",
"result",
")",
"{",
"// Reverse order",
"// make sure to insert the characters in ascending order",
"let",
"glyphs",
"=",
"result",
".",
"glyphs",
".",
"slice",
"(",
"0",
")",
";",
"let",
"glyphLen",
"=",
"glyphs",
... | Insert glyphs css rules
@param rule
@param result | [
"Insert",
"glyphs",
"css",
"rules"
] | 35bc3eecc0a0baa1db32ec523ff2904b0b9aa08d | https://github.com/kidney/postcss-iconfont/blob/35bc3eecc0a0baa1db32ec523ff2904b0b9aa08d/src/index.js#L170-L214 |
45,806 | rksm/estree-to-js | index.js | extractTypeSourcesFromMarkdown | function extractTypeSourcesFromMarkdown(mdSource) {
var types = lang.string.lines(mdSource).reduce((typesAkk, line) => {
if (line.trim().startsWith("//")) return typesAkk;
if (typesAkk.current && !line.trim().length) {
typesAkk.types.push(typesAkk.current); typesAkk.current = [];
} else if (typesAkk... | javascript | function extractTypeSourcesFromMarkdown(mdSource) {
var types = lang.string.lines(mdSource).reduce((typesAkk, line) => {
if (line.trim().startsWith("//")) return typesAkk;
if (typesAkk.current && !line.trim().length) {
typesAkk.types.push(typesAkk.current); typesAkk.current = [];
} else if (typesAkk... | [
"function",
"extractTypeSourcesFromMarkdown",
"(",
"mdSource",
")",
"{",
"var",
"types",
"=",
"lang",
".",
"string",
".",
"lines",
"(",
"mdSource",
")",
".",
"reduce",
"(",
"(",
"typesAkk",
",",
"line",
")",
"=>",
"{",
"if",
"(",
"line",
".",
"trim",
"... | -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- estree spec markdown parser | [
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"... | 3cb21c9c63ff329651f08197d353965e80551bd2 | https://github.com/rksm/estree-to-js/blob/3cb21c9c63ff329651f08197d353965e80551bd2/index.js#L53-L66 |
45,807 | alexindigo/cartesian | index.js | cartesian | function cartesian(list)
{
var last, init, keys, product = [];
if (Array.isArray(list))
{
init = [];
last = list.length - 1;
}
else if (typeof list == 'object' && list !== null)
{
init = {};
keys = Object.keys(list);
last = keys.length - 1;
}
else
{
throw new TypeError('Expect... | javascript | function cartesian(list)
{
var last, init, keys, product = [];
if (Array.isArray(list))
{
init = [];
last = list.length - 1;
}
else if (typeof list == 'object' && list !== null)
{
init = {};
keys = Object.keys(list);
last = keys.length - 1;
}
else
{
throw new TypeError('Expect... | [
"function",
"cartesian",
"(",
"list",
")",
"{",
"var",
"last",
",",
"init",
",",
"keys",
",",
"product",
"=",
"[",
"]",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"list",
")",
")",
"{",
"init",
"=",
"[",
"]",
";",
"last",
"=",
"list",
".",
... | Creates cartesian product of the provided properties
@param {object|array} list - list of (array) properties or array of arrays
@returns {array} all the combinations of the properties | [
"Creates",
"cartesian",
"product",
"of",
"the",
"provided",
"properties"
] | 378663ad87902a058bd7202eb3e87a91993c1d3a | https://github.com/alexindigo/cartesian/blob/378663ad87902a058bd7202eb3e87a91993c1d3a/index.js#L12-L60 |
45,808 | alexindigo/cartesian | index.js | store | function store(obj, elem, key)
{
Array.isArray(obj) ? obj.push(elem) : (obj[key] = elem);
} | javascript | function store(obj, elem, key)
{
Array.isArray(obj) ? obj.push(elem) : (obj[key] = elem);
} | [
"function",
"store",
"(",
"obj",
",",
"elem",
",",
"key",
")",
"{",
"Array",
".",
"isArray",
"(",
"obj",
")",
"?",
"obj",
".",
"push",
"(",
"elem",
")",
":",
"(",
"obj",
"[",
"key",
"]",
"=",
"elem",
")",
";",
"}"
] | Stores provided element in the provided object or array
@param {object|array} obj - object or array to add to
@param {mixed} elem - element to add
@param {string|number} key - object's property key to add to
@returns {void} | [
"Stores",
"provided",
"element",
"in",
"the",
"provided",
"object",
"or",
"array"
] | 378663ad87902a058bd7202eb3e87a91993c1d3a | https://github.com/alexindigo/cartesian/blob/378663ad87902a058bd7202eb3e87a91993c1d3a/index.js#L81-L84 |
45,809 | jordangarcia/nuclear-js-react-addons | build/nuclearComponent.js | nuclearComponent | function nuclearComponent(Component, getDataBindings) {
console.warn('nuclearComponent is deprecated, use `connect()` instead');
// support decorator pattern
// detect all React Components because they have a render method
if (arguments.length === 0 || !Component.prototype.render) {
// Component here is the... | javascript | function nuclearComponent(Component, getDataBindings) {
console.warn('nuclearComponent is deprecated, use `connect()` instead');
// support decorator pattern
// detect all React Components because they have a render method
if (arguments.length === 0 || !Component.prototype.render) {
// Component here is the... | [
"function",
"nuclearComponent",
"(",
"Component",
",",
"getDataBindings",
")",
"{",
"console",
".",
"warn",
"(",
"'nuclearComponent is deprecated, use `connect()` instead'",
")",
";",
"// support decorator pattern",
"// detect all React Components because they have a render method",
... | Provides dataBindings + reactor
as props to wrapped component
Example:
var WrappedComponent = nuclearComponent(Component, function(props) {
return { counter: 'counter' };
);
Also supports the decorator pattern:
@nuclearComponent((props) => {
return { counter: 'counter' }
})
class BaseComponent extends React.Component... | [
"Provides",
"dataBindings",
"+",
"reactor",
"as",
"props",
"to",
"wrapped",
"component"
] | 5550ebd6ec07bfec01aa557908735142613dcdb3 | https://github.com/jordangarcia/nuclear-js-react-addons/blob/5550ebd6ec07bfec01aa557908735142613dcdb3/build/nuclearComponent.js#L38-L48 |
45,810 | opendxl/node-red-contrib-dxl | lib/node-utils.js | function (value, defaultValue) {
if (module.exports.isEmpty(value)) {
value = defaultValue
} else if (typeof value === 'string') {
value = value.trim().toLowerCase()
switch (value) {
case 'false':
value = 0
break
case 'true':
value = 1
br... | javascript | function (value, defaultValue) {
if (module.exports.isEmpty(value)) {
value = defaultValue
} else if (typeof value === 'string') {
value = value.trim().toLowerCase()
switch (value) {
case 'false':
value = 0
break
case 'true':
value = 1
br... | [
"function",
"(",
"value",
",",
"defaultValue",
")",
"{",
"if",
"(",
"module",
".",
"exports",
".",
"isEmpty",
"(",
"value",
")",
")",
"{",
"value",
"=",
"defaultValue",
"}",
"else",
"if",
"(",
"typeof",
"value",
"===",
"'string'",
")",
"{",
"value",
... | Convert the supplied value into a number.
@param value - The value to convert.
@param defaultValue - If the value parameter is undefined, null,
a zero-length string, or a string containing only whitespace characters,
the defaultValue is returned.
@returns The converted or default value. If the value parameter is
non-nu... | [
"Convert",
"the",
"supplied",
"value",
"into",
"a",
"number",
"."
] | a68169c4357162f48d98006fb40843795f997f28 | https://github.com/opendxl/node-red-contrib-dxl/blob/a68169c4357162f48d98006fb40843795f997f28/lib/node-utils.js#L21-L42 | |
45,811 | sheepsteak/react-perf-component | lib/index.js | perf | function perf(Target) {
if (process.env.NODE_ENV === 'production') {
return Target;
}
// eslint-disable-next-line global-require
var ReactPerf = require('react-addons-perf');
var Perf = function (_Component) {
_inherits(Perf, _Component);
function Perf() {
_classCallCheck(this, Perf);
... | javascript | function perf(Target) {
if (process.env.NODE_ENV === 'production') {
return Target;
}
// eslint-disable-next-line global-require
var ReactPerf = require('react-addons-perf');
var Perf = function (_Component) {
_inherits(Perf, _Component);
function Perf() {
_classCallCheck(this, Perf);
... | [
"function",
"perf",
"(",
"Target",
")",
"{",
"if",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
"===",
"'production'",
")",
"{",
"return",
"Target",
";",
"}",
"// eslint-disable-next-line global-require",
"var",
"ReactPerf",
"=",
"require",
"(",
"'react-addons-p... | Wraps the passed in `Component` in a higher-order component. It can then
measure the performance of every render of the `Component`.
Can also be used as an ES2016 decorator.
@param {ReactComponent} Component the component to wrap
@return {ReactComponent} the wrapped component | [
"Wraps",
"the",
"passed",
"in",
"Component",
"in",
"a",
"higher",
"-",
"order",
"component",
".",
"It",
"can",
"then",
"measure",
"the",
"performance",
"of",
"every",
"render",
"of",
"the",
"Component",
"."
] | b6b34c578e715940e59f958ba5b5d1b52a64f253 | https://github.com/sheepsteak/react-perf-component/blob/b6b34c578e715940e59f958ba5b5d1b52a64f253/lib/index.js#L31-L81 |
45,812 | jordangarcia/nuclear-js-react-addons | build/provideReactor.js | provideReactor | function provideReactor(Component, additionalContextTypes) {
console.warn('`provideReactor` is deprecated, use `<Provider reactor={reactor} />` instead');
// support decorator pattern
if (arguments.length === 0 || typeof arguments[0] !== 'function') {
additionalContextTypes = arguments[0];
return function... | javascript | function provideReactor(Component, additionalContextTypes) {
console.warn('`provideReactor` is deprecated, use `<Provider reactor={reactor} />` instead');
// support decorator pattern
if (arguments.length === 0 || typeof arguments[0] !== 'function') {
additionalContextTypes = arguments[0];
return function... | [
"function",
"provideReactor",
"(",
"Component",
",",
"additionalContextTypes",
")",
"{",
"console",
".",
"warn",
"(",
"'`provideReactor` is deprecated, use `<Provider reactor={reactor} />` instead'",
")",
";",
"// support decorator pattern",
"if",
"(",
"arguments",
".",
"leng... | Provides reactor prop to all children as React context
Example:
var WrappedComponent = provideReactor(Component, {
foo: React.PropTypes.string
});
Also supports the decorator pattern:
@provideReactor({
foo: React.PropTypes.string
})
class BaseComponent extends React.Component {
render() {
return <div/>;
}
}
@method ... | [
"Provides",
"reactor",
"prop",
"to",
"all",
"children",
"as",
"React",
"context"
] | 5550ebd6ec07bfec01aa557908735142613dcdb3 | https://github.com/jordangarcia/nuclear-js-react-addons/blob/5550ebd6ec07bfec01aa557908735142613dcdb3/build/provideReactor.js#L81-L92 |
45,813 | jefftham/wsm | lib/wsm.js | wsConnect | function wsConnect() {
var typeOfConnection;
if (location.protocol === 'https:') {
typeOfConnection = 'wss';
} else {
typeOfConnection = 'ws'
}
self.ws = new WebSocket(typeOfConnection + '://' + location.hostname + ':' + loca... | javascript | function wsConnect() {
var typeOfConnection;
if (location.protocol === 'https:') {
typeOfConnection = 'wss';
} else {
typeOfConnection = 'ws'
}
self.ws = new WebSocket(typeOfConnection + '://' + location.hostname + ':' + loca... | [
"function",
"wsConnect",
"(",
")",
"{",
"var",
"typeOfConnection",
";",
"if",
"(",
"location",
".",
"protocol",
"===",
"'https:'",
")",
"{",
"typeOfConnection",
"=",
"'wss'",
";",
"}",
"else",
"{",
"typeOfConnection",
"=",
"'ws'",
"}",
"self",
".",
"ws",
... | on browser
wrap browser's websocket connection into one function, if the connection drop or close, try to reconnect itself. | [
"on",
"browser",
"wrap",
"browser",
"s",
"websocket",
"connection",
"into",
"one",
"function",
"if",
"the",
"connection",
"drop",
"or",
"close",
"try",
"to",
"reconnect",
"itself",
"."
] | 6d88aa1e8cc21384aa918c3f9526fe61aa92483f | https://github.com/jefftham/wsm/blob/6d88aa1e8cc21384aa918c3f9526fe61aa92483f/lib/wsm.js#L172-L205 |
45,814 | Ustimov/node-red-flow-drawer | src/red/localfilesystem.js | getLocalNodeFiles | function getLocalNodeFiles(dir) {
dir = path.resolve(dir);
var result = [];
var files = [];
var icons = [];
try {
files = fs.readdirSync(dir);
} catch(err) {
return {files: [], icons: []};
}
files.sort();
files.forEach(function(fn) {
var stats = fs.statSync(p... | javascript | function getLocalNodeFiles(dir) {
dir = path.resolve(dir);
var result = [];
var files = [];
var icons = [];
try {
files = fs.readdirSync(dir);
} catch(err) {
return {files: [], icons: []};
}
files.sort();
files.forEach(function(fn) {
var stats = fs.statSync(p... | [
"function",
"getLocalNodeFiles",
"(",
"dir",
")",
"{",
"dir",
"=",
"path",
".",
"resolve",
"(",
"dir",
")",
";",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"files",
"=",
"[",
"]",
";",
"var",
"icons",
"=",
"[",
"]",
";",
"try",
"{",
"files",
"... | Synchronously walks the directory looking for node files.
Emits 'node-icon-dir' events for an icon dirs found
@param dir the directory to search
@return an array of fully-qualified paths to .js files | [
"Synchronously",
"walks",
"the",
"directory",
"looking",
"for",
"node",
"files",
".",
"Emits",
"node",
"-",
"icon",
"-",
"dir",
"events",
"for",
"an",
"icon",
"dirs",
"found"
] | 58bb5f760d6800f41b9557e030b1ea7db2db02c0 | https://github.com/Ustimov/node-red-flow-drawer/blob/58bb5f760d6800f41b9557e030b1ea7db2db02c0/src/red/localfilesystem.js#L74-L108 |
45,815 | Ustimov/node-red-flow-drawer | src/red/localfilesystem.js | scanTreeForNodesModules | function scanTreeForNodesModules(moduleName) {
var dir = settings.coreNodesDir;
var results = [];
var userDir;
if (settings.userDir) {
userDir = path.join(settings.userDir,"node_modules");
results = scanDirForNodesModules(userDir,moduleName);
results.forEach(function(r) { r.loca... | javascript | function scanTreeForNodesModules(moduleName) {
var dir = settings.coreNodesDir;
var results = [];
var userDir;
if (settings.userDir) {
userDir = path.join(settings.userDir,"node_modules");
results = scanDirForNodesModules(userDir,moduleName);
results.forEach(function(r) { r.loca... | [
"function",
"scanTreeForNodesModules",
"(",
"moduleName",
")",
"{",
"var",
"dir",
"=",
"settings",
".",
"coreNodesDir",
";",
"var",
"results",
"=",
"[",
"]",
";",
"var",
"userDir",
";",
"if",
"(",
"settings",
".",
"userDir",
")",
"{",
"userDir",
"=",
"pa... | Scans the node_modules path for nodes
@param moduleName the name of the module to be found
@return a list of node modules: {dir,package} | [
"Scans",
"the",
"node_modules",
"path",
"for",
"nodes"
] | 58bb5f760d6800f41b9557e030b1ea7db2db02c0 | https://github.com/Ustimov/node-red-flow-drawer/blob/58bb5f760d6800f41b9557e030b1ea7db2db02c0/src/red/localfilesystem.js#L163-L186 |
45,816 | NickCis/polygonize | src/Graph.js | validateGeoJson | function validateGeoJson(geoJson) {
if (!geoJson)
throw new Error('No geojson passed');
if (geoJson.type !== 'FeatureCollection' &&
geoJson.type !== 'GeometryCollection' &&
geoJson.type !== 'MultiLineString' &&
geoJson.type !== 'LineString' &&
geoJson.type !== 'Feature'
)
throw new Error(... | javascript | function validateGeoJson(geoJson) {
if (!geoJson)
throw new Error('No geojson passed');
if (geoJson.type !== 'FeatureCollection' &&
geoJson.type !== 'GeometryCollection' &&
geoJson.type !== 'MultiLineString' &&
geoJson.type !== 'LineString' &&
geoJson.type !== 'Feature'
)
throw new Error(... | [
"function",
"validateGeoJson",
"(",
"geoJson",
")",
"{",
"if",
"(",
"!",
"geoJson",
")",
"throw",
"new",
"Error",
"(",
"'No geojson passed'",
")",
";",
"if",
"(",
"geoJson",
".",
"type",
"!==",
"'FeatureCollection'",
"&&",
"geoJson",
".",
"type",
"!==",
"'... | Validates the geoJson.
@param {Geojson} geoJson - input geoJson.
@throws {Error} if geoJson is invalid. | [
"Validates",
"the",
"geoJson",
"."
] | f8f9ea78debfdfd1d60a7429ddf6ba64fb54d0cc | https://github.com/NickCis/polygonize/blob/f8f9ea78debfdfd1d60a7429ddf6ba64fb54d0cc/src/Graph.js#L12-L23 |
45,817 | discolabs/grunt-shopify-theme-settings | tasks/shopify_theme_settings.js | getCombinedTemplateDirectory | function getCombinedTemplateDirectory(templateDirectories) {
// Automatically track and clean up files at exit.
temp.track();
// Create a temporary directory to hold our template files.
var combinedTemplateDirectory = temp.mkdirSync('templates');
// Copy templates from our source directories into ... | javascript | function getCombinedTemplateDirectory(templateDirectories) {
// Automatically track and clean up files at exit.
temp.track();
// Create a temporary directory to hold our template files.
var combinedTemplateDirectory = temp.mkdirSync('templates');
// Copy templates from our source directories into ... | [
"function",
"getCombinedTemplateDirectory",
"(",
"templateDirectories",
")",
"{",
"// Automatically track and clean up files at exit.",
"temp",
".",
"track",
"(",
")",
";",
"// Create a temporary directory to hold our template files.",
"var",
"combinedTemplateDirectory",
"=",
"temp... | Given a list of template directories, compile them into a single template directory.
Templates with the same name will be overridden, with preference given to those first in the list.
@param templateDirectories
@return string | [
"Given",
"a",
"list",
"of",
"template",
"directories",
"compile",
"them",
"into",
"a",
"single",
"template",
"directory",
".",
"Templates",
"with",
"the",
"same",
"name",
"will",
"be",
"overridden",
"with",
"preference",
"given",
"to",
"those",
"first",
"in",
... | 31ac81131de393ef4d5715f2d90a5641c8d991f8 | https://github.com/discolabs/grunt-shopify-theme-settings/blob/31ac81131de393ef4d5715f2d90a5641c8d991f8/tasks/shopify_theme_settings.js#L99-L116 |
45,818 | discolabs/grunt-shopify-theme-settings | tasks/shopify_theme_settings.js | addSwigFilters | function addSwigFilters() {
/**
* Zero padding function.
* Used as both a filter and internally here.
*
* @param input
* @param length
* @returns {string}
*/
function zeropad(input, length) {
input = input + ''; // Ensure input is a string.
length = length || 2; /... | javascript | function addSwigFilters() {
/**
* Zero padding function.
* Used as both a filter and internally here.
*
* @param input
* @param length
* @returns {string}
*/
function zeropad(input, length) {
input = input + ''; // Ensure input is a string.
length = length || 2; /... | [
"function",
"addSwigFilters",
"(",
")",
"{",
"/**\n * Zero padding function.\n * Used as both a filter and internally here.\n *\n * @param input\n * @param length\n * @returns {string}\n */",
"function",
"zeropad",
"(",
"input",
",",
"length",
")",
"{",
"input... | Add some custom filters to Swig for use in templates. | [
"Add",
"some",
"custom",
"filters",
"to",
"Swig",
"for",
"use",
"in",
"templates",
"."
] | 31ac81131de393ef4d5715f2d90a5641c8d991f8 | https://github.com/discolabs/grunt-shopify-theme-settings/blob/31ac81131de393ef4d5715f2d90a5641c8d991f8/tasks/shopify_theme_settings.js#L121-L173 |
45,819 | discolabs/grunt-shopify-theme-settings | tasks/shopify_theme_settings.js | zeropad | function zeropad(input, length) {
input = input + ''; // Ensure input is a string.
length = length || 2; // Ensure a length is set.
return input.length >= length ? input : new Array(length - input.length + 1).join('0') + input;
} | javascript | function zeropad(input, length) {
input = input + ''; // Ensure input is a string.
length = length || 2; // Ensure a length is set.
return input.length >= length ? input : new Array(length - input.length + 1).join('0') + input;
} | [
"function",
"zeropad",
"(",
"input",
",",
"length",
")",
"{",
"input",
"=",
"input",
"+",
"''",
";",
"// Ensure input is a string.",
"length",
"=",
"length",
"||",
"2",
";",
"// Ensure a length is set.",
"return",
"input",
".",
"length",
">=",
"length",
"?",
... | Zero padding function.
Used as both a filter and internally here.
@param input
@param length
@returns {string} | [
"Zero",
"padding",
"function",
".",
"Used",
"as",
"both",
"a",
"filter",
"and",
"internally",
"here",
"."
] | 31ac81131de393ef4d5715f2d90a5641c8d991f8 | https://github.com/discolabs/grunt-shopify-theme-settings/blob/31ac81131de393ef4d5715f2d90a5641c8d991f8/tasks/shopify_theme_settings.js#L131-L135 |
45,820 | jhermsmeier/gulp-rm | index.js | rmdirWalk | function rmdirWalk( ls, done ) {
if( ls.length === 0 ) return done()
fs.rmdir( ls.shift().path, function( error ) {
if( error ) log( error.message )
rmdirWalk( ls, done )
})
} | javascript | function rmdirWalk( ls, done ) {
if( ls.length === 0 ) return done()
fs.rmdir( ls.shift().path, function( error ) {
if( error ) log( error.message )
rmdirWalk( ls, done )
})
} | [
"function",
"rmdirWalk",
"(",
"ls",
",",
"done",
")",
"{",
"if",
"(",
"ls",
".",
"length",
"===",
"0",
")",
"return",
"done",
"(",
")",
"fs",
".",
"rmdir",
"(",
"ls",
".",
"shift",
"(",
")",
".",
"path",
",",
"function",
"(",
"error",
")",
"{",... | Walk an array of directories and
delete one after another
@param {Array<Object>} ls
@param {Function} done | [
"Walk",
"an",
"array",
"of",
"directories",
"and",
"delete",
"one",
"after",
"another"
] | 73a223b13b55030b0201da313124a42f4163eafb | https://github.com/jhermsmeier/gulp-rm/blob/73a223b13b55030b0201da313124a42f4163eafb/index.js#L12-L18 |
45,821 | koajs/atomic-session | lib/mongodb.js | Session | function Session(context) {
this.context = context
this.cookies = context.cookies
this.update = this.update.bind(this)
} | javascript | function Session(context) {
this.context = context
this.cookies = context.cookies
this.update = this.update.bind(this)
} | [
"function",
"Session",
"(",
"context",
")",
"{",
"this",
".",
"context",
"=",
"context",
"this",
".",
"cookies",
"=",
"context",
".",
"cookies",
"this",
".",
"update",
"=",
"this",
".",
"update",
".",
"bind",
"(",
"this",
")",
"}"
] | Session constructor. | [
"Session",
"constructor",
"."
] | 5ef7ccd8ae2189e1e35a9422670f83d7b7ba079a | https://github.com/koajs/atomic-session/blob/5ef7ccd8ae2189e1e35a9422670f83d7b7ba079a/lib/mongodb.js#L90-L94 |
45,822 | adriann0/npm-aprs-parser | lib/SymbolIconUtils.js | function (symbol) {
return symbolDict[symbol.charCodeAt(0)] && symbolDict[symbol.charCodeAt(0)][symbol.charCodeAt(1)] || symbolDict[symbol.charCodeAt(1)] && symbolDict[symbol.charCodeAt(0)][symbol.charCodeAt(0)];
} | javascript | function (symbol) {
return symbolDict[symbol.charCodeAt(0)] && symbolDict[symbol.charCodeAt(0)][symbol.charCodeAt(1)] || symbolDict[symbol.charCodeAt(1)] && symbolDict[symbol.charCodeAt(0)][symbol.charCodeAt(0)];
} | [
"function",
"(",
"symbol",
")",
"{",
"return",
"symbolDict",
"[",
"symbol",
".",
"charCodeAt",
"(",
"0",
")",
"]",
"&&",
"symbolDict",
"[",
"symbol",
".",
"charCodeAt",
"(",
"0",
")",
"]",
"[",
"symbol",
".",
"charCodeAt",
"(",
"1",
")",
"]",
"||",
... | table + symbol id | [
"table",
"+",
"symbol",
"id"
] | c189e758cca0641a37c426ebd4c9e0a880d6bdb3 | https://github.com/adriann0/npm-aprs-parser/blob/c189e758cca0641a37c426ebd4c9e0a880d6bdb3/lib/SymbolIconUtils.js#L204-L206 | |
45,823 | LastLeaf/epub-generator | lib/builder.js | function(){
STATIC_FILES.forEach(function(file){
addFile(fs.createReadStream(__dirname + '/templates/' + file), { name: file });
});
} | javascript | function(){
STATIC_FILES.forEach(function(file){
addFile(fs.createReadStream(__dirname + '/templates/' + file), { name: file });
});
} | [
"function",
"(",
")",
"{",
"STATIC_FILES",
".",
"forEach",
"(",
"function",
"(",
"file",
")",
"{",
"addFile",
"(",
"fs",
".",
"createReadStream",
"(",
"__dirname",
"+",
"'/templates/'",
"+",
"file",
")",
",",
"{",
"name",
":",
"file",
"}",
")",
";",
... | add static files | [
"add",
"static",
"files"
] | de7191f990c6c61dc4ff55238e79be7517e46bc3 | https://github.com/LastLeaf/epub-generator/blob/de7191f990c6c61dc4ff55238e79be7517e46bc3/lib/builder.js#L46-L50 | |
45,824 | LastLeaf/epub-generator | lib/builder.js | function(){
for(var i=0; i<DYNAMIC_FILES.length; i++) {
addFile(dynamicFilesCompiled[i](options), { name: DYNAMIC_FILES[i] });
}
} | javascript | function(){
for(var i=0; i<DYNAMIC_FILES.length; i++) {
addFile(dynamicFilesCompiled[i](options), { name: DYNAMIC_FILES[i] });
}
} | [
"function",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"DYNAMIC_FILES",
".",
"length",
";",
"i",
"++",
")",
"{",
"addFile",
"(",
"dynamicFilesCompiled",
"[",
"i",
"]",
"(",
"options",
")",
",",
"{",
"name",
":",
"DYNAMIC_FILES"... | add dynamic files | [
"add",
"dynamic",
"files"
] | de7191f990c6c61dc4ff55238e79be7517e46bc3 | https://github.com/LastLeaf/epub-generator/blob/de7191f990c6c61dc4ff55238e79be7517e46bc3/lib/builder.js#L53-L57 | |
45,825 | nebrius/transport-logger | lib/transportlogger.js | Transport | function Transport(settings, levels) {
settings = settings || {};
this.levels = levels;
// Set the base settings
this.settings = {
levels: levels,
timestamp: !!settings.timestamp,
prependLevel: !!settings.prependLevel,
colorize: !!settings.colorize,
name: settings.name
};
// Parse the ... | javascript | function Transport(settings, levels) {
settings = settings || {};
this.levels = levels;
// Set the base settings
this.settings = {
levels: levels,
timestamp: !!settings.timestamp,
prependLevel: !!settings.prependLevel,
colorize: !!settings.colorize,
name: settings.name
};
// Parse the ... | [
"function",
"Transport",
"(",
"settings",
",",
"levels",
")",
"{",
"settings",
"=",
"settings",
"||",
"{",
"}",
";",
"this",
".",
"levels",
"=",
"levels",
";",
"// Set the base settings",
"this",
".",
"settings",
"=",
"{",
"levels",
":",
"levels",
",",
"... | Settings for creating a transport.
@name module:transport-logger.TransportSettings
@type Object
@property {Boolean} [timestamp] Timestamps each log message with a UTC date (default false)
@property {Boolean} [prependLevel] Prepends each log message with the log level (default false)
@property {String} [minLevel] The m... | [
"Settings",
"for",
"creating",
"a",
"transport",
"."
] | d9a0eef021ac9511ed215e688ddb4ca97392eea1 | https://github.com/nebrius/transport-logger/blob/d9a0eef021ac9511ed215e688ddb4ca97392eea1/lib/transportlogger.js#L103-L145 |
45,826 | nebrius/transport-logger | lib/transportlogger.js | Logger | function Logger(transports, settings) {
var i, len,
transport,
levels,
transportInstances = [],
names = {};
// Normalize the inputs
if (!transports) {
transports = [{}];
} else if (!Array.isArray(transports)) {
transports = [transports];
}
settings = settings || {};
levels... | javascript | function Logger(transports, settings) {
var i, len,
transport,
levels,
transportInstances = [],
names = {};
// Normalize the inputs
if (!transports) {
transports = [{}];
} else if (!Array.isArray(transports)) {
transports = [transports];
}
settings = settings || {};
levels... | [
"function",
"Logger",
"(",
"transports",
",",
"settings",
")",
"{",
"var",
"i",
",",
"len",
",",
"transport",
",",
"levels",
",",
"transportInstances",
"=",
"[",
"]",
",",
"names",
"=",
"{",
"}",
";",
"// Normalize the inputs",
"if",
"(",
"!",
"transport... | The global settings for the logger that applies to all transports
@name module:transport-logger.GlobalSettings
@type Object
@property {Object} [levels] The log levels
@property {String} <log-level> The key specifies the log level, and the value specifies the color. Colors are one of
'black', 'red', 'green', 'yellow', ... | [
"The",
"global",
"settings",
"for",
"the",
"logger",
"that",
"applies",
"to",
"all",
"transports"
] | d9a0eef021ac9511ed215e688ddb4ca97392eea1 | https://github.com/nebrius/transport-logger/blob/d9a0eef021ac9511ed215e688ddb4ca97392eea1/lib/transportlogger.js#L217-L285 |
45,827 | jan-swiecki/node-autowire | lib/ModuleFinder.js | mapAllNames | function mapAllNames(path) {
log("[%s] Mapping %s", self.parentModuleName, path);
fs.readdirSync(path).forEach(function(p){
var absPath = PATH.resolve(path+PATH.sep+p);
var lstat = fs.lstatSync(absPath);
if(lstat.isFile() && isModule(p)) {
var name = getModuleName(p);
self.upd... | javascript | function mapAllNames(path) {
log("[%s] Mapping %s", self.parentModuleName, path);
fs.readdirSync(path).forEach(function(p){
var absPath = PATH.resolve(path+PATH.sep+p);
var lstat = fs.lstatSync(absPath);
if(lstat.isFile() && isModule(p)) {
var name = getModuleName(p);
self.upd... | [
"function",
"mapAllNames",
"(",
"path",
")",
"{",
"log",
"(",
"\"[%s] Mapping %s\"",
",",
"self",
".",
"parentModuleName",
",",
"path",
")",
";",
"fs",
".",
"readdirSync",
"(",
"path",
")",
".",
"forEach",
"(",
"function",
"(",
"p",
")",
"{",
"var",
"a... | Saves absPath -> filename mapping in the map
@param path | [
"Saves",
"absPath",
"-",
">",
"filename",
"mapping",
"in",
"the",
"map"
] | a5bddb8d1d581ffab9c23e2a50c8fedede83ec1b | https://github.com/jan-swiecki/node-autowire/blob/a5bddb8d1d581ffab9c23e2a50c8fedede83ec1b/lib/ModuleFinder.js#L338-L363 |
45,828 | jan-swiecki/node-autowire | lib/ModuleFinder.js | findProjectRoot | function findProjectRoot(startPath) {
log.trace("findProjectRoot startPath = %s", startPath);
if(isDiskRoot()) {
if(hasPackageJson()) {
return startPath;
} else {
throw new Error("Cannot find project root");
}
} else if(hasPackageJson()) {
return startPath;
} else... | javascript | function findProjectRoot(startPath) {
log.trace("findProjectRoot startPath = %s", startPath);
if(isDiskRoot()) {
if(hasPackageJson()) {
return startPath;
} else {
throw new Error("Cannot find project root");
}
} else if(hasPackageJson()) {
return startPath;
} else... | [
"function",
"findProjectRoot",
"(",
"startPath",
")",
"{",
"log",
".",
"trace",
"(",
"\"findProjectRoot startPath = %s\"",
",",
"startPath",
")",
";",
"if",
"(",
"isDiskRoot",
"(",
")",
")",
"{",
"if",
"(",
"hasPackageJson",
"(",
")",
")",
"{",
"return",
"... | Going up the folder tree returns the first
folder with package.json present.
@param startPath
@returns {*} | [
"Going",
"up",
"the",
"folder",
"tree",
"returns",
"the",
"first",
"folder",
"with",
"package",
".",
"json",
"present",
"."
] | a5bddb8d1d581ffab9c23e2a50c8fedede83ec1b | https://github.com/jan-swiecki/node-autowire/blob/a5bddb8d1d581ffab9c23e2a50c8fedede83ec1b/lib/ModuleFinder.js#L400-L421 |
45,829 | cettia/cettia-protocol | lib/transport-http-server.js | createLongpollTransport | function createLongpollTransport(req, res) {
// The current response which can be used to send a message or close the connection. It's not
// null when it's available and null when it's not available.
var response;
// A flag to mark this transport is aborted. It's used when `response` is not available, if
// ... | javascript | function createLongpollTransport(req, res) {
// The current response which can be used to send a message or close the connection. It's not
// null when it's available and null when it's not available.
var response;
// A flag to mark this transport is aborted. It's used when `response` is not available, if
// ... | [
"function",
"createLongpollTransport",
"(",
"req",
",",
"res",
")",
"{",
"// The current response which can be used to send a message or close the connection. It's not",
"// null when it's available and null when it's not available.",
"var",
"response",
";",
"// A flag to mark this transpo... | The client performs a HTTP persistent connection and the server ends the response with data. Then, the client receives it and performs a request again and again. | [
"The",
"client",
"performs",
"a",
"HTTP",
"persistent",
"connection",
"and",
"the",
"server",
"ends",
"the",
"response",
"with",
"data",
".",
"Then",
"the",
"client",
"receives",
"it",
"and",
"performs",
"a",
"request",
"again",
"and",
"again",
"."
] | 9af3b578a9ae7b33099932903b52faeb2ca92528 | https://github.com/cettia/cettia-protocol/blob/9af3b578a9ae7b33099932903b52faeb2ca92528/lib/transport-http-server.js#L271-L425 |
45,830 | eladnava/koa-async | wrapper.js | wrapAsyncMethod | function wrapAsyncMethod(fn, ctx) {
return function() {
// Obtain function arguments
var args = [].slice.call(arguments);
// Return a thunkified function that receives a done callback
return new Promise(function(resolve, reject) {
// Add a custom callback to provided arg... | javascript | function wrapAsyncMethod(fn, ctx) {
return function() {
// Obtain function arguments
var args = [].slice.call(arguments);
// Return a thunkified function that receives a done callback
return new Promise(function(resolve, reject) {
// Add a custom callback to provided arg... | [
"function",
"wrapAsyncMethod",
"(",
"fn",
",",
"ctx",
")",
"{",
"return",
"function",
"(",
")",
"{",
"// Obtain function arguments",
"var",
"args",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"// Return a thunkified function that receiv... | Wrap async methods inside a promise | [
"Wrap",
"async",
"methods",
"inside",
"a",
"promise"
] | e1f2b3a483c0c8dde853bbc29860b96bcf91707a | https://github.com/eladnava/koa-async/blob/e1f2b3a483c0c8dde853bbc29860b96bcf91707a/wrapper.js#L4-L26 |
45,831 | eladnava/koa-async | wrapper.js | wrapAsync | function wrapAsync() {
// Traverse async methods
for (var fn in async) {
// Promisify the method
async[fn] = wrapAsyncMethod(async[fn], async);
}
// Return co-friendly async object
return async;
} | javascript | function wrapAsync() {
// Traverse async methods
for (var fn in async) {
// Promisify the method
async[fn] = wrapAsyncMethod(async[fn], async);
}
// Return co-friendly async object
return async;
} | [
"function",
"wrapAsync",
"(",
")",
"{",
"// Traverse async methods",
"for",
"(",
"var",
"fn",
"in",
"async",
")",
"{",
"// Promisify the method",
"async",
"[",
"fn",
"]",
"=",
"wrapAsyncMethod",
"(",
"async",
"[",
"fn",
"]",
",",
"async",
")",
";",
"}",
... | Wraps an async object with co-friendly functions | [
"Wraps",
"an",
"async",
"object",
"with",
"co",
"-",
"friendly",
"functions"
] | e1f2b3a483c0c8dde853bbc29860b96bcf91707a | https://github.com/eladnava/koa-async/blob/e1f2b3a483c0c8dde853bbc29860b96bcf91707a/wrapper.js#L29-L38 |
45,832 | silas/node-mesos | lib/marathon.js | Marathon | function Marathon(opts) {
if (!(this instanceof Marathon)) {
return new Marathon(opts);
}
opts = opts || {};
if (!opts.baseUrl) {
opts.baseUrl = (opts.secure ? 'https:' : 'http:') + '//' +
(opts.host || '127.0.0.1') + ':' +
(opts.port || '8080') + '/v2';
}
opts.name = 'marathon';
opt... | javascript | function Marathon(opts) {
if (!(this instanceof Marathon)) {
return new Marathon(opts);
}
opts = opts || {};
if (!opts.baseUrl) {
opts.baseUrl = (opts.secure ? 'https:' : 'http:') + '//' +
(opts.host || '127.0.0.1') + ':' +
(opts.port || '8080') + '/v2';
}
opts.name = 'marathon';
opt... | [
"function",
"Marathon",
"(",
"opts",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Marathon",
")",
")",
"{",
"return",
"new",
"Marathon",
"(",
"opts",
")",
";",
"}",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"opts",
".",
... | Initialize a new `Marathon` client.
@param {Object} opts | [
"Initialize",
"a",
"new",
"Marathon",
"client",
"."
] | 157ca9fa9cfeb13def49cf8f6ef53ff7e708da95 | https://github.com/silas/node-mesos/blob/157ca9fa9cfeb13def49cf8f6ef53ff7e708da95/lib/marathon.js#L25-L44 |
45,833 | jordangarcia/nuclear-js-react-addons | src/nuclearMixin.js | getState | function getState(reactor, data) {
var state = {}
each(data, function(value, key) {
state[key] = reactor.evaluate(value)
})
return state
} | javascript | function getState(reactor, data) {
var state = {}
each(data, function(value, key) {
state[key] = reactor.evaluate(value)
})
return state
} | [
"function",
"getState",
"(",
"reactor",
",",
"data",
")",
"{",
"var",
"state",
"=",
"{",
"}",
"each",
"(",
"data",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"state",
"[",
"key",
"]",
"=",
"reactor",
".",
"evaluate",
"(",
"value",
")",
... | Returns a mapping of the getDataBinding keys to
the reactor values | [
"Returns",
"a",
"mapping",
"of",
"the",
"getDataBinding",
"keys",
"to",
"the",
"reactor",
"values"
] | 5550ebd6ec07bfec01aa557908735142613dcdb3 | https://github.com/jordangarcia/nuclear-js-react-addons/blob/5550ebd6ec07bfec01aa557908735142613dcdb3/src/nuclearMixin.js#L18-L24 |
45,834 | IonicaBizau/fs-file-tree | lib/index.js | fsFileTree | function fsFileTree (inputPath, opts, cb) {
let result = {};
if (typeof inputPath === "function") {
cb = inputPath;
inputPath = process.cwd();
opts = {};
} else if (typeof opts === "function") {
cb = opts;
if (typeof inputPath === "object") {
opts = inputP... | javascript | function fsFileTree (inputPath, opts, cb) {
let result = {};
if (typeof inputPath === "function") {
cb = inputPath;
inputPath = process.cwd();
opts = {};
} else if (typeof opts === "function") {
cb = opts;
if (typeof inputPath === "object") {
opts = inputP... | [
"function",
"fsFileTree",
"(",
"inputPath",
",",
"opts",
",",
"cb",
")",
"{",
"let",
"result",
"=",
"{",
"}",
";",
"if",
"(",
"typeof",
"inputPath",
"===",
"\"function\"",
")",
"{",
"cb",
"=",
"inputPath",
";",
"inputPath",
"=",
"process",
".",
"cwd",
... | fsFileTree
Get a directory file tree as an object.
@name fsFileTree
@function
@param {String} inputPath The input path.
@param {Object} opts An object containing the following fields:
- `camelCase` (Boolean): Convert the file names in camelcase format (to be easily accessible using dot notation).
- `all` (Boolean): I... | [
"fsFileTree",
"Get",
"a",
"directory",
"file",
"tree",
"as",
"an",
"object",
"."
] | a16cf9258ef96734b4767d546edd17616d61df21 | https://github.com/IonicaBizau/fs-file-tree/blob/a16cf9258ef96734b4767d546edd17616d61df21/lib/index.js#L24-L65 |
45,835 | gragland/react-component-data | src/resolveRecursive.js | walkTree | function walkTree(element, context, mergeProps, visitor) {
const Component = element.type;
if (typeof Component === 'function') {
const props = assign({}, Component.defaultProps, element.props, (mergeProps || {}));
let childContext = context;
let child;
// Are we are a react class?
// https:... | javascript | function walkTree(element, context, mergeProps, visitor) {
const Component = element.type;
if (typeof Component === 'function') {
const props = assign({}, Component.defaultProps, element.props, (mergeProps || {}));
let childContext = context;
let child;
// Are we are a react class?
// https:... | [
"function",
"walkTree",
"(",
"element",
",",
"context",
",",
"mergeProps",
",",
"visitor",
")",
"{",
"const",
"Component",
"=",
"element",
".",
"type",
";",
"if",
"(",
"typeof",
"Component",
"===",
"'function'",
")",
"{",
"const",
"props",
"=",
"assign",
... | Recurse an React Element tree, running visitor on each element. If visitor returns `false`, don't call the element's render function or recurse into its child elements | [
"Recurse",
"an",
"React",
"Element",
"tree",
"running",
"visitor",
"on",
"each",
"element",
".",
"If",
"visitor",
"returns",
"false",
"don",
"t",
"call",
"the",
"element",
"s",
"render",
"function",
"or",
"recurse",
"into",
"its",
"child",
"elements"
] | 788397f133e4d327e074689f17b3f8e47abdaf2e | https://github.com/gragland/react-component-data/blob/788397f133e4d327e074689f17b3f8e47abdaf2e/src/resolveRecursive.js#L10-L88 |
45,836 | gragland/react-component-data | src/resolveRecursive.js | getDataFromTree | function getDataFromTree(rootElement, rootContext, fetchRoot, mergeProps, isTopLevel){
//console.log(`Now searching element (${rootElement.type.name || rootElement.type.displayName}):`, rootElement);
// Get array of queries (fetchData promises) from tree
// This will traverse down recursively looking for fetchD... | javascript | function getDataFromTree(rootElement, rootContext, fetchRoot, mergeProps, isTopLevel){
//console.log(`Now searching element (${rootElement.type.name || rootElement.type.displayName}):`, rootElement);
// Get array of queries (fetchData promises) from tree
// This will traverse down recursively looking for fetchD... | [
"function",
"getDataFromTree",
"(",
"rootElement",
",",
"rootContext",
",",
"fetchRoot",
",",
"mergeProps",
",",
"isTopLevel",
")",
"{",
"//console.log(`Now searching element (${rootElement.type.name || rootElement.type.displayName}):`, rootElement);",
"// Get array of queries (fetchDa... | XXX component Cache | [
"XXX",
"component",
"Cache"
] | 788397f133e4d327e074689f17b3f8e47abdaf2e | https://github.com/gragland/react-component-data/blob/788397f133e4d327e074689f17b3f8e47abdaf2e/src/resolveRecursive.js#L130-L169 |
45,837 | rksm/estree-to-js | bin/estree-to-js.js | jsonSpec | function jsonSpec() {
return parsedArgs.specFile ?
read(parsedArgs.specFile).then(JSON.parse) :
require("../index").fetch(parsedArgs.urls)
.then(mdSource => require("../index").parse(mdSource))
} | javascript | function jsonSpec() {
return parsedArgs.specFile ?
read(parsedArgs.specFile).then(JSON.parse) :
require("../index").fetch(parsedArgs.urls)
.then(mdSource => require("../index").parse(mdSource))
} | [
"function",
"jsonSpec",
"(",
")",
"{",
"return",
"parsedArgs",
".",
"specFile",
"?",
"read",
"(",
"parsedArgs",
".",
"specFile",
")",
".",
"then",
"(",
"JSON",
".",
"parse",
")",
":",
"require",
"(",
"\"../index\"",
")",
".",
"fetch",
"(",
"parsedArgs",
... | -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- helpers | [
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"=",
"-",
"... | 3cb21c9c63ff329651f08197d353965e80551bd2 | https://github.com/rksm/estree-to-js/blob/3cb21c9c63ff329651f08197d353965e80551bd2/bin/estree-to-js.js#L53-L58 |
45,838 | cettia/cettia-protocol | lib/transport-websocket-server.js | createWebSocketTransport | function createWebSocketTransport(ws) {
// A transport object.
var self = new events.EventEmitter();
// Transport URI contains information like protocol header as query.
self.uri = ws.upgradeReq.url;
// Simply delegates WebSocket's events to transport and transport's behaviors to WebSocket.
ws.onmessage = f... | javascript | function createWebSocketTransport(ws) {
// A transport object.
var self = new events.EventEmitter();
// Transport URI contains information like protocol header as query.
self.uri = ws.upgradeReq.url;
// Simply delegates WebSocket's events to transport and transport's behaviors to WebSocket.
ws.onmessage = f... | [
"function",
"createWebSocketTransport",
"(",
"ws",
")",
"{",
"// A transport object.",
"var",
"self",
"=",
"new",
"events",
".",
"EventEmitter",
"(",
")",
";",
"// Transport URI contains information like protocol header as query.",
"self",
".",
"uri",
"=",
"ws",
".",
... | WebSocket is a protocol designed for a full-duplex communications over a TCP connection. | [
"WebSocket",
"is",
"a",
"protocol",
"designed",
"for",
"a",
"full",
"-",
"duplex",
"communications",
"over",
"a",
"TCP",
"connection",
"."
] | 9af3b578a9ae7b33099932903b52faeb2ca92528 | https://github.com/cettia/cettia-protocol/blob/9af3b578a9ae7b33099932903b52faeb2ca92528/lib/transport-websocket-server.js#L30-L69 |
45,839 | flightjs/flight-with-state | src/index.js | cloneStateDef | function cloneStateDef(stateDef) {
stateDef = (stateDef || {});
return function () {
var ctx = this;
return Object.keys(stateDef).reduce((state, k) => {
var value = stateDef[k];
state[k] = (typeof value === 'function' ? value.call(ctx) : value);
return state;
... | javascript | function cloneStateDef(stateDef) {
stateDef = (stateDef || {});
return function () {
var ctx = this;
return Object.keys(stateDef).reduce((state, k) => {
var value = stateDef[k];
state[k] = (typeof value === 'function' ? value.call(ctx) : value);
return state;
... | [
"function",
"cloneStateDef",
"(",
"stateDef",
")",
"{",
"stateDef",
"=",
"(",
"stateDef",
"||",
"{",
"}",
")",
";",
"return",
"function",
"(",
")",
"{",
"var",
"ctx",
"=",
"this",
";",
"return",
"Object",
".",
"keys",
"(",
"stateDef",
")",
".",
"redu... | Returns a function that returns a clone of the object passed to it initially | [
"Returns",
"a",
"function",
"that",
"returns",
"a",
"clone",
"of",
"the",
"object",
"passed",
"to",
"it",
"initially"
] | 3ccf726bdeff9778aabb04adab351eff3f852f46 | https://github.com/flightjs/flight-with-state/blob/3ccf726bdeff9778aabb04adab351eff3f852f46/src/index.js#L8-L18 |
45,840 | aholstenson/amounts | lib/quantity.js | createUnits | function createUnits(conversions, withNames=false) {
const result = {};
conversions.forEach(c => c.names.forEach(name =>
result[unitToLower(normalizeUnitName(name))] = {
name: c.names[0],
prefix: c.prefix,
scale: c.scale,
toBase: c.toBase,
fr... | javascript | function createUnits(conversions, withNames=false) {
const result = {};
conversions.forEach(c => c.names.forEach(name =>
result[unitToLower(normalizeUnitName(name))] = {
name: c.names[0],
prefix: c.prefix,
scale: c.scale,
toBase: c.toBase,
fr... | [
"function",
"createUnits",
"(",
"conversions",
",",
"withNames",
"=",
"false",
")",
"{",
"const",
"result",
"=",
"{",
"}",
";",
"conversions",
".",
"forEach",
"(",
"c",
"=>",
"c",
".",
"names",
".",
"forEach",
"(",
"name",
"=>",
"result",
"[",
"unitToL... | Map a list of conversions into an object where each name is represented
as a key. | [
"Map",
"a",
"list",
"of",
"conversions",
"into",
"an",
"object",
"where",
"each",
"name",
"is",
"represented",
"as",
"a",
"key",
"."
] | 04fdc68b782918eeaeae62bfcdcb0f20f7afb527 | https://github.com/aholstenson/amounts/blob/04fdc68b782918eeaeae62bfcdcb0f20f7afb527/lib/quantity.js#L113-L129 |
45,841 | aholstenson/amounts | lib/quantity.js | createUnitRegex | function createUnitRegex(units) {
return Object.keys(units)
.sort((a, b) => b.length - a.length)
.map(unit => unit.length > 2 ? caseInsensitivePart(unit) : unit)
.join('|');
} | javascript | function createUnitRegex(units) {
return Object.keys(units)
.sort((a, b) => b.length - a.length)
.map(unit => unit.length > 2 ? caseInsensitivePart(unit) : unit)
.join('|');
} | [
"function",
"createUnitRegex",
"(",
"units",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"units",
")",
".",
"sort",
"(",
"(",
"a",
",",
"b",
")",
"=>",
"b",
".",
"length",
"-",
"a",
".",
"length",
")",
".",
"map",
"(",
"unit",
"=>",
"unit",
... | Create a regex for the given associative object. | [
"Create",
"a",
"regex",
"for",
"the",
"given",
"associative",
"object",
"."
] | 04fdc68b782918eeaeae62bfcdcb0f20f7afb527 | https://github.com/aholstenson/amounts/blob/04fdc68b782918eeaeae62bfcdcb0f20f7afb527/lib/quantity.js#L154-L159 |
45,842 | EspressoLogicCafe/APICreatorSDK | APICreatorSDK.js | function (url, key, password) {
var deferred, options, headers, liveapicreator;
liveapicreator = _.extend({}, SDK);
liveapicreator.url = this.stripWrappingSlashes(url);
liveapicreator.params = _.pick(URL.parse(url), 'host', 'path', 'port');
liveapicreator.params.headers = {};
if (url.match('https')) ... | javascript | function (url, key, password) {
var deferred, options, headers, liveapicreator;
liveapicreator = _.extend({}, SDK);
liveapicreator.url = this.stripWrappingSlashes(url);
liveapicreator.params = _.pick(URL.parse(url), 'host', 'path', 'port');
liveapicreator.params.headers = {};
if (url.match('https')) ... | [
"function",
"(",
"url",
",",
"key",
",",
"password",
")",
"{",
"var",
"deferred",
",",
"options",
",",
"headers",
",",
"liveapicreator",
";",
"liveapicreator",
"=",
"_",
".",
"extend",
"(",
"{",
"}",
",",
"SDK",
")",
";",
"liveapicreator",
".",
"url",
... | The default method of connecting to an API. Returns an instance of this library
and initializes a promise used to make requests on API endpoints.
@param string url the API url base e.g. http://localhost:8080/rest/default/demo/v1
@param string key an API key, typically found in Logic Designer's Security section.
When c... | [
"The",
"default",
"method",
"of",
"connecting",
"to",
"an",
"API",
".",
"Returns",
"an",
"instance",
"of",
"this",
"library",
"and",
"initializes",
"a",
"promise",
"used",
"to",
"make",
"requests",
"on",
"API",
"endpoints",
"."
] | ada0acf7c9e91807bcb781ba233282915ed13770 | https://github.com/EspressoLogicCafe/APICreatorSDK/blob/ada0acf7c9e91807bcb781ba233282915ed13770/APICreatorSDK.js#L102-L149 | |
45,843 | EspressoLogicCafe/APICreatorSDK | APICreatorSDK.js | function (options, headers) {
if (!headers) { headers = {}; }
if (options.headers) {
var headers = options.headers;
headers = _.extend(headers, this.headers, headers);
}
return options;
} | javascript | function (options, headers) {
if (!headers) { headers = {}; }
if (options.headers) {
var headers = options.headers;
headers = _.extend(headers, this.headers, headers);
}
return options;
} | [
"function",
"(",
"options",
",",
"headers",
")",
"{",
"if",
"(",
"!",
"headers",
")",
"{",
"headers",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"options",
".",
"headers",
")",
"{",
"var",
"headers",
"=",
"options",
".",
"headers",
";",
"headers",
"=",
... | Internal method for merging liveapicreatorsdk.headers attributes with those passed in via headers.
@param object options a collection of URL.parse(url) attributes, which may or may not contain options.headers
@param object headers a collection of header attributes to be appended to the request | [
"Internal",
"method",
"for",
"merging",
"liveapicreatorsdk",
".",
"headers",
"attributes",
"with",
"those",
"passed",
"in",
"via",
"headers",
"."
] | ada0acf7c9e91807bcb781ba233282915ed13770 | https://github.com/EspressoLogicCafe/APICreatorSDK/blob/ada0acf7c9e91807bcb781ba233282915ed13770/APICreatorSDK.js#L173-L180 | |
45,844 | stehefan/postcss-env-replace | index.js | verifyParameters | function verifyParameters(replacements, value, decl, environment) {
if (undefined === replacements[value]) {
throw decl.error(
'Unknown variable ' + value,
{ plugin: plugin.name }
);
}
if (undefined === replacements[value][environment]) {
throw decl.error(
... | javascript | function verifyParameters(replacements, value, decl, environment) {
if (undefined === replacements[value]) {
throw decl.error(
'Unknown variable ' + value,
{ plugin: plugin.name }
);
}
if (undefined === replacements[value][environment]) {
throw decl.error(
... | [
"function",
"verifyParameters",
"(",
"replacements",
",",
"value",
",",
"decl",
",",
"environment",
")",
"{",
"if",
"(",
"undefined",
"===",
"replacements",
"[",
"value",
"]",
")",
"{",
"throw",
"decl",
".",
"error",
"(",
"'Unknown variable '",
"+",
"value",... | Verifies the found options and checks whether they are configured or not
@param {Object} replacements - Object containing replacement information
per environment
@param {String} value - String found inside the declaration that should
be replaced
@param {Declaration} decl - Declaration currently examined
@param {String... | [
"Verifies",
"the",
"found",
"options",
"and",
"checks",
"whether",
"they",
"are",
"configured",
"or",
"not"
] | f6f879dbcc2cb7268f16d9e2bc6a931f609ead13 | https://github.com/stehefan/postcss-env-replace/blob/f6f879dbcc2cb7268f16d9e2bc6a931f609ead13/index.js#L19-L34 |
45,845 | stehefan/postcss-env-replace | index.js | walkDeclaration | function walkDeclaration(decl, environment, replacements) {
decl.value = decl.value.replace(functionRegex, function (match, value) {
verifyParameters(replacements, value, decl, environment);
return replacements[value][environment];
});
} | javascript | function walkDeclaration(decl, environment, replacements) {
decl.value = decl.value.replace(functionRegex, function (match, value) {
verifyParameters(replacements, value, decl, environment);
return replacements[value][environment];
});
} | [
"function",
"walkDeclaration",
"(",
"decl",
",",
"environment",
",",
"replacements",
")",
"{",
"decl",
".",
"value",
"=",
"decl",
".",
"value",
".",
"replace",
"(",
"functionRegex",
",",
"function",
"(",
"match",
",",
"value",
")",
"{",
"verifyParameters",
... | Parses one CSS-declaration from the given AST and checks for
possible replacements
@param {Declaration} decl - one CSS-Declaration from the AST
@param {String} environment - current environment
@param {String} replacements - Object containing all replacements that we
have inside the options | [
"Parses",
"one",
"CSS",
"-",
"declaration",
"from",
"the",
"given",
"AST",
"and",
"checks",
"for",
"possible",
"replacements"
] | f6f879dbcc2cb7268f16d9e2bc6a931f609ead13 | https://github.com/stehefan/postcss-env-replace/blob/f6f879dbcc2cb7268f16d9e2bc6a931f609ead13/index.js#L45-L51 |
45,846 | silas/node-mesos | lib/chronos.js | Chronos | function Chronos(opts) {
if (!(this instanceof Chronos)) {
return new Chronos(opts);
}
opts = opts || {};
if (!opts.baseUrl) {
opts.baseUrl = (opts.secure ? 'https:' : 'http:') + '//' +
(opts.host || '127.0.0.1') + ':' +
(opts.port || '4400') + '/scheduler';
}
opts.name = 'chronos';
... | javascript | function Chronos(opts) {
if (!(this instanceof Chronos)) {
return new Chronos(opts);
}
opts = opts || {};
if (!opts.baseUrl) {
opts.baseUrl = (opts.secure ? 'https:' : 'http:') + '//' +
(opts.host || '127.0.0.1') + ':' +
(opts.port || '4400') + '/scheduler';
}
opts.name = 'chronos';
... | [
"function",
"Chronos",
"(",
"opts",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Chronos",
")",
")",
"{",
"return",
"new",
"Chronos",
"(",
"opts",
")",
";",
"}",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"opts",
".",
"b... | Initialize a new `Chronos` client.
@param {Object} opts | [
"Initialize",
"a",
"new",
"Chronos",
"client",
"."
] | 157ca9fa9cfeb13def49cf8f6ef53ff7e708da95 | https://github.com/silas/node-mesos/blob/157ca9fa9cfeb13def49cf8f6ef53ff7e708da95/lib/chronos.js#L23-L42 |
45,847 | Kong/galileo-agent-node | lib/helpers.js | function (testOverride) {
var ret = '127.0.0.1'
os = testOverride || os
var interfaces = os.networkInterfaces()
Object.keys(interfaces).forEach(function (el) {
interfaces[el].forEach(function (el2) {
if (!el2.internal && el2.family === 'IPv4') {
ret = el2.address
}
... | javascript | function (testOverride) {
var ret = '127.0.0.1'
os = testOverride || os
var interfaces = os.networkInterfaces()
Object.keys(interfaces).forEach(function (el) {
interfaces[el].forEach(function (el2) {
if (!el2.internal && el2.family === 'IPv4') {
ret = el2.address
}
... | [
"function",
"(",
"testOverride",
")",
"{",
"var",
"ret",
"=",
"'127.0.0.1'",
"os",
"=",
"testOverride",
"||",
"os",
"var",
"interfaces",
"=",
"os",
".",
"networkInterfaces",
"(",
")",
"Object",
".",
"keys",
"(",
"interfaces",
")",
".",
"forEach",
"(",
"f... | get server address from network interface | [
"get",
"server",
"address",
"from",
"network",
"interface"
] | 651626bbf82c66e0b1786992a7fd7e18845f076b | https://github.com/Kong/galileo-agent-node/blob/651626bbf82c66e0b1786992a7fd7e18845f076b/lib/helpers.js#L20-L34 | |
45,848 | Kong/galileo-agent-node | lib/helpers.js | function (string) {
if (!string || string === '' || string.indexOf('\r\n') === -1) {
return {
version: 'HTTP/1.1',
statusText: ''
}
}
var lines = string.split('\r\n')
var status = lines.shift()
// Remove empty strings
lines = lines.filter(Boolean)
// Parse stat... | javascript | function (string) {
if (!string || string === '' || string.indexOf('\r\n') === -1) {
return {
version: 'HTTP/1.1',
statusText: ''
}
}
var lines = string.split('\r\n')
var status = lines.shift()
// Remove empty strings
lines = lines.filter(Boolean)
// Parse stat... | [
"function",
"(",
"string",
")",
"{",
"if",
"(",
"!",
"string",
"||",
"string",
"===",
"''",
"||",
"string",
".",
"indexOf",
"(",
"'\\r\\n'",
")",
"===",
"-",
"1",
")",
"{",
"return",
"{",
"version",
":",
"'HTTP/1.1'",
",",
"statusText",
":",
"''",
... | convert header string to assoc array | [
"convert",
"header",
"string",
"to",
"assoc",
"array"
] | 651626bbf82c66e0b1786992a7fd7e18845f076b | https://github.com/Kong/galileo-agent-node/blob/651626bbf82c66e0b1786992a7fd7e18845f076b/lib/helpers.js#L61-L92 | |
45,849 | Kong/galileo-agent-node | lib/helpers.js | function (line) {
var pieces = line.split(' ')
// Header string pieces
var output = {
version: pieces.shift(),
status: parseFloat(pieces.shift()),
statusText: pieces.join(' ')
}
return output
} | javascript | function (line) {
var pieces = line.split(' ')
// Header string pieces
var output = {
version: pieces.shift(),
status: parseFloat(pieces.shift()),
statusText: pieces.join(' ')
}
return output
} | [
"function",
"(",
"line",
")",
"{",
"var",
"pieces",
"=",
"line",
".",
"split",
"(",
"' '",
")",
"// Header string pieces",
"var",
"output",
"=",
"{",
"version",
":",
"pieces",
".",
"shift",
"(",
")",
",",
"status",
":",
"parseFloat",
"(",
"pieces",
"."... | parse status line into an object | [
"parse",
"status",
"line",
"into",
"an",
"object"
] | 651626bbf82c66e0b1786992a7fd7e18845f076b | https://github.com/Kong/galileo-agent-node/blob/651626bbf82c66e0b1786992a7fd7e18845f076b/lib/helpers.js#L97-L108 | |
45,850 | Kong/galileo-agent-node | lib/helpers.js | function (obj) {
// sanity check
if (!obj || typeof obj !== 'object') {
return []
}
var results = []
Object.keys(obj).forEach(function (name) {
// nested values in query string
if (typeof obj[name] === 'object') {
obj[name].forEach(function (value) {
results.pus... | javascript | function (obj) {
// sanity check
if (!obj || typeof obj !== 'object') {
return []
}
var results = []
Object.keys(obj).forEach(function (name) {
// nested values in query string
if (typeof obj[name] === 'object') {
obj[name].forEach(function (value) {
results.pus... | [
"function",
"(",
"obj",
")",
"{",
"// sanity check",
"if",
"(",
"!",
"obj",
"||",
"typeof",
"obj",
"!==",
"'object'",
")",
"{",
"return",
"[",
"]",
"}",
"var",
"results",
"=",
"[",
"]",
"Object",
".",
"keys",
"(",
"obj",
")",
".",
"forEach",
"(",
... | Transform objects into an array of key value pairs. | [
"Transform",
"objects",
"into",
"an",
"array",
"of",
"key",
"value",
"pairs",
"."
] | 651626bbf82c66e0b1786992a7fd7e18845f076b | https://github.com/Kong/galileo-agent-node/blob/651626bbf82c66e0b1786992a7fd7e18845f076b/lib/helpers.js#L127-L154 | |
45,851 | Kong/galileo-agent-node | lib/helpers.js | function (headers, key, def) {
if (headers instanceof Array) {
var regex = new RegExp(key, 'i')
for (var i = 0; i < headers.length; i++) {
if (regex.test(headers[i].name)) {
return headers[i].value
}
}
}
return def !== undefined ? def : false
} | javascript | function (headers, key, def) {
if (headers instanceof Array) {
var regex = new RegExp(key, 'i')
for (var i = 0; i < headers.length; i++) {
if (regex.test(headers[i].name)) {
return headers[i].value
}
}
}
return def !== undefined ? def : false
} | [
"function",
"(",
"headers",
",",
"key",
",",
"def",
")",
"{",
"if",
"(",
"headers",
"instanceof",
"Array",
")",
"{",
"var",
"regex",
"=",
"new",
"RegExp",
"(",
"key",
",",
"'i'",
")",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"headers",
... | uses regex to match a header value | [
"uses",
"regex",
"to",
"match",
"a",
"header",
"value"
] | 651626bbf82c66e0b1786992a7fd7e18845f076b | https://github.com/Kong/galileo-agent-node/blob/651626bbf82c66e0b1786992a7fd7e18845f076b/lib/helpers.js#L159-L170 | |
45,852 | Kong/galileo-agent-node | lib/helpers.js | function (req) {
var keys = Object.keys(req.headers)
var values = keys.map(function (key) {
return req.headers[key]
})
var headers = req.method + req.url + keys.join() + values.join()
// startline: [method] [url] HTTP/1.1\r\n = 12
// endline: \r\n = 2
// every header + \r\n = * 2
... | javascript | function (req) {
var keys = Object.keys(req.headers)
var values = keys.map(function (key) {
return req.headers[key]
})
var headers = req.method + req.url + keys.join() + values.join()
// startline: [method] [url] HTTP/1.1\r\n = 12
// endline: \r\n = 2
// every header + \r\n = * 2
... | [
"function",
"(",
"req",
")",
"{",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"req",
".",
"headers",
")",
"var",
"values",
"=",
"keys",
".",
"map",
"(",
"function",
"(",
"key",
")",
"{",
"return",
"req",
".",
"headers",
"[",
"key",
"]",
"}",
... | quickly calculates the header size in bytes for a given array of headers | [
"quickly",
"calculates",
"the",
"header",
"size",
"in",
"bytes",
"for",
"a",
"given",
"array",
"of",
"headers"
] | 651626bbf82c66e0b1786992a7fd7e18845f076b | https://github.com/Kong/galileo-agent-node/blob/651626bbf82c66e0b1786992a7fd7e18845f076b/lib/helpers.js#L175-L189 | |
45,853 | rakuten-frontend/generator-rff | generators/app/index.js | function () {
var done = this.async();
var questions = [];
var choices = [
{
name: 'Standard Preset',
value: 'standard'
},
{
name: 'Minimum Preset',
value: 'minimum'
},
{
name: 'Custom Configuration (Advanced)',
... | javascript | function () {
var done = this.async();
var questions = [];
var choices = [
{
name: 'Standard Preset',
value: 'standard'
},
{
name: 'Minimum Preset',
value: 'minimum'
},
{
name: 'Custom Configuration (Advanced)',
... | [
"function",
"(",
")",
"{",
"var",
"done",
"=",
"this",
".",
"async",
"(",
")",
";",
"var",
"questions",
"=",
"[",
"]",
";",
"var",
"choices",
"=",
"[",
"{",
"name",
":",
"'Standard Preset'",
",",
"value",
":",
"'standard'",
"}",
",",
"{",
"name",
... | Setup prompting type | [
"Setup",
"prompting",
"type"
] | f0621e5b2a042036599d2126701af6a2f59e563f | https://github.com/rakuten-frontend/generator-rff/blob/f0621e5b2a042036599d2126701af6a2f59e563f/generators/app/index.js#L43-L109 | |
45,854 | rakuten-frontend/generator-rff | generators/app/index.js | function () {
this.cfg = {};
// Copy from prompt settings
Object.keys(this.settings).forEach(function (key) {
this.cfg[key] = this.settings[key];
}.bind(this));
// Boolean config
options.forEach(function (option) {
var name = option.name;
option.choices.forE... | javascript | function () {
this.cfg = {};
// Copy from prompt settings
Object.keys(this.settings).forEach(function (key) {
this.cfg[key] = this.settings[key];
}.bind(this));
// Boolean config
options.forEach(function (option) {
var name = option.name;
option.choices.forE... | [
"function",
"(",
")",
"{",
"this",
".",
"cfg",
"=",
"{",
"}",
";",
"// Copy from prompt settings",
"Object",
".",
"keys",
"(",
"this",
".",
"settings",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"this",
".",
"cfg",
"[",
"key",
"]",
... | Config for template generator | [
"Config",
"for",
"template",
"generator"
] | f0621e5b2a042036599d2126701af6a2f59e563f | https://github.com/rakuten-frontend/generator-rff/blob/f0621e5b2a042036599d2126701af6a2f59e563f/generators/app/index.js#L187-L218 | |
45,855 | tradle/simple-wallet | index.js | Wallet | function Wallet (options) {
this.priv = typeof options.priv === 'string' ?
bitcoin.ECKey.fromWIF(options.priv) :
options.priv
typeforce(typeforce.Object, this.priv)
typeforce({
blockchain: typeforce.Object,
networkName: typeforce.String
}, options)
assert(options.networkName in bitcoin.netwo... | javascript | function Wallet (options) {
this.priv = typeof options.priv === 'string' ?
bitcoin.ECKey.fromWIF(options.priv) :
options.priv
typeforce(typeforce.Object, this.priv)
typeforce({
blockchain: typeforce.Object,
networkName: typeforce.String
}, options)
assert(options.networkName in bitcoin.netwo... | [
"function",
"Wallet",
"(",
"options",
")",
"{",
"this",
".",
"priv",
"=",
"typeof",
"options",
".",
"priv",
"===",
"'string'",
"?",
"bitcoin",
".",
"ECKey",
".",
"fromWIF",
"(",
"options",
".",
"priv",
")",
":",
"options",
".",
"priv",
"typeforce",
"("... | primitive one key common blockchain wallet
@param {Object} options
@param {String|ECKey} options.priv
@param {CommonBlockchain impl} options.blockchain common-blockchain api | [
"primitive",
"one",
"key",
"common",
"blockchain",
"wallet"
] | de0c8d5d932aab08c93688b6565a25c793ee9915 | https://github.com/tradle/simple-wallet/blob/de0c8d5d932aab08c93688b6565a25c793ee9915/index.js#L18-L37 |
45,856 | gcanti/flowcheck | visitors.js | visitTypedVariableDeclarator | function visitTypedVariableDeclarator(traverse, node, path, state) {
var ctx = new Context(state);
if (node.init) {
utils.catchup(node.init.range[0], state);
utils.append(ctx.getProperty('check') + '(', state);
traverse(node.init, path, state);
utils.catchup(node.init.range[1], state);
utils.app... | javascript | function visitTypedVariableDeclarator(traverse, node, path, state) {
var ctx = new Context(state);
if (node.init) {
utils.catchup(node.init.range[0], state);
utils.append(ctx.getProperty('check') + '(', state);
traverse(node.init, path, state);
utils.catchup(node.init.range[1], state);
utils.app... | [
"function",
"visitTypedVariableDeclarator",
"(",
"traverse",
",",
"node",
",",
"path",
",",
"state",
")",
"{",
"var",
"ctx",
"=",
"new",
"Context",
"(",
"state",
")",
";",
"if",
"(",
"node",
".",
"init",
")",
"{",
"utils",
".",
"catchup",
"(",
"node",
... | handle variable declarations | [
"handle",
"variable",
"declarations"
] | 7c29f7ebdd962b4cc3b26771a1b3c1319b5137c5 | https://github.com/gcanti/flowcheck/blob/7c29f7ebdd962b4cc3b26771a1b3c1319b5137c5/visitors.js#L171-L182 |
45,857 | gcanti/flowcheck | visitors.js | visitTypedFunction | function visitTypedFunction(traverse, node, path, state) {
var klass = getParentClassDeclaration(path);
var generics = klass && klass.typeParameters ? toLookup(klass.typeParameters.params.map(getName)) : {};
if (node.typeParameters) {
generics = mixin(generics, toLookup(node.typeParameters.params.map(getName)... | javascript | function visitTypedFunction(traverse, node, path, state) {
var klass = getParentClassDeclaration(path);
var generics = klass && klass.typeParameters ? toLookup(klass.typeParameters.params.map(getName)) : {};
if (node.typeParameters) {
generics = mixin(generics, toLookup(node.typeParameters.params.map(getName)... | [
"function",
"visitTypedFunction",
"(",
"traverse",
",",
"node",
",",
"path",
",",
"state",
")",
"{",
"var",
"klass",
"=",
"getParentClassDeclaration",
"(",
"path",
")",
";",
"var",
"generics",
"=",
"klass",
"&&",
"klass",
".",
"typeParameters",
"?",
"toLooku... | handle typed functions a typed function is a function such that at least one param or the return value is typed | [
"handle",
"typed",
"functions",
"a",
"typed",
"function",
"is",
"a",
"function",
"such",
"that",
"at",
"least",
"one",
"param",
"or",
"the",
"return",
"value",
"is",
"typed"
] | 7c29f7ebdd962b4cc3b26771a1b3c1319b5137c5 | https://github.com/gcanti/flowcheck/blob/7c29f7ebdd962b4cc3b26771a1b3c1319b5137c5/visitors.js#L193-L226 |
45,858 | gcanti/flowcheck | visitors.js | visitTypeAlias | function visitTypeAlias(traverse, node, path, state) {
var ctx = new Context(state);
utils.catchup(node.range[1], state);
utils.append('var ' + node.id.name + ' = ' + ctx.getType(node.right) + ';', state);
return false;
} | javascript | function visitTypeAlias(traverse, node, path, state) {
var ctx = new Context(state);
utils.catchup(node.range[1], state);
utils.append('var ' + node.id.name + ' = ' + ctx.getType(node.right) + ';', state);
return false;
} | [
"function",
"visitTypeAlias",
"(",
"traverse",
",",
"node",
",",
"path",
",",
"state",
")",
"{",
"var",
"ctx",
"=",
"new",
"Context",
"(",
"state",
")",
";",
"utils",
".",
"catchup",
"(",
"node",
".",
"range",
"[",
"1",
"]",
",",
"state",
")",
";",... | handle type aliases | [
"handle",
"type",
"aliases"
] | 7c29f7ebdd962b4cc3b26771a1b3c1319b5137c5 | https://github.com/gcanti/flowcheck/blob/7c29f7ebdd962b4cc3b26771a1b3c1319b5137c5/visitors.js#L240-L245 |
45,859 | tomaszczechowski/jsbeautify-loader | index.js | function (type) {
var handlers = { 'html': beautify.html, 'css': beautify.css, 'js': beautify.js };
if (type === undefined) {
return beautify;
}
if (type in handlers) {
return handlers[type];
}
throw new Error('Unrecognized beautifier type:', type);
} | javascript | function (type) {
var handlers = { 'html': beautify.html, 'css': beautify.css, 'js': beautify.js };
if (type === undefined) {
return beautify;
}
if (type in handlers) {
return handlers[type];
}
throw new Error('Unrecognized beautifier type:', type);
} | [
"function",
"(",
"type",
")",
"{",
"var",
"handlers",
"=",
"{",
"'html'",
":",
"beautify",
".",
"html",
",",
"'css'",
":",
"beautify",
".",
"css",
",",
"'js'",
":",
"beautify",
".",
"js",
"}",
";",
"if",
"(",
"type",
"===",
"undefined",
")",
"{",
... | Method returns beautify handler for specific type of file.
@param {String} type - type of file e.g. html or js.
@return {Object} - beautify object. | [
"Method",
"returns",
"beautify",
"handler",
"for",
"specific",
"type",
"of",
"file",
"."
] | a896ee6c348d779c27694e3225cf5355f88b2e74 | https://github.com/tomaszczechowski/jsbeautify-loader/blob/a896ee6c348d779c27694e3225cf5355f88b2e74/index.js#L25-L37 | |
45,860 | tomaszczechowski/jsbeautify-loader | index.js | function (options, fileExtension) {
var getOptionsKey = function (options, fileExtension) {
for (var prop in options) {
var _prop = prop.toLowerCase();
if ((options[_prop].hasOwnProperty('allowed_file_extensions') && options[_prop].allowed_file_extensions.indexOf(fileExtension) > -1) || (!options[_pr... | javascript | function (options, fileExtension) {
var getOptionsKey = function (options, fileExtension) {
for (var prop in options) {
var _prop = prop.toLowerCase();
if ((options[_prop].hasOwnProperty('allowed_file_extensions') && options[_prop].allowed_file_extensions.indexOf(fileExtension) > -1) || (!options[_pr... | [
"function",
"(",
"options",
",",
"fileExtension",
")",
"{",
"var",
"getOptionsKey",
"=",
"function",
"(",
"options",
",",
"fileExtension",
")",
"{",
"for",
"(",
"var",
"prop",
"in",
"options",
")",
"{",
"var",
"_prop",
"=",
"prop",
".",
"toLowerCase",
"(... | Method checks whether file's extension has corresponded configuration object.
@param {Object} options - configuration object.
@param {String} fileExtension - file's extension.
@return {String|Object} - object key or null. | [
"Method",
"checks",
"whether",
"file",
"s",
"extension",
"has",
"corresponded",
"configuration",
"object",
"."
] | a896ee6c348d779c27694e3225cf5355f88b2e74 | https://github.com/tomaszczechowski/jsbeautify-loader/blob/a896ee6c348d779c27694e3225cf5355f88b2e74/index.js#L73-L92 | |
45,861 | tomaszczechowski/jsbeautify-loader | index.js | function (source, fileExtension, globalOptions, beautify) {
var path = rcFile.for(this.resourcePath)
, options = globalOptions || {};
if (globalOptions === null && typeof path === "string") {
this.addDependency(path);
options = JSON.parse(stripJsonComments(fs.readFileSync(path, "utf8")));
}
return... | javascript | function (source, fileExtension, globalOptions, beautify) {
var path = rcFile.for(this.resourcePath)
, options = globalOptions || {};
if (globalOptions === null && typeof path === "string") {
this.addDependency(path);
options = JSON.parse(stripJsonComments(fs.readFileSync(path, "utf8")));
}
return... | [
"function",
"(",
"source",
",",
"fileExtension",
",",
"globalOptions",
",",
"beautify",
")",
"{",
"var",
"path",
"=",
"rcFile",
".",
"for",
"(",
"this",
".",
"resourcePath",
")",
",",
"options",
"=",
"globalOptions",
"||",
"{",
"}",
";",
"if",
"(",
"gl... | Method parses file synchronously
@param {String} source - file's content.
@param {String} fileExtension - file's extension.
@param {Object} globalOptions - configuration from weback file.
@return {String} - parsed content of file. | [
"Method",
"parses",
"file",
"synchronously"
] | a896ee6c348d779c27694e3225cf5355f88b2e74 | https://github.com/tomaszczechowski/jsbeautify-loader/blob/a896ee6c348d779c27694e3225cf5355f88b2e74/index.js#L101-L111 | |
45,862 | tomaszczechowski/jsbeautify-loader | index.js | function (source, fileExtension, globalOptions, beautify, callback) {
var _this = this;
if (globalOptions === null) {
rcFile.for(this.resourcePath, function (err, path) {
if (!err) {
if (typeof path === "string") {
_this.addDependency(path);
fs.readFile(path, "utf8", function... | javascript | function (source, fileExtension, globalOptions, beautify, callback) {
var _this = this;
if (globalOptions === null) {
rcFile.for(this.resourcePath, function (err, path) {
if (!err) {
if (typeof path === "string") {
_this.addDependency(path);
fs.readFile(path, "utf8", function... | [
"function",
"(",
"source",
",",
"fileExtension",
",",
"globalOptions",
",",
"beautify",
",",
"callback",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"if",
"(",
"globalOptions",
"===",
"null",
")",
"{",
"rcFile",
".",
"for",
"(",
"this",
".",
"resourcePat... | Method parses file asynchronously
@param {String} source - file's content.
@param {String} fileExtension - file's extension.
@param {Object} globalOptions - configuration from weback file.
@param {Function} callback - callback function with processed file content or with error message. | [
"Method",
"parses",
"file",
"asynchronously"
] | a896ee6c348d779c27694e3225cf5355f88b2e74 | https://github.com/tomaszczechowski/jsbeautify-loader/blob/a896ee6c348d779c27694e3225cf5355f88b2e74/index.js#L120-L147 | |
45,863 | joelabair/Bracket-Templates | index.js | _extract | function _extract(keyStr, dataObj) {
var altkey,
_subKey,
_splitPoint,
_found = false,
dataValue = null,
_queryParts = [];
if (dataObj && typeof dataObj === 'object') {
dataValue = Object.create(dataObj);
_queryParts = keyStr.split(/[\-\_\.]/);
//console.warn("INIT:", keyStr, _queryParts);
// tes... | javascript | function _extract(keyStr, dataObj) {
var altkey,
_subKey,
_splitPoint,
_found = false,
dataValue = null,
_queryParts = [];
if (dataObj && typeof dataObj === 'object') {
dataValue = Object.create(dataObj);
_queryParts = keyStr.split(/[\-\_\.]/);
//console.warn("INIT:", keyStr, _queryParts);
// tes... | [
"function",
"_extract",
"(",
"keyStr",
",",
"dataObj",
")",
"{",
"var",
"altkey",
",",
"_subKey",
",",
"_splitPoint",
",",
"_found",
"=",
"false",
",",
"dataValue",
"=",
"null",
",",
"_queryParts",
"=",
"[",
"]",
";",
"if",
"(",
"dataObj",
"&&",
"typeo... | key notation value extraction
@param {String} keyStr The key string, including sub-key notation (i.e. this.prop.key or thing-prop).
@param {Object} dataObj The data object an array or object.
@returns {Mixed} | [
"key",
"notation",
"value",
"extraction"
] | 6a2025b900e1dde68bf20820c3dec7c48bf98c7d | https://github.com/joelabair/Bracket-Templates/blob/6a2025b900e1dde68bf20820c3dec7c48bf98c7d/index.js#L50-L96 |
45,864 | joelabair/Bracket-Templates | index.js | renderData | function renderData(textString, options, data, doSpecials) {
var replacer = function replacer(match, $1, $2) {
var extracted,
dataValue,
key = String($1 || '').trim(),
defaultValue = String($2 || '').trim();
// literal bracket excaping via \[ text ]
if(match.substr(0, 1) === "\\") {
return match.su... | javascript | function renderData(textString, options, data, doSpecials) {
var replacer = function replacer(match, $1, $2) {
var extracted,
dataValue,
key = String($1 || '').trim(),
defaultValue = String($2 || '').trim();
// literal bracket excaping via \[ text ]
if(match.substr(0, 1) === "\\") {
return match.su... | [
"function",
"renderData",
"(",
"textString",
",",
"options",
",",
"data",
",",
"doSpecials",
")",
"{",
"var",
"replacer",
"=",
"function",
"replacer",
"(",
"match",
",",
"$1",
",",
"$2",
")",
"{",
"var",
"extracted",
",",
"dataValue",
",",
"key",
"=",
... | Text tag renderer
@param {String} textString The template string.
@param {Object} options The current options config.
@param {Object} data The source keys and values as an object.
@param {Bool} doSpecials Optional - render plain special keys [KEY, INDEX, VALUE]
@returns {String} | [
"Text",
"tag",
"renderer"
] | 6a2025b900e1dde68bf20820c3dec7c48bf98c7d | https://github.com/joelabair/Bracket-Templates/blob/6a2025b900e1dde68bf20820c3dec7c48bf98c7d/index.js#L199-L244 |
45,865 | joelabair/Bracket-Templates | index.js | getOptions | function getOptions(opts) {
var obj = Object.create(_options);
obj = util._extend(obj, opts);
return obj;
} | javascript | function getOptions(opts) {
var obj = Object.create(_options);
obj = util._extend(obj, opts);
return obj;
} | [
"function",
"getOptions",
"(",
"opts",
")",
"{",
"var",
"obj",
"=",
"Object",
".",
"create",
"(",
"_options",
")",
";",
"obj",
"=",
"util",
".",
"_extend",
"(",
"obj",
",",
"opts",
")",
";",
"return",
"obj",
";",
"}"
] | Return options inheriting form the module defaults.
@param {Object} options Custom options passed in.
@returns {Object} | [
"Return",
"options",
"inheriting",
"form",
"the",
"module",
"defaults",
"."
] | 6a2025b900e1dde68bf20820c3dec7c48bf98c7d | https://github.com/joelabair/Bracket-Templates/blob/6a2025b900e1dde68bf20820c3dec7c48bf98c7d/index.js#L253-L257 |
45,866 | mkormendy/node-alarm-dot-com | index.js | getCurrentState | function getCurrentState(systemID, authOpts) {
return authenticatedGet(SYSTEM_URL + systemID, authOpts).then(res => {
const rels = res.data.relationships
const partTasks = rels.partitions.data.map(p =>
getPartition(p.id, authOpts)
)
const sensorIDs = rels.sensors.data.map(s => s.id)
return ... | javascript | function getCurrentState(systemID, authOpts) {
return authenticatedGet(SYSTEM_URL + systemID, authOpts).then(res => {
const rels = res.data.relationships
const partTasks = rels.partitions.data.map(p =>
getPartition(p.id, authOpts)
)
const sensorIDs = rels.sensors.data.map(s => s.id)
return ... | [
"function",
"getCurrentState",
"(",
"systemID",
",",
"authOpts",
")",
"{",
"return",
"authenticatedGet",
"(",
"SYSTEM_URL",
"+",
"systemID",
",",
"authOpts",
")",
".",
"then",
"(",
"res",
"=>",
"{",
"const",
"rels",
"=",
"res",
".",
"data",
".",
"relations... | Retrieve information about the current state of a security system including
attributes, partitions, sensors, and relationships.
@param {string} systemID ID of the system to query. The Authentication object
returned from the `login` method contains a `systems` property which is an
array of system IDs.
@param {Object} a... | [
"Retrieve",
"information",
"about",
"the",
"current",
"state",
"of",
"a",
"security",
"system",
"including",
"attributes",
"partitions",
"sensors",
"and",
"relationships",
"."
] | b4ac45886eaddd5e739cd49b7aa8f9189c0124cc | https://github.com/mkormendy/node-alarm-dot-com/blob/b4ac45886eaddd5e739cd49b7aa8f9189c0124cc/index.js#L167-L189 |
45,867 | mkormendy/node-alarm-dot-com | index.js | getSensors | function getSensors(sensorIDs, authOpts) {
if (!Array.isArray(sensorIDs)) sensorIDs = [sensorIDs]
const query = sensorIDs.map(id => `ids%5B%5D=${id}`).join('&')
const url = `${SENSORS_URL}?${query}`
return authenticatedGet(url, authOpts)
} | javascript | function getSensors(sensorIDs, authOpts) {
if (!Array.isArray(sensorIDs)) sensorIDs = [sensorIDs]
const query = sensorIDs.map(id => `ids%5B%5D=${id}`).join('&')
const url = `${SENSORS_URL}?${query}`
return authenticatedGet(url, authOpts)
} | [
"function",
"getSensors",
"(",
"sensorIDs",
",",
"authOpts",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"sensorIDs",
")",
")",
"sensorIDs",
"=",
"[",
"sensorIDs",
"]",
"const",
"query",
"=",
"sensorIDs",
".",
"map",
"(",
"id",
"=>",
"`",
... | Get information for one or more sensors.
@param {string|string[]} sensorIDs Array of sensor ID strings.
@param {Object} authOpts Authentication object returned from the `login`
method.
@returns {Promise} | [
"Get",
"information",
"for",
"one",
"or",
"more",
"sensors",
"."
] | b4ac45886eaddd5e739cd49b7aa8f9189c0124cc | https://github.com/mkormendy/node-alarm-dot-com/blob/b4ac45886eaddd5e739cd49b7aa8f9189c0124cc/index.js#L211-L216 |
45,868 | buttercup/buttercup-core-web | source/StorageInterface.js | function(key, defaultValue) {
var value = window.localStorage.getItem(key);
return value ? JSON.parse(value) : defaultValue;
} | javascript | function(key, defaultValue) {
var value = window.localStorage.getItem(key);
return value ? JSON.parse(value) : defaultValue;
} | [
"function",
"(",
"key",
",",
"defaultValue",
")",
"{",
"var",
"value",
"=",
"window",
".",
"localStorage",
".",
"getItem",
"(",
"key",
")",
";",
"return",
"value",
"?",
"JSON",
".",
"parse",
"(",
"value",
")",
":",
"defaultValue",
";",
"}"
] | Get data from storage
@memberof StorageInterface
@name getData
@static
@param {String} key The key to fetch for
@param {*} defaultValue The default value if the key is not found
@returns {*} The fetched data | [
"Get",
"data",
"from",
"storage"
] | 40b6ff7ee4b04a085720dbb013782be8e921f864 | https://github.com/buttercup/buttercup-core-web/blob/40b6ff7ee4b04a085720dbb013782be8e921f864/source/StorageInterface.js#L18-L21 | |
45,869 | cgalvarez/atom-coverage | lib/util.js | writeConfig | function writeConfig(filePath, data, fileFormat) {
if (!filePath || !data) {
throw new Error('No file/data to save!');
}
const ext = rgxExt.exec(filePath) || [];
const format = fileFormat || ext[1];
if (format === 'yaml' || format === 'yml') {
return writeFileSync(filePath, yaml.safeDump(data), { en... | javascript | function writeConfig(filePath, data, fileFormat) {
if (!filePath || !data) {
throw new Error('No file/data to save!');
}
const ext = rgxExt.exec(filePath) || [];
const format = fileFormat || ext[1];
if (format === 'yaml' || format === 'yml') {
return writeFileSync(filePath, yaml.safeDump(data), { en... | [
"function",
"writeConfig",
"(",
"filePath",
",",
"data",
",",
"fileFormat",
")",
"{",
"if",
"(",
"!",
"filePath",
"||",
"!",
"data",
")",
"{",
"throw",
"new",
"Error",
"(",
"'No file/data to save!'",
")",
";",
"}",
"const",
"ext",
"=",
"rgxExt",
".",
"... | Writes a given JSON object `data` to a `filePath` with the requested `format`.
@param {String} filePath The path where to write the file.
@param {Object} data The object to write into the file contents.
@param {String} fileFormat One of "yaml", "yml", "json". | [
"Writes",
"a",
"given",
"JSON",
"object",
"data",
"to",
"a",
"filePath",
"with",
"the",
"requested",
"format",
"."
] | c0f9f621bad474079f809b56b532ab2f4004c151 | https://github.com/cgalvarez/atom-coverage/blob/c0f9f621bad474079f809b56b532ab2f4004c151/lib/util.js#L35-L48 |
45,870 | cgalvarez/atom-coverage | lib/util.js | readConfig | function readConfig(globPattern, fileFormat) {
const filepath = findConfigFile(globPattern);
if (!filepath) {
this.settings = {};
return;
}
const ext = rgxExt.exec(filepath) || [];
const format = fileFormat || ext[1];
const settings = (format === 'yaml' || format === 'yml')
? yaml.safeLoad(re... | javascript | function readConfig(globPattern, fileFormat) {
const filepath = findConfigFile(globPattern);
if (!filepath) {
this.settings = {};
return;
}
const ext = rgxExt.exec(filepath) || [];
const format = fileFormat || ext[1];
const settings = (format === 'yaml' || format === 'yml')
? yaml.safeLoad(re... | [
"function",
"readConfig",
"(",
"globPattern",
",",
"fileFormat",
")",
"{",
"const",
"filepath",
"=",
"findConfigFile",
"(",
"globPattern",
")",
";",
"if",
"(",
"!",
"filepath",
")",
"{",
"this",
".",
"settings",
"=",
"{",
"}",
";",
"return",
";",
"}",
... | Searches a config file under current working dir, using the provided glob
pattern `globPattern`.
If found, parses its contents based on the provided `fileFormat`. Currently
only supports YAML or JSON formats (defaults to JSON if format not
provided and cannot be inferred from file extension).
NOTE This function is me... | [
"Searches",
"a",
"config",
"file",
"under",
"current",
"working",
"dir",
"using",
"the",
"provided",
"glob",
"pattern",
"globPattern",
"."
] | c0f9f621bad474079f809b56b532ab2f4004c151 | https://github.com/cgalvarez/atom-coverage/blob/c0f9f621bad474079f809b56b532ab2f4004c151/lib/util.js#L79-L96 |
45,871 | Marketcloud/marketcloud-js | src/request.js | createXMLHTTPObject | function createXMLHTTPObject () {
var xmlhttp = false
for (var i = 0; i < XMLHttpFactories.length; i++) {
try {
xmlhttp = XMLHttpFactories[i]()
} catch (e) {
continue
}
break
}
return xmlhttp
} | javascript | function createXMLHTTPObject () {
var xmlhttp = false
for (var i = 0; i < XMLHttpFactories.length; i++) {
try {
xmlhttp = XMLHttpFactories[i]()
} catch (e) {
continue
}
break
}
return xmlhttp
} | [
"function",
"createXMLHTTPObject",
"(",
")",
"{",
"var",
"xmlhttp",
"=",
"false",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"XMLHttpFactories",
".",
"length",
";",
"i",
"++",
")",
"{",
"try",
"{",
"xmlhttp",
"=",
"XMLHttpFactories",
"[",
"i",
... | Builds an AJAX request in a cross browser fashion
@returns {XMLHttpRequest|ActiveXObject} The crafted request | [
"Builds",
"an",
"AJAX",
"request",
"in",
"a",
"cross",
"browser",
"fashion"
] | b41faa9b26445c39422aa167a5cc804ef00d9552 | https://github.com/Marketcloud/marketcloud-js/blob/b41faa9b26445c39422aa167a5cc804ef00d9552/src/request.js#L20-L31 |
45,872 | sydneystockholm/jpegmini | index.js | optionString | function optionString(options) {
return Object.keys(options).map(function (key) {
var value = options[key];
if (value === null) {
return '-' + key;
} else if (typeof value === 'number') {
value += '';
} else if (typeof value === 'string') {
value =... | javascript | function optionString(options) {
return Object.keys(options).map(function (key) {
var value = options[key];
if (value === null) {
return '-' + key;
} else if (typeof value === 'number') {
value += '';
} else if (typeof value === 'string') {
value =... | [
"function",
"optionString",
"(",
"options",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"options",
")",
".",
"map",
"(",
"function",
"(",
"key",
")",
"{",
"var",
"value",
"=",
"options",
"[",
"key",
"]",
";",
"if",
"(",
"value",
"===",
"null",
... | Convert an options object to a string. | [
"Convert",
"an",
"options",
"object",
"to",
"a",
"string",
"."
] | 4ac2377286510817a079dcc84c9d8b1db9a746f6 | https://github.com/sydneystockholm/jpegmini/blob/4ac2377286510817a079dcc84c9d8b1db9a746f6/index.js#L168-L180 |
45,873 | sydneystockholm/jpegmini | index.js | randomString | function randomString() {
var str = '', length = 32;
while (length--) {
str += String.fromCharCode(Math.random() * 26 | 97);
}
return str;
} | javascript | function randomString() {
var str = '', length = 32;
while (length--) {
str += String.fromCharCode(Math.random() * 26 | 97);
}
return str;
} | [
"function",
"randomString",
"(",
")",
"{",
"var",
"str",
"=",
"''",
",",
"length",
"=",
"32",
";",
"while",
"(",
"length",
"--",
")",
"{",
"str",
"+=",
"String",
".",
"fromCharCode",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"26",
"|",
"97",
")"... | Get a random 32 byte string. | [
"Get",
"a",
"random",
"32",
"byte",
"string",
"."
] | 4ac2377286510817a079dcc84c9d8b1db9a746f6 | https://github.com/sydneystockholm/jpegmini/blob/4ac2377286510817a079dcc84c9d8b1db9a746f6/index.js#L186-L192 |
45,874 | kotfire/jquery-clockpicker | dist/jquery-clockpicker.js | function() {
var element = this.element,
template = this.template,
offset = element.offset(),
width = element.outerWidth(),
height = element.outerHeight(),
position = this.options.position,
alignment = this.optio... | javascript | function() {
var element = this.element,
template = this.template,
offset = element.offset(),
width = element.outerWidth(),
height = element.outerHeight(),
position = this.options.position,
alignment = this.optio... | [
"function",
"(",
")",
"{",
"var",
"element",
"=",
"this",
".",
"element",
",",
"template",
"=",
"this",
".",
"template",
",",
"offset",
"=",
"element",
".",
"offset",
"(",
")",
",",
"width",
"=",
"element",
".",
"outerWidth",
"(",
")",
",",
"height",... | Set template position | [
"Set",
"template",
"position"
] | dc41cc5efb1dcd5a583db25cd92fb9f62933a92a | https://github.com/kotfire/jquery-clockpicker/blob/dc41cc5efb1dcd5a583db25cd92fb9f62933a92a/dist/jquery-clockpicker.js#L451-L491 | |
45,875 | kotfire/jquery-clockpicker | dist/jquery-clockpicker.js | function(view, delay) {
var self = this;
var raiseAfterShowHours = false;
var raiseAfterShowMinutes = false;
if (view === 'hours') {
raiseCallback(this.options.beforeShowHours);
raiseAfterShowHours = true;
}
if (vie... | javascript | function(view, delay) {
var self = this;
var raiseAfterShowHours = false;
var raiseAfterShowMinutes = false;
if (view === 'hours') {
raiseCallback(this.options.beforeShowHours);
raiseAfterShowHours = true;
}
if (vie... | [
"function",
"(",
"view",
",",
"delay",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"raiseAfterShowHours",
"=",
"false",
";",
"var",
"raiseAfterShowMinutes",
"=",
"false",
";",
"if",
"(",
"view",
"===",
"'hours'",
")",
"{",
"raiseCallback",
"(",
"th... | Toggle to hours or minutes view | [
"Toggle",
"to",
"hours",
"or",
"minutes",
"view"
] | dc41cc5efb1dcd5a583db25cd92fb9f62933a92a | https://github.com/kotfire/jquery-clockpicker/blob/dc41cc5efb1dcd5a583db25cd92fb9f62933a92a/dist/jquery-clockpicker.js#L575-L619 | |
45,876 | kotfire/jquery-clockpicker | dist/jquery-clockpicker.js | function(delay) {
var view = this.currentView,
value = this[view],
isHours = view === 'hours',
unit = Math.PI / (isHours ? 6 : 30),
radian = value * unit,
radius = isHours && value > 0 && value < 13 ? innerRadius : outerRadius,
... | javascript | function(delay) {
var view = this.currentView,
value = this[view],
isHours = view === 'hours',
unit = Math.PI / (isHours ? 6 : 30),
radian = value * unit,
radius = isHours && value > 0 && value < 13 ? innerRadius : outerRadius,
... | [
"function",
"(",
"delay",
")",
"{",
"var",
"view",
"=",
"this",
".",
"currentView",
",",
"value",
"=",
"this",
"[",
"view",
"]",
",",
"isHours",
"=",
"view",
"===",
"'hours'",
",",
"unit",
"=",
"Math",
".",
"PI",
"/",
"(",
"isHours",
"?",
"6",
":... | Reset clock hand | [
"Reset",
"clock",
"hand"
] | dc41cc5efb1dcd5a583db25cd92fb9f62933a92a | https://github.com/kotfire/jquery-clockpicker/blob/dc41cc5efb1dcd5a583db25cd92fb9f62933a92a/dist/jquery-clockpicker.js#L622-L642 | |
45,877 | kotfire/jquery-clockpicker | dist/jquery-clockpicker.js | function(timeObject) {
this.hours = timeObject.hours;
this.minutes = timeObject.minutes;
this.amOrPm = timeObject.amOrPm;
this._checkTimeLimits();
this._updateLabels();
this.resetClock();
} | javascript | function(timeObject) {
this.hours = timeObject.hours;
this.minutes = timeObject.minutes;
this.amOrPm = timeObject.amOrPm;
this._checkTimeLimits();
this._updateLabels();
this.resetClock();
} | [
"function",
"(",
"timeObject",
")",
"{",
"this",
".",
"hours",
"=",
"timeObject",
".",
"hours",
";",
"this",
".",
"minutes",
"=",
"timeObject",
".",
"minutes",
";",
"this",
".",
"amOrPm",
"=",
"timeObject",
".",
"amOrPm",
";",
"this",
".",
"_checkTimeLim... | Set time from ClockTime object | [
"Set",
"time",
"from",
"ClockTime",
"object"
] | dc41cc5efb1dcd5a583db25cd92fb9f62933a92a | https://github.com/kotfire/jquery-clockpicker/blob/dc41cc5efb1dcd5a583db25cd92fb9f62933a92a/dist/jquery-clockpicker.js#L848-L858 | |
45,878 | vrest-io/vrunner | lib/replacingStrings.js | function(str, methodDec, methodName, method, methodsMap, options){
var methodValue = getMethodValue(methodDec, methodName, method, methodsMap, options);
if(str === methodDec) return methodValue;
return str.replace(methodDec, function(){ return methodValue; });
} | javascript | function(str, methodDec, methodName, method, methodsMap, options){
var methodValue = getMethodValue(methodDec, methodName, method, methodsMap, options);
if(str === methodDec) return methodValue;
return str.replace(methodDec, function(){ return methodValue; });
} | [
"function",
"(",
"str",
",",
"methodDec",
",",
"methodName",
",",
"method",
",",
"methodsMap",
",",
"options",
")",
"{",
"var",
"methodValue",
"=",
"getMethodValue",
"(",
"methodDec",
",",
"methodName",
",",
"method",
",",
"methodsMap",
",",
"options",
")",
... | invokes a single method and replaces its value in the string | [
"invokes",
"a",
"single",
"method",
"and",
"replaces",
"its",
"value",
"in",
"the",
"string"
] | cad70c21cb9a763e74dcffebad1c45ca11a63a1e | https://github.com/vrest-io/vrunner/blob/cad70c21cb9a763e74dcffebad1c45ca11a63a1e/lib/replacingStrings.js#L179-L183 | |
45,879 | nickclaw/alexa-ssml | src/renderToString.js | renderNode | function renderNode(node, children = []) {
[...children].forEach(child => {
if (child && child.tag) {
node.ele(child.tag, child.props);
renderNode(node, child.children);
node.end();
} else {
node.text(child);
}
});
} | javascript | function renderNode(node, children = []) {
[...children].forEach(child => {
if (child && child.tag) {
node.ele(child.tag, child.props);
renderNode(node, child.children);
node.end();
} else {
node.text(child);
}
});
} | [
"function",
"renderNode",
"(",
"node",
",",
"children",
"=",
"[",
"]",
")",
"{",
"[",
"...",
"children",
"]",
".",
"forEach",
"(",
"child",
"=>",
"{",
"if",
"(",
"child",
"&&",
"child",
".",
"tag",
")",
"{",
"node",
".",
"ele",
"(",
"child",
".",... | Recursively turns jsx children into xml nodes
@param {Array} children
@param {XMLNode} node | [
"Recursively",
"turns",
"jsx",
"children",
"into",
"xml",
"nodes"
] | f857e2daa9e4e5d7ed1ff40b78fd56a66d9d228d | https://github.com/nickclaw/alexa-ssml/blob/f857e2daa9e4e5d7ed1ff40b78fd56a66d9d228d/src/renderToString.js#L21-L31 |
45,880 | naturalatlas/tilestrata-vtile-raster | index.js | initialize | function initialize(server, callback) {
source = new Backend(server, options);
source.initialize(callback);
} | javascript | function initialize(server, callback) {
source = new Backend(server, options);
source.initialize(callback);
} | [
"function",
"initialize",
"(",
"server",
",",
"callback",
")",
"{",
"source",
"=",
"new",
"Backend",
"(",
"server",
",",
"options",
")",
";",
"source",
".",
"initialize",
"(",
"callback",
")",
";",
"}"
] | Initializes the mapnik datasource.
@param {TileServer} server
@param {function} callback(err, fn)
@return {void} | [
"Initializes",
"the",
"mapnik",
"datasource",
"."
] | e97ae82894362023aed05f0391defd434f974aff | https://github.com/naturalatlas/tilestrata-vtile-raster/blob/e97ae82894362023aed05f0391defd434f974aff/index.js#L30-L33 |
45,881 | laurent22/joplin-turndown | src/turndown.js | replacementForNode | function replacementForNode (node) {
var rule = this.rules.forNode(node)
var content = process.call(this, node)
var whitespace = node.flankingWhitespace
if (whitespace.leading || whitespace.trailing) content = content.trim()
return (
whitespace.leading +
rule.replacement(content, node, this.options) +... | javascript | function replacementForNode (node) {
var rule = this.rules.forNode(node)
var content = process.call(this, node)
var whitespace = node.flankingWhitespace
if (whitespace.leading || whitespace.trailing) content = content.trim()
return (
whitespace.leading +
rule.replacement(content, node, this.options) +... | [
"function",
"replacementForNode",
"(",
"node",
")",
"{",
"var",
"rule",
"=",
"this",
".",
"rules",
".",
"forNode",
"(",
"node",
")",
"var",
"content",
"=",
"process",
".",
"call",
"(",
"this",
",",
"node",
")",
"var",
"whitespace",
"=",
"node",
".",
... | Converts an element node to its Markdown equivalent
@private
@param {HTMLElement} node The node to convert
@returns A Markdown representation of the node
@type String | [
"Converts",
"an",
"element",
"node",
"to",
"its",
"Markdown",
"equivalent"
] | 0ef389619b0b70e18e3d679c0fbed088591a3ab2 | https://github.com/laurent22/joplin-turndown/blob/0ef389619b0b70e18e3d679c0fbed088591a3ab2/src/turndown.js#L233-L243 |
45,882 | laurent22/joplin-turndown | src/turndown.js | separatingNewlines | function separatingNewlines (output, replacement) {
var newlines = [
output.match(trailingNewLinesRegExp)[0],
replacement.match(leadingNewLinesRegExp)[0]
].sort()
var maxNewlines = newlines[newlines.length - 1]
return maxNewlines.length < 2 ? maxNewlines : '\n\n'
} | javascript | function separatingNewlines (output, replacement) {
var newlines = [
output.match(trailingNewLinesRegExp)[0],
replacement.match(leadingNewLinesRegExp)[0]
].sort()
var maxNewlines = newlines[newlines.length - 1]
return maxNewlines.length < 2 ? maxNewlines : '\n\n'
} | [
"function",
"separatingNewlines",
"(",
"output",
",",
"replacement",
")",
"{",
"var",
"newlines",
"=",
"[",
"output",
".",
"match",
"(",
"trailingNewLinesRegExp",
")",
"[",
"0",
"]",
",",
"replacement",
".",
"match",
"(",
"leadingNewLinesRegExp",
")",
"[",
"... | Determines the new lines between the current output and the replacement
@private
@param {String} output The current conversion output
@param {String} replacement The string to append to the output
@returns The whitespace to separate the current output and the replacement
@type String | [
"Determines",
"the",
"new",
"lines",
"between",
"the",
"current",
"output",
"and",
"the",
"replacement"
] | 0ef389619b0b70e18e3d679c0fbed088591a3ab2 | https://github.com/laurent22/joplin-turndown/blob/0ef389619b0b70e18e3d679c0fbed088591a3ab2/src/turndown.js#L254-L261 |
45,883 | mikolalysenko/mesh-geodesic | lib/geodesic.js | quadratic_distance | function quadratic_distance(a, b, c, dpa, dpb, orientation) {
var ab = new Array(3);
var ac = new Array(3);
var dab2 = 0.0;
for(var i=0; i<3; ++i) {
ab[i] = b[i] - a[i];
dab2 += ab[i] * ab[i];
ac[i] = c[i] - a[i];
}
if(dab2 < EPSILON) {
return 1e30;
}
//Transform c into triangle co... | javascript | function quadratic_distance(a, b, c, dpa, dpb, orientation) {
var ab = new Array(3);
var ac = new Array(3);
var dab2 = 0.0;
for(var i=0; i<3; ++i) {
ab[i] = b[i] - a[i];
dab2 += ab[i] * ab[i];
ac[i] = c[i] - a[i];
}
if(dab2 < EPSILON) {
return 1e30;
}
//Transform c into triangle co... | [
"function",
"quadratic_distance",
"(",
"a",
",",
"b",
",",
"c",
",",
"dpa",
",",
"dpb",
",",
"orientation",
")",
"{",
"var",
"ab",
"=",
"new",
"Array",
"(",
"3",
")",
";",
"var",
"ac",
"=",
"new",
"Array",
"(",
"3",
")",
";",
"var",
"dab2",
"="... | Computes quadratic distance to point c | [
"Computes",
"quadratic",
"distance",
"to",
"point",
"c"
] | 066d741f3b6f890e1c749e14fd42ff9a57294d14 | https://github.com/mikolalysenko/mesh-geodesic/blob/066d741f3b6f890e1c749e14fd42ff9a57294d14/lib/geodesic.js#L7-L54 |
45,884 | mikolalysenko/mesh-geodesic | lib/geodesic.js | geodesic_distance | function geodesic_distance(cells, positions, p, max_distance, tolerance, stars) {
if(typeof(max_distance) === "undefined") {
max_distance = Number.POSITIVE_INFINITY
}
if(typeof(tolerance) === "undefined") {
tolerance = 1e-4
}
if(typeof(dual) === "undefined") {
stars = top.dual(cells, positions.le... | javascript | function geodesic_distance(cells, positions, p, max_distance, tolerance, stars) {
if(typeof(max_distance) === "undefined") {
max_distance = Number.POSITIVE_INFINITY
}
if(typeof(tolerance) === "undefined") {
tolerance = 1e-4
}
if(typeof(dual) === "undefined") {
stars = top.dual(cells, positions.le... | [
"function",
"geodesic_distance",
"(",
"cells",
",",
"positions",
",",
"p",
",",
"max_distance",
",",
"tolerance",
",",
"stars",
")",
"{",
"if",
"(",
"typeof",
"(",
"max_distance",
")",
"===",
"\"undefined\"",
")",
"{",
"max_distance",
"=",
"Number",
".",
"... | Computes a distances to a vertex p | [
"Computes",
"a",
"distances",
"to",
"a",
"vertex",
"p"
] | 066d741f3b6f890e1c749e14fd42ff9a57294d14 | https://github.com/mikolalysenko/mesh-geodesic/blob/066d741f3b6f890e1c749e14fd42ff9a57294d14/lib/geodesic.js#L177-L197 |
45,885 | weexteam/weex-templater | index.js | walk | function walk(node, output, previousNode) {
// tag name
validator.checkTagName(node, output)
// attrs: id/class/style/if/repeat/append/event/attr
var attrs = node.attrs || []
attrs.forEach(function switchAttr(attr) {
var name = attr.name
var value = attr.value
var locationInfo = {line: 1, colum... | javascript | function walk(node, output, previousNode) {
// tag name
validator.checkTagName(node, output)
// attrs: id/class/style/if/repeat/append/event/attr
var attrs = node.attrs || []
attrs.forEach(function switchAttr(attr) {
var name = attr.name
var value = attr.value
var locationInfo = {line: 1, colum... | [
"function",
"walk",
"(",
"node",
",",
"output",
",",
"previousNode",
")",
"{",
"// tag name",
"validator",
".",
"checkTagName",
"(",
"node",
",",
"output",
")",
"// attrs: id/class/style/if/repeat/append/event/attr",
"var",
"attrs",
"=",
"node",
".",
"attrs",
"||"... | walk all nodes
- tag name checking
- attrs checking
- children checking
@param {Node} node
@param {object} output{result, deps[], log[]}
@param {Node} previousNode | [
"walk",
"all",
"nodes",
"-",
"tag",
"name",
"checking",
"-",
"attrs",
"checking",
"-",
"children",
"checking"
] | 200c1fbeb923b70e304193752fdf1db9802650c7 | https://github.com/weexteam/weex-templater/blob/200c1fbeb923b70e304193752fdf1db9802650c7/index.js#L15-L98 |
45,886 | sjonnet19/mocha-cobertura-reporter | lib/reporters/cobertura.js | Cobertura | function Cobertura(runner) {
var jade = require('jade')
jade.doctypes.cobertura = '<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-03.dtd">'
var file = __dirname + '/templates/cobertura.jade',
str = fs.readFileSync(file, 'utf8'),
fn = jade.compile(str, { filename: file }),
self = this
... | javascript | function Cobertura(runner) {
var jade = require('jade')
jade.doctypes.cobertura = '<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-03.dtd">'
var file = __dirname + '/templates/cobertura.jade',
str = fs.readFileSync(file, 'utf8'),
fn = jade.compile(str, { filename: file }),
self = this
... | [
"function",
"Cobertura",
"(",
"runner",
")",
"{",
"var",
"jade",
"=",
"require",
"(",
"'jade'",
")",
"jade",
".",
"doctypes",
".",
"cobertura",
"=",
"'<!DOCTYPE coverage SYSTEM \"http://cobertura.sourceforge.net/xml/coverage-03.dtd\">'",
"var",
"file",
"=",
"__dirname",... | Initialize a new `Cobertura` reporter.
@param {Runner} runner
@api public | [
"Initialize",
"a",
"new",
"Cobertura",
"reporter",
"."
] | c4f3c2c7820a35e665be42118767f1621f0923d3 | https://github.com/sjonnet19/mocha-cobertura-reporter/blob/c4f3c2c7820a35e665be42118767f1621f0923d3/lib/reporters/cobertura.js#L22-L39 |
45,887 | arve0/deep-reduce | index.js | deepReduce | function deepReduce(obj, reducer, reduced, path, thisArg) {
if (reduced === void 0) { reduced = {}; }
if (path === void 0) { path = ''; }
if (thisArg === void 0) { thisArg = {}; }
var pathArr = path === '' ? [] : path.split('.');
var root = obj; // keep value of root object, for recursion
if (pa... | javascript | function deepReduce(obj, reducer, reduced, path, thisArg) {
if (reduced === void 0) { reduced = {}; }
if (path === void 0) { path = ''; }
if (thisArg === void 0) { thisArg = {}; }
var pathArr = path === '' ? [] : path.split('.');
var root = obj; // keep value of root object, for recursion
if (pa... | [
"function",
"deepReduce",
"(",
"obj",
",",
"reducer",
",",
"reduced",
",",
"path",
",",
"thisArg",
")",
"{",
"if",
"(",
"reduced",
"===",
"void",
"0",
")",
"{",
"reduced",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"path",
"===",
"void",
"0",
")",
"{",
... | Reduce objects deeply, like Array.prototype.reduce but for objects.
@param obj Object to traverse.
@param reducer Reducer function.
@param reduced Initial accumulated value.
@param path Root of traversal.
@param thisArg Binds `thisArg` as `this` on `reducer`.
@returns Accumulated value. | [
"Reduce",
"objects",
"deeply",
"like",
"Array",
".",
"prototype",
".",
"reduce",
"but",
"for",
"objects",
"."
] | 375e1058b61671656dc602b2b58d742fe9dd95a2 | https://github.com/arve0/deep-reduce/blob/375e1058b61671656dc602b2b58d742fe9dd95a2/index.js#L12-L42 |
45,888 | dkozar/raycast-dom | build/lookup/evaluateID.js | evaluateID | function evaluateID(sub, element) {
var id = element.id;
return id && id.indexOf(sub) === 0;
} | javascript | function evaluateID(sub, element) {
var id = element.id;
return id && id.indexOf(sub) === 0;
} | [
"function",
"evaluateID",
"(",
"sub",
",",
"element",
")",
"{",
"var",
"id",
"=",
"element",
".",
"id",
";",
"return",
"id",
"&&",
"id",
".",
"indexOf",
"(",
"sub",
")",
"===",
"0",
";",
"}"
] | Checks whether the substring is present within element ID
@param sub Substring to check for
@param element DOM element
@returns {*|boolean} | [
"Checks",
"whether",
"the",
"substring",
"is",
"present",
"within",
"element",
"ID"
] | 91eb7ad1fbc4c91f8f3ccca69a33e1083f6d5d98 | https://github.com/dkozar/raycast-dom/blob/91eb7ad1fbc4c91f8f3ccca69a33e1083f6d5d98/build/lookup/evaluateID.js#L13-L17 |
45,889 | gaurav-nelson/retext-google-styleguide | index.js | removeA | function removeA(arr) {
var what,
a = arguments,
L = a.length,
ax;
while (L > 1 && arr.length) {
what = a[--L];
while ((ax = arr.indexOf(what)) !== -1) {
arr.splice(ax, 1);
}
}
return arr;
} | javascript | function removeA(arr) {
var what,
a = arguments,
L = a.length,
ax;
while (L > 1 && arr.length) {
what = a[--L];
while ((ax = arr.indexOf(what)) !== -1) {
arr.splice(ax, 1);
}
}
return arr;
} | [
"function",
"removeA",
"(",
"arr",
")",
"{",
"var",
"what",
",",
"a",
"=",
"arguments",
",",
"L",
"=",
"a",
".",
"length",
",",
"ax",
";",
"while",
"(",
"L",
">",
"1",
"&&",
"arr",
".",
"length",
")",
"{",
"what",
"=",
"a",
"[",
"--",
"L",
... | to remove passed values from the array, used to find and remove empty vlaues | [
"to",
"remove",
"passed",
"values",
"from",
"the",
"array",
"used",
"to",
"find",
"and",
"remove",
"empty",
"vlaues"
] | 9c601b11e2c4bed57376b78566bad26ecbbeadca | https://github.com/gaurav-nelson/retext-google-styleguide/blob/9c601b11e2c4bed57376b78566bad26ecbbeadca/index.js#L28-L40 |
45,890 | gaurav-nelson/retext-google-styleguide | index.js | countWords | function countWords(s) {
s = s.replace(/(^\s*)|(\s*$)/gi, ""); //exclude start and end white-space
s = s.replace(/[ ]{2,}/gi, " "); //2 or more space to 1
s = s.replace(/\n /, "\n"); // exclude newline with a start spacing
return s.split(" ").length;
} | javascript | function countWords(s) {
s = s.replace(/(^\s*)|(\s*$)/gi, ""); //exclude start and end white-space
s = s.replace(/[ ]{2,}/gi, " "); //2 or more space to 1
s = s.replace(/\n /, "\n"); // exclude newline with a start spacing
return s.split(" ").length;
} | [
"function",
"countWords",
"(",
"s",
")",
"{",
"s",
"=",
"s",
".",
"replace",
"(",
"/",
"(^\\s*)|(\\s*$)",
"/",
"gi",
",",
"\"\"",
")",
";",
"//exclude start and end white-space",
"s",
"=",
"s",
".",
"replace",
"(",
"/",
"[ ]{2,}",
"/",
"gi",
",",
"\" ... | to check number of words in an array | [
"to",
"check",
"number",
"of",
"words",
"in",
"an",
"array"
] | 9c601b11e2c4bed57376b78566bad26ecbbeadca | https://github.com/gaurav-nelson/retext-google-styleguide/blob/9c601b11e2c4bed57376b78566bad26ecbbeadca/index.js#L43-L48 |
45,891 | gaurav-nelson/retext-google-styleguide | index.js | function(needle) {
// Per spec, the way to identify NaN is that it is not equal to itself
var findNaN = needle !== needle;
var indexOf;
if (!findNaN && typeof Array.prototype.indexOf === "function") {
indexOf = Array.prototype.indexOf;
} else {
indexOf = function(needle) {
var i = -1,
i... | javascript | function(needle) {
// Per spec, the way to identify NaN is that it is not equal to itself
var findNaN = needle !== needle;
var indexOf;
if (!findNaN && typeof Array.prototype.indexOf === "function") {
indexOf = Array.prototype.indexOf;
} else {
indexOf = function(needle) {
var i = -1,
i... | [
"function",
"(",
"needle",
")",
"{",
"// Per spec, the way to identify NaN is that it is not equal to itself",
"var",
"findNaN",
"=",
"needle",
"!==",
"needle",
";",
"var",
"indexOf",
";",
"if",
"(",
"!",
"findNaN",
"&&",
"typeof",
"Array",
".",
"prototype",
".",
... | to check if all values in the array are same | [
"to",
"check",
"if",
"all",
"values",
"in",
"the",
"array",
"are",
"same"
] | 9c601b11e2c4bed57376b78566bad26ecbbeadca | https://github.com/gaurav-nelson/retext-google-styleguide/blob/9c601b11e2c4bed57376b78566bad26ecbbeadca/index.js#L51-L77 | |
45,892 | tdreyno/morlock.js | controllers/breakpoint-controller.js | BreakpointController | function BreakpointController(options) {
if (!(this instanceof BreakpointController)) {
return new BreakpointController(options);
}
Emitter.mixin(this);
var breakpointStream = BreakpointStream.create(options.breakpoints, {
throttleMs: options.throttleMs,
debounceMs: options.debounceMs
});
var... | javascript | function BreakpointController(options) {
if (!(this instanceof BreakpointController)) {
return new BreakpointController(options);
}
Emitter.mixin(this);
var breakpointStream = BreakpointStream.create(options.breakpoints, {
throttleMs: options.throttleMs,
debounceMs: options.debounceMs
});
var... | [
"function",
"BreakpointController",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"BreakpointController",
")",
")",
"{",
"return",
"new",
"BreakpointController",
"(",
"options",
")",
";",
"}",
"Emitter",
".",
"mixin",
"(",
"this",
")",... | Provides a familiar OO-style API for tracking breakpoint events.
@constructor
@param {Object=} options The options passed to the breakpoint tracker.
@return {Object} The API with a `on` function to attach callbacks
to breakpoint changes. | [
"Provides",
"a",
"familiar",
"OO",
"-",
"style",
"API",
"for",
"tracking",
"breakpoint",
"events",
"."
] | a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/controllers/breakpoint-controller.js#L13-L40 |
45,893 | mosaicjs/Leaflet.CanvasDataGrid | src/data/GridIndex.js | function(x, y) {
var array = this.getAllData(x, y);
return array && array.length ? array[0] : undefined;
} | javascript | function(x, y) {
var array = this.getAllData(x, y);
return array && array.length ? array[0] : undefined;
} | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"var",
"array",
"=",
"this",
".",
"getAllData",
"(",
"x",
",",
"y",
")",
";",
"return",
"array",
"&&",
"array",
".",
"length",
"?",
"array",
"[",
"0",
"]",
":",
"undefined",
";",
"}"
] | Returns data associated with the specified position on the canvas. | [
"Returns",
"data",
"associated",
"with",
"the",
"specified",
"position",
"on",
"the",
"canvas",
"."
] | ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/data/GridIndex.js#L19-L22 | |
45,894 | mosaicjs/Leaflet.CanvasDataGrid | src/data/GridIndex.js | function(x, y) {
var maskX = this._getMaskX(x);
var maskY = this._getMaskY(y);
var key = this._getIndexKey(maskX, maskY);
return this._dataIndex[key];
} | javascript | function(x, y) {
var maskX = this._getMaskX(x);
var maskY = this._getMaskY(y);
var key = this._getIndexKey(maskX, maskY);
return this._dataIndex[key];
} | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"var",
"maskX",
"=",
"this",
".",
"_getMaskX",
"(",
"x",
")",
";",
"var",
"maskY",
"=",
"this",
".",
"_getMaskY",
"(",
"y",
")",
";",
"var",
"key",
"=",
"this",
".",
"_getIndexKey",
"(",
"maskX",
",",
"... | Returns all data objects associated with the specified position on the
canvas. | [
"Returns",
"all",
"data",
"objects",
"associated",
"with",
"the",
"specified",
"position",
"on",
"the",
"canvas",
"."
] | ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/data/GridIndex.js#L28-L33 | |
45,895 | mosaicjs/Leaflet.CanvasDataGrid | src/data/GridIndex.js | function(x, y, options) {
var maskX = this._getMaskX(x);
var maskY = this._getMaskY(y);
var key = this._getIndexKey(maskX, maskY);
return this._addDataToIndex(key, options);
} | javascript | function(x, y, options) {
var maskX = this._getMaskX(x);
var maskY = this._getMaskY(y);
var key = this._getIndexKey(maskX, maskY);
return this._addDataToIndex(key, options);
} | [
"function",
"(",
"x",
",",
"y",
",",
"options",
")",
"{",
"var",
"maskX",
"=",
"this",
".",
"_getMaskX",
"(",
"x",
")",
";",
"var",
"maskY",
"=",
"this",
".",
"_getMaskY",
"(",
"y",
")",
";",
"var",
"key",
"=",
"this",
".",
"_getIndexKey",
"(",
... | Sets data in the specified position on the canvas.
@param x
@param y
@param options.data
a data object to set | [
"Sets",
"data",
"in",
"the",
"specified",
"position",
"on",
"the",
"canvas",
"."
] | ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/data/GridIndex.js#L43-L48 | |
45,896 | dkozar/raycast-dom | build/lookup/evaluateReactID.js | evaluateReactID | function evaluateReactID(sub, element) {
var id = element.getAttribute && element.getAttribute('data-reactid');
return id && id.indexOf(sub) > -1;
} | javascript | function evaluateReactID(sub, element) {
var id = element.getAttribute && element.getAttribute('data-reactid');
return id && id.indexOf(sub) > -1;
} | [
"function",
"evaluateReactID",
"(",
"sub",
",",
"element",
")",
"{",
"var",
"id",
"=",
"element",
".",
"getAttribute",
"&&",
"element",
".",
"getAttribute",
"(",
"'data-reactid'",
")",
";",
"return",
"id",
"&&",
"id",
".",
"indexOf",
"(",
"sub",
")",
">"... | Checks whether the substring is present within element's React ID
@param sub Substring to check for
@param element DOM element
@returns {*|boolean} | [
"Checks",
"whether",
"the",
"substring",
"is",
"present",
"within",
"element",
"s",
"React",
"ID"
] | 91eb7ad1fbc4c91f8f3ccca69a33e1083f6d5d98 | https://github.com/dkozar/raycast-dom/blob/91eb7ad1fbc4c91f8f3ccca69a33e1083f6d5d98/build/lookup/evaluateReactID.js#L13-L17 |
45,897 | weexteam/weex-templater | lib/validator.js | checkTagName | function checkTagName(node, output) {
var result = output.result
var deps = output.deps
var log = output.log
var tagName = node.tagName
var childNodes = node.childNodes || []
var location = node.__location || {}
// alias
if (TAG_NAME_ALIAS_MAP[tagName]) {
if (tagName !== 'img') { // FIXME: `parse5... | javascript | function checkTagName(node, output) {
var result = output.result
var deps = output.deps
var log = output.log
var tagName = node.tagName
var childNodes = node.childNodes || []
var location = node.__location || {}
// alias
if (TAG_NAME_ALIAS_MAP[tagName]) {
if (tagName !== 'img') { // FIXME: `parse5... | [
"function",
"checkTagName",
"(",
"node",
",",
"output",
")",
"{",
"var",
"result",
"=",
"output",
".",
"result",
"var",
"deps",
"=",
"output",
".",
"deps",
"var",
"log",
"=",
"output",
".",
"log",
"var",
"tagName",
"=",
"node",
".",
"tagName",
"var",
... | tag name checking
- autofix alias
- append deps
- check parent requirements
- check children requirements
and the result, deps, log will be updated
@param {Node} node
@param {object} output{result, deps[], log[]} | [
"tag",
"name",
"checking",
"-",
"autofix",
"alias",
"-",
"append",
"deps",
"-",
"check",
"parent",
"requirements",
"-",
"check",
"children",
"requirements",
"and",
"the",
"result",
"deps",
"log",
"will",
"be",
"updated"
] | 200c1fbeb923b70e304193752fdf1db9802650c7 | https://github.com/weexteam/weex-templater/blob/200c1fbeb923b70e304193752fdf1db9802650c7/lib/validator.js#L99-L185 |
45,898 | crcn/emailify | lib/index.js | _parse | function _parse(content, options, callback) {
if(typeof options == 'function') {
callback = options;
options.test = false;
}
var on = outcome.error(callback),
warnings,
window;
step(
/**
* load it.
*/
function() {
jsdom.env({
html: content,
scripts: [
__dirname + "/jqu... | javascript | function _parse(content, options, callback) {
if(typeof options == 'function') {
callback = options;
options.test = false;
}
var on = outcome.error(callback),
warnings,
window;
step(
/**
* load it.
*/
function() {
jsdom.env({
html: content,
scripts: [
__dirname + "/jqu... | [
"function",
"_parse",
"(",
"content",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"options",
"==",
"'function'",
")",
"{",
"callback",
"=",
"options",
";",
"options",
".",
"test",
"=",
"false",
";",
"}",
"var",
"on",
"=",
"outcome",... | parses content into email-safe HTML | [
"parses",
"content",
"into",
"email",
"-",
"safe",
"HTML"
] | 9ef187d60828ce393195396e87326fdceb1d1d57 | https://github.com/crcn/emailify/blob/9ef187d60828ce393195396e87326fdceb1d1d57/lib/index.js#L30-L129 |
45,899 | tdreyno/morlock.js | core/stream.js | attachListener_ | function attachListener_() {
if (isListening) { return; }
isListening = true;
unsubFunc = Events.eventListener(target, eventName, function() {
if (outputStream.closed) {
detachListener_();
} else {
Util.apply(boundEmit, arguments);
}
});
onClose(outputStream, deta... | javascript | function attachListener_() {
if (isListening) { return; }
isListening = true;
unsubFunc = Events.eventListener(target, eventName, function() {
if (outputStream.closed) {
detachListener_();
} else {
Util.apply(boundEmit, arguments);
}
});
onClose(outputStream, deta... | [
"function",
"attachListener_",
"(",
")",
"{",
"if",
"(",
"isListening",
")",
"{",
"return",
";",
"}",
"isListening",
"=",
"true",
";",
"unsubFunc",
"=",
"Events",
".",
"eventListener",
"(",
"target",
",",
"eventName",
",",
"function",
"(",
")",
"{",
"if"... | Lazily subscribes to a dom event. | [
"Lazily",
"subscribes",
"to",
"a",
"dom",
"event",
"."
] | a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/stream.js#L132-L145 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.