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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
andrewplummer/Sugar | lib/es5.js | defineNativeMethodsOnChainable | function defineNativeMethodsOnChainable() {
var nativeTokens = {
'Function': 'apply,call',
'RegExp': 'compile,exec,test',
'Number': 'toExponential,toFixed,toLocaleString,toPrecision',
'Object': 'hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString',
'Array': 'concat,join,pop,... | javascript | function defineNativeMethodsOnChainable() {
var nativeTokens = {
'Function': 'apply,call',
'RegExp': 'compile,exec,test',
'Number': 'toExponential,toFixed,toLocaleString,toPrecision',
'Object': 'hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString',
'Array': 'concat,join,pop,... | [
"function",
"defineNativeMethodsOnChainable",
"(",
")",
"{",
"var",
"nativeTokens",
"=",
"{",
"'Function'",
":",
"'apply,call'",
",",
"'RegExp'",
":",
"'compile,exec,test'",
",",
"'Number'",
":",
"'toExponential,toFixed,toLocaleString,toPrecision'",
",",
"'Object'",
":",
... | Polyfilled methods will automatically be added to the chainable prototype. However, Object.getOwnPropertyNames cannot be shimmed for non-enumerable properties, so if it does not exist, then the only way to access native methods previous to ES5 is to provide them as a list of tokens here. | [
"Polyfilled",
"methods",
"will",
"automatically",
"be",
"added",
"to",
"the",
"chainable",
"prototype",
".",
"However",
"Object",
".",
"getOwnPropertyNames",
"cannot",
"be",
"shimmed",
"for",
"non",
"-",
"enumerable",
"properties",
"so",
"if",
"it",
"does",
"not... | 4adba2e6ef8c8734a693af3141461dec6d674d50 | https://github.com/andrewplummer/Sugar/blob/4adba2e6ef8c8734a693af3141461dec6d674d50/lib/es5.js#L55-L87 | train |
kentcdodds/nps | src/bin-utils/parser.js | showHelp | function showHelp(specifiedScripts) {
if (parsedArgv.help) {
// if --help was specified, then yargs will show the default help
log.info(help(psConfig))
return true
}
const helpStyle = String(psConfig.options['help-style'])
const hasDefaultScript = Boolean(psConfig.scripts.default)
... | javascript | function showHelp(specifiedScripts) {
if (parsedArgv.help) {
// if --help was specified, then yargs will show the default help
log.info(help(psConfig))
return true
}
const helpStyle = String(psConfig.options['help-style'])
const hasDefaultScript = Boolean(psConfig.scripts.default)
... | [
"function",
"showHelp",
"(",
"specifiedScripts",
")",
"{",
"if",
"(",
"parsedArgv",
".",
"help",
")",
"{",
"// if --help was specified, then yargs will show the default help",
"log",
".",
"info",
"(",
"help",
"(",
"psConfig",
")",
")",
"return",
"true",
"}",
"cons... | util functions eslint-disable-next-line complexity | [
"util",
"functions",
"eslint",
"-",
"disable",
"-",
"next",
"-",
"line",
"complexity"
] | a0c961a2986ebb89d41bcd0f0dd54cada986cd2e | https://github.com/kentcdodds/nps/blob/a0c961a2986ebb89d41bcd0f0dd54cada986cd2e/src/bin-utils/parser.js#L121-L152 | train |
kentcdodds/nps | src/bin-utils/initialize/stringify-object.js | stringifyObject | function stringifyObject(object, indent) {
return Object.keys(object).reduce((string, key, index) => {
const script = object[key]
let value
if (isPlainObject(script)) {
value = `{${stringifyObject(script, `${indent} `)}\n${indent}}`
} else {
value = `'${escapeSingleQuote(script)}'`
}
... | javascript | function stringifyObject(object, indent) {
return Object.keys(object).reduce((string, key, index) => {
const script = object[key]
let value
if (isPlainObject(script)) {
value = `{${stringifyObject(script, `${indent} `)}\n${indent}}`
} else {
value = `'${escapeSingleQuote(script)}'`
}
... | [
"function",
"stringifyObject",
"(",
"object",
",",
"indent",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"object",
")",
".",
"reduce",
"(",
"(",
"string",
",",
"key",
",",
"index",
")",
"=>",
"{",
"const",
"script",
"=",
"object",
"[",
"key",
"]"... | Converts given object to its string representation.
Every line is preceded by given indent.
@param {object} object "Object to convert"
@param {string} indent "Indent to use"
@returns {string} "Stringified and indented object" | [
"Converts",
"given",
"object",
"to",
"its",
"string",
"representation",
".",
"Every",
"line",
"is",
"preceded",
"by",
"given",
"indent",
"."
] | a0c961a2986ebb89d41bcd0f0dd54cada986cd2e | https://github.com/kentcdodds/nps/blob/a0c961a2986ebb89d41bcd0f0dd54cada986cd2e/src/bin-utils/initialize/stringify-object.js#L11-L23 | train |
kentcdodds/nps | src/bin-utils/index.js | loadConfig | function loadConfig(configPath, input) {
let config
if (configPath.endsWith('.yml') || configPath.endsWith('.yaml')) {
config = loadYAMLConfig(configPath)
} else {
config = loadJSConfig(configPath)
}
if (isUndefined(config)) {
// let the caller deal with this
return config
}
let typeMessa... | javascript | function loadConfig(configPath, input) {
let config
if (configPath.endsWith('.yml') || configPath.endsWith('.yaml')) {
config = loadYAMLConfig(configPath)
} else {
config = loadJSConfig(configPath)
}
if (isUndefined(config)) {
// let the caller deal with this
return config
}
let typeMessa... | [
"function",
"loadConfig",
"(",
"configPath",
",",
"input",
")",
"{",
"let",
"config",
"if",
"(",
"configPath",
".",
"endsWith",
"(",
"'.yml'",
")",
"||",
"configPath",
".",
"endsWith",
"(",
"'.yaml'",
")",
")",
"{",
"config",
"=",
"loadYAMLConfig",
"(",
... | Attempts to load the config and logs an error if there's a problem
@param {String} configPath The path to attempt to require the config from
@param {*} input the input to pass to the config if it's a function
@return {Object} The config
eslint-disable-next-line complexity | [
"Attempts",
"to",
"load",
"the",
"config",
"and",
"logs",
"an",
"error",
"if",
"there",
"s",
"a",
"problem"
] | a0c961a2986ebb89d41bcd0f0dd54cada986cd2e | https://github.com/kentcdodds/nps/blob/a0c961a2986ebb89d41bcd0f0dd54cada986cd2e/src/bin-utils/index.js#L67-L112 | train |
jshttp/mime-db | scripts/build.js | addData | function addData (db, mime, source) {
Object.keys(mime).forEach(function (key) {
var data = mime[key]
var type = key.toLowerCase()
var obj = db[type] = db[type] || createTypeEntry(source)
// add missing data
setValue(obj, 'charset', data.charset)
setValue(obj, 'compressible', data.compressibl... | javascript | function addData (db, mime, source) {
Object.keys(mime).forEach(function (key) {
var data = mime[key]
var type = key.toLowerCase()
var obj = db[type] = db[type] || createTypeEntry(source)
// add missing data
setValue(obj, 'charset', data.charset)
setValue(obj, 'compressible', data.compressibl... | [
"function",
"addData",
"(",
"db",
",",
"mime",
",",
"source",
")",
"{",
"Object",
".",
"keys",
"(",
"mime",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"var",
"data",
"=",
"mime",
"[",
"key",
"]",
"var",
"type",
"=",
"key",
".",
... | Add mime data to the db, marked as a given source. | [
"Add",
"mime",
"data",
"to",
"the",
"db",
"marked",
"as",
"a",
"given",
"source",
"."
] | 4db92114124a76a38bf29b7d572d4c7da33a1261 | https://github.com/jshttp/mime-db/blob/4db92114124a76a38bf29b7d572d4c7da33a1261/scripts/build.js#L37-L50 | train |
jshttp/mime-db | scripts/build.js | appendExtension | function appendExtension (obj, extension) {
if (!obj.extensions) {
obj.extensions = []
}
if (obj.extensions.indexOf(extension) === -1) {
obj.extensions.push(extension)
}
} | javascript | function appendExtension (obj, extension) {
if (!obj.extensions) {
obj.extensions = []
}
if (obj.extensions.indexOf(extension) === -1) {
obj.extensions.push(extension)
}
} | [
"function",
"appendExtension",
"(",
"obj",
",",
"extension",
")",
"{",
"if",
"(",
"!",
"obj",
".",
"extensions",
")",
"{",
"obj",
".",
"extensions",
"=",
"[",
"]",
"}",
"if",
"(",
"obj",
".",
"extensions",
".",
"indexOf",
"(",
"extension",
")",
"==="... | Append an extension to an object. | [
"Append",
"an",
"extension",
"to",
"an",
"object",
"."
] | 4db92114124a76a38bf29b7d572d4c7da33a1261 | https://github.com/jshttp/mime-db/blob/4db92114124a76a38bf29b7d572d4c7da33a1261/scripts/build.js#L55-L63 | train |
jshttp/mime-db | scripts/build.js | appendExtensions | function appendExtensions (obj, extensions) {
if (!extensions) {
return
}
for (var i = 0; i < extensions.length; i++) {
var extension = extensions[i]
// add extension to the type entry
appendExtension(obj, extension)
}
} | javascript | function appendExtensions (obj, extensions) {
if (!extensions) {
return
}
for (var i = 0; i < extensions.length; i++) {
var extension = extensions[i]
// add extension to the type entry
appendExtension(obj, extension)
}
} | [
"function",
"appendExtensions",
"(",
"obj",
",",
"extensions",
")",
"{",
"if",
"(",
"!",
"extensions",
")",
"{",
"return",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"extensions",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"extensio... | Append extensions to an object. | [
"Append",
"extensions",
"to",
"an",
"object",
"."
] | 4db92114124a76a38bf29b7d572d4c7da33a1261 | https://github.com/jshttp/mime-db/blob/4db92114124a76a38bf29b7d572d4c7da33a1261/scripts/build.js#L68-L79 | train |
jshttp/mime-db | scripts/build.js | setValue | function setValue (obj, prop, value) {
if (value !== undefined && obj[prop] === undefined) {
obj[prop] = value
}
} | javascript | function setValue (obj, prop, value) {
if (value !== undefined && obj[prop] === undefined) {
obj[prop] = value
}
} | [
"function",
"setValue",
"(",
"obj",
",",
"prop",
",",
"value",
")",
"{",
"if",
"(",
"value",
"!==",
"undefined",
"&&",
"obj",
"[",
"prop",
"]",
"===",
"undefined",
")",
"{",
"obj",
"[",
"prop",
"]",
"=",
"value",
"}",
"}"
] | Set a value on an object, if not already set. | [
"Set",
"a",
"value",
"on",
"an",
"object",
"if",
"not",
"already",
"set",
"."
] | 4db92114124a76a38bf29b7d572d4c7da33a1261 | https://github.com/jshttp/mime-db/blob/4db92114124a76a38bf29b7d572d4c7da33a1261/scripts/build.js#L97-L101 | train |
jshttp/mime-db | scripts/fetch-apache.js | get | function get (url, callback) {
https.get(url, function onResponse (res) {
if (res.statusCode !== 200) {
callback(new Error('got status code ' + res.statusCode + ' from ' + URL))
} else {
getBody(res, true, callback)
}
})
} | javascript | function get (url, callback) {
https.get(url, function onResponse (res) {
if (res.statusCode !== 200) {
callback(new Error('got status code ' + res.statusCode + ' from ' + URL))
} else {
getBody(res, true, callback)
}
})
} | [
"function",
"get",
"(",
"url",
",",
"callback",
")",
"{",
"https",
".",
"get",
"(",
"url",
",",
"function",
"onResponse",
"(",
"res",
")",
"{",
"if",
"(",
"res",
".",
"statusCode",
"!==",
"200",
")",
"{",
"callback",
"(",
"new",
"Error",
"(",
"'got... | Get HTTPS resource. | [
"Get",
"HTTPS",
"resource",
"."
] | 4db92114124a76a38bf29b7d572d4c7da33a1261 | https://github.com/jshttp/mime-db/blob/4db92114124a76a38bf29b7d572d4c7da33a1261/scripts/fetch-apache.js#L88-L96 | train |
allenhwkim/angularjs-google-maps | directives/heatmap-layer.js | parseScope | function parseScope( path, obj ) {
return path.split('.').reduce( function( prev, curr ) {
return prev[curr];
}, obj || this );
} | javascript | function parseScope( path, obj ) {
return path.split('.').reduce( function( prev, curr ) {
return prev[curr];
}, obj || this );
} | [
"function",
"parseScope",
"(",
"path",
",",
"obj",
")",
"{",
"return",
"path",
".",
"split",
"(",
"'.'",
")",
".",
"reduce",
"(",
"function",
"(",
"prev",
",",
"curr",
")",
"{",
"return",
"prev",
"[",
"curr",
"]",
";",
"}",
",",
"obj",
"||",
"thi... | helper get nexted path | [
"helper",
"get",
"nexted",
"path"
] | 8d485a6b3e0b94fa7c78fce9d5b3f101ccd6149c | https://github.com/allenhwkim/angularjs-google-maps/blob/8d485a6b3e0b94fa7c78fce9d5b3f101ccd6149c/directives/heatmap-layer.js#L51-L55 | train |
allenhwkim/angularjs-google-maps | build/scripts/ng-map.debug.js | function(el) {
(el.length > 0) && (el = el[0]);
var orgAttributes = {};
for (var i=0; i<el.attributes.length; i++) {
var attr = el.attributes[i];
orgAttributes[attr.name] = attr.value;
}
return orgAttributes;
} | javascript | function(el) {
(el.length > 0) && (el = el[0]);
var orgAttributes = {};
for (var i=0; i<el.attributes.length; i++) {
var attr = el.attributes[i];
orgAttributes[attr.name] = attr.value;
}
return orgAttributes;
} | [
"function",
"(",
"el",
")",
"{",
"(",
"el",
".",
"length",
">",
"0",
")",
"&&",
"(",
"el",
"=",
"el",
"[",
"0",
"]",
")",
";",
"var",
"orgAttributes",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"el",
".",
"attrib... | Returns the attributes of an element as hash
@memberof Attr2MapOptions
@param {HTMLElement} el html element
@returns {Hash} attributes | [
"Returns",
"the",
"attributes",
"of",
"an",
"element",
"as",
"hash"
] | 8d485a6b3e0b94fa7c78fce9d5b3f101ccd6149c | https://github.com/allenhwkim/angularjs-google-maps/blob/8d485a6b3e0b94fa7c78fce9d5b3f101ccd6149c/build/scripts/ng-map.debug.js#L2519-L2527 | train | |
allenhwkim/angularjs-google-maps | build/scripts/ng-map.debug.js | function(scope, attrs) {
var events = {};
var toLowercaseFunc = function($1){
return "_"+$1.toLowerCase();
};
var EventFunc = function(attrValue) {
// funcName(argsStr)
var matches = attrValue.match(/([^\(]+)\(([^\)]*)\)/);
var funcName = matches[1];
var a... | javascript | function(scope, attrs) {
var events = {};
var toLowercaseFunc = function($1){
return "_"+$1.toLowerCase();
};
var EventFunc = function(attrValue) {
// funcName(argsStr)
var matches = attrValue.match(/([^\(]+)\(([^\)]*)\)/);
var funcName = matches[1];
var a... | [
"function",
"(",
"scope",
",",
"attrs",
")",
"{",
"var",
"events",
"=",
"{",
"}",
";",
"var",
"toLowercaseFunc",
"=",
"function",
"(",
"$1",
")",
"{",
"return",
"\"_\"",
"+",
"$1",
".",
"toLowerCase",
"(",
")",
";",
"}",
";",
"var",
"EventFunc",
"=... | converts attributes hash to scope-specific event function
@memberof Attr2MapOptions
@param {scope} scope angularjs scope
@param {Hash} attrs tag attributes
@returns {Hash} events converted events | [
"converts",
"attributes",
"hash",
"to",
"scope",
"-",
"specific",
"event",
"function"
] | 8d485a6b3e0b94fa7c78fce9d5b3f101ccd6149c | https://github.com/allenhwkim/angularjs-google-maps/blob/8d485a6b3e0b94fa7c78fce9d5b3f101ccd6149c/build/scripts/ng-map.debug.js#L2767-L2805 | train | |
allenhwkim/angularjs-google-maps | build/scripts/ng-map.debug.js | function(filtered) {
var controlOptions = {};
if (typeof filtered != 'object') {
return false;
}
for (var attr in filtered) {
if (filtered[attr]) {
if (!attr.match(/(.*)ControlOptions$/)) {
continue; // if not controlOptions, skip it
}
... | javascript | function(filtered) {
var controlOptions = {};
if (typeof filtered != 'object') {
return false;
}
for (var attr in filtered) {
if (filtered[attr]) {
if (!attr.match(/(.*)ControlOptions$/)) {
continue; // if not controlOptions, skip it
}
... | [
"function",
"(",
"filtered",
")",
"{",
"var",
"controlOptions",
"=",
"{",
"}",
";",
"if",
"(",
"typeof",
"filtered",
"!=",
"'object'",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"var",
"attr",
"in",
"filtered",
")",
"{",
"if",
"(",
"filtered"... | control means map controls, i.e streetview, pan, etc, not a general control
@memberof Attr2MapOptions
@param {Hash} filtered filtered tag attributes
@returns {Hash} Google Map options | [
"control",
"means",
"map",
"controls",
"i",
".",
"e",
"streetview",
"pan",
"etc",
"not",
"a",
"general",
"control"
] | 8d485a6b3e0b94fa7c78fce9d5b3f101ccd6149c | https://github.com/allenhwkim/angularjs-google-maps/blob/8d485a6b3e0b94fa7c78fce9d5b3f101ccd6149c/build/scripts/ng-map.debug.js#L2813-L2871 | train | |
allenhwkim/angularjs-google-maps | build/scripts/ng-map.debug.js | function(map, panoId) {
var svp = new google.maps.StreetViewPanorama(
map.getDiv(), {enableCloseButton: true}
);
svp.setPano(panoId);
} | javascript | function(map, panoId) {
var svp = new google.maps.StreetViewPanorama(
map.getDiv(), {enableCloseButton: true}
);
svp.setPano(panoId);
} | [
"function",
"(",
"map",
",",
"panoId",
")",
"{",
"var",
"svp",
"=",
"new",
"google",
".",
"maps",
".",
"StreetViewPanorama",
"(",
"map",
".",
"getDiv",
"(",
")",
",",
"{",
"enableCloseButton",
":",
"true",
"}",
")",
";",
"svp",
".",
"setPano",
"(",
... | Set panorama view on the given map with the panorama id
@memberof StreetView
@param {map} map Google map instance
@param {String} panoId Panorama id fro getPanorama method
@example
StreetView.setPanorama(map, panoId); | [
"Set",
"panorama",
"view",
"on",
"the",
"given",
"map",
"with",
"the",
"panorama",
"id"
] | 8d485a6b3e0b94fa7c78fce9d5b3f101ccd6149c | https://github.com/allenhwkim/angularjs-google-maps/blob/8d485a6b3e0b94fa7c78fce9d5b3f101ccd6149c/build/scripts/ng-map.debug.js#L3518-L3523 | train | |
zurb/foundation-emails-template | gulpfile.babel.js | pages | function pages() {
return gulp.src(['src/pages/**/*.html', '!src/pages/archive/**/*.html'])
.pipe(panini({
root: 'src/pages',
layouts: 'src/layouts',
partials: 'src/partials',
helpers: 'src/helpers'
}))
.pipe(inky())
.pipe(gulp.dest('dist'));
} | javascript | function pages() {
return gulp.src(['src/pages/**/*.html', '!src/pages/archive/**/*.html'])
.pipe(panini({
root: 'src/pages',
layouts: 'src/layouts',
partials: 'src/partials',
helpers: 'src/helpers'
}))
.pipe(inky())
.pipe(gulp.dest('dist'));
} | [
"function",
"pages",
"(",
")",
"{",
"return",
"gulp",
".",
"src",
"(",
"[",
"'src/pages/**/*.html'",
",",
"'!src/pages/archive/**/*.html'",
"]",
")",
".",
"pipe",
"(",
"panini",
"(",
"{",
"root",
":",
"'src/pages'",
",",
"layouts",
":",
"'src/layouts'",
",",... | Compile layouts, pages, and partials into flat HTML files Then parse using Inky templates | [
"Compile",
"layouts",
"pages",
"and",
"partials",
"into",
"flat",
"HTML",
"files",
"Then",
"parse",
"using",
"Inky",
"templates"
] | 2f0cfa9a978ad7ced4ee3de33366224a90168724 | https://github.com/zurb/foundation-emails-template/blob/2f0cfa9a978ad7ced4ee3de33366224a90168724/gulpfile.babel.js#L53-L63 | train |
zurb/foundation-emails-template | gulpfile.babel.js | sass | function sass() {
return gulp.src('src/assets/scss/app.scss')
.pipe($.if(!PRODUCTION, $.sourcemaps.init()))
.pipe($.sass({
includePaths: ['node_modules/foundation-emails/scss']
}).on('error', $.sass.logError))
.pipe($.if(PRODUCTION, $.uncss(
{
html: ['dist/**/*.html']
})))
... | javascript | function sass() {
return gulp.src('src/assets/scss/app.scss')
.pipe($.if(!PRODUCTION, $.sourcemaps.init()))
.pipe($.sass({
includePaths: ['node_modules/foundation-emails/scss']
}).on('error', $.sass.logError))
.pipe($.if(PRODUCTION, $.uncss(
{
html: ['dist/**/*.html']
})))
... | [
"function",
"sass",
"(",
")",
"{",
"return",
"gulp",
".",
"src",
"(",
"'src/assets/scss/app.scss'",
")",
".",
"pipe",
"(",
"$",
".",
"if",
"(",
"!",
"PRODUCTION",
",",
"$",
".",
"sourcemaps",
".",
"init",
"(",
")",
")",
")",
".",
"pipe",
"(",
"$",
... | Compile Sass into CSS | [
"Compile",
"Sass",
"into",
"CSS"
] | 2f0cfa9a978ad7ced4ee3de33366224a90168724 | https://github.com/zurb/foundation-emails-template/blob/2f0cfa9a978ad7ced4ee3de33366224a90168724/gulpfile.babel.js#L72-L84 | train |
zurb/foundation-emails-template | gulpfile.babel.js | watch | function watch() {
gulp.watch('src/pages/**/*.html').on('all', gulp.series(pages, inline, browser.reload));
gulp.watch(['src/layouts/**/*', 'src/partials/**/*']).on('all', gulp.series(resetPages, pages, inline, browser.reload));
gulp.watch(['../scss/**/*.scss', 'src/assets/scss/**/*.scss']).on('all', gulp.series(... | javascript | function watch() {
gulp.watch('src/pages/**/*.html').on('all', gulp.series(pages, inline, browser.reload));
gulp.watch(['src/layouts/**/*', 'src/partials/**/*']).on('all', gulp.series(resetPages, pages, inline, browser.reload));
gulp.watch(['../scss/**/*.scss', 'src/assets/scss/**/*.scss']).on('all', gulp.series(... | [
"function",
"watch",
"(",
")",
"{",
"gulp",
".",
"watch",
"(",
"'src/pages/**/*.html'",
")",
".",
"on",
"(",
"'all'",
",",
"gulp",
".",
"series",
"(",
"pages",
",",
"inline",
",",
"browser",
".",
"reload",
")",
")",
";",
"gulp",
".",
"watch",
"(",
... | Watch for file changes | [
"Watch",
"for",
"file",
"changes"
] | 2f0cfa9a978ad7ced4ee3de33366224a90168724 | https://github.com/zurb/foundation-emails-template/blob/2f0cfa9a978ad7ced4ee3de33366224a90168724/gulpfile.babel.js#L109-L114 | train |
zurb/foundation-emails-template | gulpfile.babel.js | creds | function creds(done) {
var configPath = './config.json';
try { CONFIG = JSON.parse(fs.readFileSync(configPath)); }
catch(e) {
beep();
console.log('[AWS]'.bold.red + ' Sorry, there was an issue locating your config.json. Please see README.md');
process.exit();
}
done();
} | javascript | function creds(done) {
var configPath = './config.json';
try { CONFIG = JSON.parse(fs.readFileSync(configPath)); }
catch(e) {
beep();
console.log('[AWS]'.bold.red + ' Sorry, there was an issue locating your config.json. Please see README.md');
process.exit();
}
done();
} | [
"function",
"creds",
"(",
"done",
")",
"{",
"var",
"configPath",
"=",
"'./config.json'",
";",
"try",
"{",
"CONFIG",
"=",
"JSON",
".",
"parse",
"(",
"fs",
".",
"readFileSync",
"(",
"configPath",
")",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"beep",... | Ensure creds for Litmus are at least there. | [
"Ensure",
"creds",
"for",
"Litmus",
"are",
"at",
"least",
"there",
"."
] | 2f0cfa9a978ad7ced4ee3de33366224a90168724 | https://github.com/zurb/foundation-emails-template/blob/2f0cfa9a978ad7ced4ee3de33366224a90168724/gulpfile.babel.js#L139-L148 | train |
zurb/foundation-emails-template | gulpfile.babel.js | aws | function aws() {
var publisher = !!CONFIG.aws ? $.awspublish.create(CONFIG.aws) : $.awspublish.create();
var headers = {
'Cache-Control': 'max-age=315360000, no-transform, public'
};
return gulp.src('./dist/assets/img/*')
// publisher will add Content-Length, Content-Type and headers specified above
... | javascript | function aws() {
var publisher = !!CONFIG.aws ? $.awspublish.create(CONFIG.aws) : $.awspublish.create();
var headers = {
'Cache-Control': 'max-age=315360000, no-transform, public'
};
return gulp.src('./dist/assets/img/*')
// publisher will add Content-Length, Content-Type and headers specified above
... | [
"function",
"aws",
"(",
")",
"{",
"var",
"publisher",
"=",
"!",
"!",
"CONFIG",
".",
"aws",
"?",
"$",
".",
"awspublish",
".",
"create",
"(",
"CONFIG",
".",
"aws",
")",
":",
"$",
".",
"awspublish",
".",
"create",
"(",
")",
";",
"var",
"headers",
"=... | Post images to AWS S3 so they are accessible to Litmus and manual test | [
"Post",
"images",
"to",
"AWS",
"S3",
"so",
"they",
"are",
"accessible",
"to",
"Litmus",
"and",
"manual",
"test"
] | 2f0cfa9a978ad7ced4ee3de33366224a90168724 | https://github.com/zurb/foundation-emails-template/blob/2f0cfa9a978ad7ced4ee3de33366224a90168724/gulpfile.babel.js#L151-L167 | train |
zurb/foundation-emails-template | gulpfile.babel.js | litmus | function litmus() {
var awsURL = !!CONFIG && !!CONFIG.aws && !!CONFIG.aws.url ? CONFIG.aws.url : false;
return gulp.src('dist/**/*.html')
.pipe($.if(!!awsURL, $.replace(/=('|")(\/?assets\/img)/g, "=$1"+ awsURL)))
.pipe($.litmus(CONFIG.litmus))
.pipe(gulp.dest('dist'));
} | javascript | function litmus() {
var awsURL = !!CONFIG && !!CONFIG.aws && !!CONFIG.aws.url ? CONFIG.aws.url : false;
return gulp.src('dist/**/*.html')
.pipe($.if(!!awsURL, $.replace(/=('|")(\/?assets\/img)/g, "=$1"+ awsURL)))
.pipe($.litmus(CONFIG.litmus))
.pipe(gulp.dest('dist'));
} | [
"function",
"litmus",
"(",
")",
"{",
"var",
"awsURL",
"=",
"!",
"!",
"CONFIG",
"&&",
"!",
"!",
"CONFIG",
".",
"aws",
"&&",
"!",
"!",
"CONFIG",
".",
"aws",
".",
"url",
"?",
"CONFIG",
".",
"aws",
".",
"url",
":",
"false",
";",
"return",
"gulp",
"... | Send email to Litmus for testing. If no AWS creds then do not replace img urls. | [
"Send",
"email",
"to",
"Litmus",
"for",
"testing",
".",
"If",
"no",
"AWS",
"creds",
"then",
"do",
"not",
"replace",
"img",
"urls",
"."
] | 2f0cfa9a978ad7ced4ee3de33366224a90168724 | https://github.com/zurb/foundation-emails-template/blob/2f0cfa9a978ad7ced4ee3de33366224a90168724/gulpfile.babel.js#L170-L177 | train |
zurb/foundation-emails-template | gulpfile.babel.js | mail | function mail() {
var awsURL = !!CONFIG && !!CONFIG.aws && !!CONFIG.aws.url ? CONFIG.aws.url : false;
if (EMAIL) {
CONFIG.mail.to = [EMAIL];
}
return gulp.src('dist/**/*.html')
.pipe($.if(!!awsURL, $.replace(/=('|")(\/?assets\/img)/g, "=$1"+ awsURL)))
.pipe($.mail(CONFIG.mail))
.pipe(gulp.dest... | javascript | function mail() {
var awsURL = !!CONFIG && !!CONFIG.aws && !!CONFIG.aws.url ? CONFIG.aws.url : false;
if (EMAIL) {
CONFIG.mail.to = [EMAIL];
}
return gulp.src('dist/**/*.html')
.pipe($.if(!!awsURL, $.replace(/=('|")(\/?assets\/img)/g, "=$1"+ awsURL)))
.pipe($.mail(CONFIG.mail))
.pipe(gulp.dest... | [
"function",
"mail",
"(",
")",
"{",
"var",
"awsURL",
"=",
"!",
"!",
"CONFIG",
"&&",
"!",
"!",
"CONFIG",
".",
"aws",
"&&",
"!",
"!",
"CONFIG",
".",
"aws",
".",
"url",
"?",
"CONFIG",
".",
"aws",
".",
"url",
":",
"false",
";",
"if",
"(",
"EMAIL",
... | Send email to specified email for testing. If no AWS creds then do not replace img urls. | [
"Send",
"email",
"to",
"specified",
"email",
"for",
"testing",
".",
"If",
"no",
"AWS",
"creds",
"then",
"do",
"not",
"replace",
"img",
"urls",
"."
] | 2f0cfa9a978ad7ced4ee3de33366224a90168724 | https://github.com/zurb/foundation-emails-template/blob/2f0cfa9a978ad7ced4ee3de33366224a90168724/gulpfile.babel.js#L180-L191 | train |
zurb/foundation-emails-template | gulpfile.babel.js | zip | function zip() {
var dist = 'dist';
var ext = '.html';
function getHtmlFiles(dir) {
return fs.readdirSync(dir)
.filter(function(file) {
var fileExt = path.join(dir, file);
var isHtml = path.extname(fileExt) == ext;
return fs.statSync(fileExt).isFile() && isHtml;
});
}
... | javascript | function zip() {
var dist = 'dist';
var ext = '.html';
function getHtmlFiles(dir) {
return fs.readdirSync(dir)
.filter(function(file) {
var fileExt = path.join(dir, file);
var isHtml = path.extname(fileExt) == ext;
return fs.statSync(fileExt).isFile() && isHtml;
});
}
... | [
"function",
"zip",
"(",
")",
"{",
"var",
"dist",
"=",
"'dist'",
";",
"var",
"ext",
"=",
"'.html'",
";",
"function",
"getHtmlFiles",
"(",
"dir",
")",
"{",
"return",
"fs",
".",
"readdirSync",
"(",
"dir",
")",
".",
"filter",
"(",
"function",
"(",
"file"... | Copy and compress into Zip | [
"Copy",
"and",
"compress",
"into",
"Zip"
] | 2f0cfa9a978ad7ced4ee3de33366224a90168724 | https://github.com/zurb/foundation-emails-template/blob/2f0cfa9a978ad7ced4ee3de33366224a90168724/gulpfile.babel.js#L194-L232 | train |
sandywalker/webui-popover | dist/jquery.webui-popover.js | function() {
if (this.$element[0] instanceof document.constructor && !this.options.selector) {
throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!');
}
if (this.getTrigger() !== 'manu... | javascript | function() {
if (this.$element[0] instanceof document.constructor && !this.options.selector) {
throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!');
}
if (this.getTrigger() !== 'manu... | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"$element",
"[",
"0",
"]",
"instanceof",
"document",
".",
"constructor",
"&&",
"!",
"this",
".",
"options",
".",
"selector",
")",
"{",
"throw",
"new",
"Error",
"(",
"'`selector` option must be specified when... | init webui popover | [
"init",
"webui",
"popover"
] | b02d6ba8ea9d2ced5ce0333d7ddb1eec6f9eb3ae | https://github.com/sandywalker/webui-popover/blob/b02d6ba8ea9d2ced5ce0333d7ddb1eec6f9eb3ae/dist/jquery.webui-popover.js#L166-L206 | train | |
a8m/angular-filter | src/_filter/collection/unique.js | some | function some(array, member) {
if(isUndefined(member)) {
return false;
}
return array.some(function(el) {
return equals(el, member);
});
} | javascript | function some(array, member) {
if(isUndefined(member)) {
return false;
}
return array.some(function(el) {
return equals(el, member);
});
} | [
"function",
"some",
"(",
"array",
",",
"member",
")",
"{",
"if",
"(",
"isUndefined",
"(",
"member",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"array",
".",
"some",
"(",
"function",
"(",
"el",
")",
"{",
"return",
"equals",
"(",
"el",
","... | checked if the unique identifier is already exist | [
"checked",
"if",
"the",
"unique",
"identifier",
"is",
"already",
"exist"
] | 0bc1607f2468bf003a8419718f42f310b1445bd9 | https://github.com/a8m/angular-filter/blob/0bc1607f2468bf003a8419718f42f310b1445bd9/src/_filter/collection/unique.js#L47-L54 | train |
a8m/angular-filter | src/_common.js | indexOf | function indexOf(word, p, c) {
var j = 0;
while ((p + j) <= word.length) {
if (word.charAt(p + j) == c) return j;
j++;
}
return -1;
} | javascript | function indexOf(word, p, c) {
var j = 0;
while ((p + j) <= word.length) {
if (word.charAt(p + j) == c) return j;
j++;
}
return -1;
} | [
"function",
"indexOf",
"(",
"word",
",",
"p",
",",
"c",
")",
"{",
"var",
"j",
"=",
"0",
";",
"while",
"(",
"(",
"p",
"+",
"j",
")",
"<=",
"word",
".",
"length",
")",
"{",
"if",
"(",
"word",
".",
"charAt",
"(",
"p",
"+",
"j",
")",
"==",
"c... | cheaper version of indexOf; instead of creating each iteration new str. | [
"cheaper",
"version",
"of",
"indexOf",
";",
"instead",
"of",
"creating",
"each",
"iteration",
"new",
"str",
"."
] | 0bc1607f2468bf003a8419718f42f310b1445bd9 | https://github.com/a8m/angular-filter/blob/0bc1607f2468bf003a8419718f42f310b1445bd9/src/_common.js#L65-L72 | train |
css/csso | lib/restructure/utils.js | hasSimilarSelectors | function hasSimilarSelectors(selectors1, selectors2) {
var cursor1 = selectors1.head;
while (cursor1 !== null) {
var cursor2 = selectors2.head;
while (cursor2 !== null) {
if (cursor1.data.compareMarker === cursor2.data.compareMarker) {
return true;
}
... | javascript | function hasSimilarSelectors(selectors1, selectors2) {
var cursor1 = selectors1.head;
while (cursor1 !== null) {
var cursor2 = selectors2.head;
while (cursor2 !== null) {
if (cursor1.data.compareMarker === cursor2.data.compareMarker) {
return true;
}
... | [
"function",
"hasSimilarSelectors",
"(",
"selectors1",
",",
"selectors2",
")",
"{",
"var",
"cursor1",
"=",
"selectors1",
".",
"head",
";",
"while",
"(",
"cursor1",
"!==",
"null",
")",
"{",
"var",
"cursor2",
"=",
"selectors2",
".",
"head",
";",
"while",
"(",... | check if simpleselectors has no equal specificity and element selector | [
"check",
"if",
"simpleselectors",
"has",
"no",
"equal",
"specificity",
"and",
"element",
"selector"
] | 3f2ce359996e28548ee1ba48e35640f311137b3f | https://github.com/css/csso/blob/3f2ce359996e28548ee1ba48e35640f311137b3f/lib/restructure/utils.js#L101-L119 | train |
css/csso | lib/restructure/utils.js | unsafeToSkipNode | function unsafeToSkipNode(node) {
switch (node.type) {
case 'Rule':
// unsafe skip ruleset with selector similarities
return hasSimilarSelectors(node.prelude.children, this);
case 'Atrule':
// can skip at-rules with blocks
if (node.block) {
... | javascript | function unsafeToSkipNode(node) {
switch (node.type) {
case 'Rule':
// unsafe skip ruleset with selector similarities
return hasSimilarSelectors(node.prelude.children, this);
case 'Atrule':
// can skip at-rules with blocks
if (node.block) {
... | [
"function",
"unsafeToSkipNode",
"(",
"node",
")",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"case",
"'Rule'",
":",
"// unsafe skip ruleset with selector similarities",
"return",
"hasSimilarSelectors",
"(",
"node",
".",
"prelude",
".",
"children",
",",
"th... | test node can't to be skipped | [
"test",
"node",
"can",
"t",
"to",
"be",
"skipped"
] | 3f2ce359996e28548ee1ba48e35640f311137b3f | https://github.com/css/csso/blob/3f2ce359996e28548ee1ba48e35640f311137b3f/lib/restructure/utils.js#L122-L142 | train |
SupremeTechnopriest/react-idle-timer | src/index.js | throttled | function throttled (fn, delay) {
let lastCall = 0
return function (...args) {
const now = new Date().getTime()
if (now - lastCall < delay) {
return
}
lastCall = now
return fn(...args)
}
} | javascript | function throttled (fn, delay) {
let lastCall = 0
return function (...args) {
const now = new Date().getTime()
if (now - lastCall < delay) {
return
}
lastCall = now
return fn(...args)
}
} | [
"function",
"throttled",
"(",
"fn",
",",
"delay",
")",
"{",
"let",
"lastCall",
"=",
"0",
"return",
"function",
"(",
"...",
"args",
")",
"{",
"const",
"now",
"=",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
"if",
"(",
"now",
"-",
"lastCall",
... | Creates a throttled function that only invokes func at most
once per every wait milliseconds.
@name throttled
@param {Function} fn Function to debounce
@param {Number} delay How long to wait
@return {Function} Executed Function | [
"Creates",
"a",
"throttled",
"function",
"that",
"only",
"invokes",
"func",
"at",
"most",
"once",
"per",
"every",
"wait",
"milliseconds",
"."
] | 5cb71957dd3b1bbe27e475b31898f1673856e8dd | https://github.com/SupremeTechnopriest/react-idle-timer/blob/5cb71957dd3b1bbe27e475b31898f1673856e8dd/src/index.js#L586-L596 | train |
yaacov/node-modbus-serial | ports/rtubufferedport.js | function(path, options) {
var self = this;
// options
if (typeof(options) === "undefined") options = {};
// disable auto open, as we handle the open
options.autoOpen = false;
// internal buffer
this._buffer = Buffer.alloc(0);
this._id = 0;
this._cmd = 0;
this._length = 0;
... | javascript | function(path, options) {
var self = this;
// options
if (typeof(options) === "undefined") options = {};
// disable auto open, as we handle the open
options.autoOpen = false;
// internal buffer
this._buffer = Buffer.alloc(0);
this._id = 0;
this._cmd = 0;
this._length = 0;
... | [
"function",
"(",
"path",
",",
"options",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// options",
"if",
"(",
"typeof",
"(",
"options",
")",
"===",
"\"undefined\"",
")",
"options",
"=",
"{",
"}",
";",
"// disable auto open, as we handle the open",
"options",
... | Simulate a modbus-RTU port using buffered serial connection.
@param path
@param options
@constructor | [
"Simulate",
"a",
"modbus",
"-",
"RTU",
"port",
"using",
"buffered",
"serial",
"connection",
"."
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/ports/rtubufferedport.js#L20-L93 | train | |
yaacov/node-modbus-serial | examples/logger.js | checkError | function checkError(e) {
if(e.errno && networkErrors.includes(e.errno)) {
console.log("we have to reconnect");
// close port
client.close();
// re open client
client = new ModbusRTU();
timeoutConnectRef = setTimeout(connect, 1000);
}
} | javascript | function checkError(e) {
if(e.errno && networkErrors.includes(e.errno)) {
console.log("we have to reconnect");
// close port
client.close();
// re open client
client = new ModbusRTU();
timeoutConnectRef = setTimeout(connect, 1000);
}
} | [
"function",
"checkError",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"errno",
"&&",
"networkErrors",
".",
"includes",
"(",
"e",
".",
"errno",
")",
")",
"{",
"console",
".",
"log",
"(",
"\"we have to reconnect\"",
")",
";",
"// close port",
"client",
".",
... | check error, and reconnect if needed | [
"check",
"error",
"and",
"reconnect",
"if",
"needed"
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/examples/logger.js#L13-L24 | train |
yaacov/node-modbus-serial | examples/logger.js | connect | function connect() {
// clear pending timeouts
clearTimeout(timeoutConnectRef);
// if client already open, just run
if (client.isOpen) {
run();
}
// if client closed, open a new connection
client.connectTCP("127.0.0.1", { port: 8502 })
.then(setClient)
.then(functio... | javascript | function connect() {
// clear pending timeouts
clearTimeout(timeoutConnectRef);
// if client already open, just run
if (client.isOpen) {
run();
}
// if client closed, open a new connection
client.connectTCP("127.0.0.1", { port: 8502 })
.then(setClient)
.then(functio... | [
"function",
"connect",
"(",
")",
"{",
"// clear pending timeouts",
"clearTimeout",
"(",
"timeoutConnectRef",
")",
";",
"// if client already open, just run",
"if",
"(",
"client",
".",
"isOpen",
")",
"{",
"run",
"(",
")",
";",
"}",
"// if client closed, open a new conn... | open connection to a serial port | [
"open",
"connection",
"to",
"a",
"serial",
"port"
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/examples/logger.js#L27-L44 | train |
yaacov/node-modbus-serial | ports/asciiport.js | _asciiEncodeRequestBuffer | function _asciiEncodeRequestBuffer(buf) {
// replace the 2 byte crc16 with a single byte lrc
buf.writeUInt8(calculateLrc(buf.slice(0, -2)), buf.length - 2);
// create a new buffer of the correct size
var bufAscii = Buffer.alloc(buf.length * 2 + 1); // 1 byte start delimit + x2 data as ascii encoded + ... | javascript | function _asciiEncodeRequestBuffer(buf) {
// replace the 2 byte crc16 with a single byte lrc
buf.writeUInt8(calculateLrc(buf.slice(0, -2)), buf.length - 2);
// create a new buffer of the correct size
var bufAscii = Buffer.alloc(buf.length * 2 + 1); // 1 byte start delimit + x2 data as ascii encoded + ... | [
"function",
"_asciiEncodeRequestBuffer",
"(",
"buf",
")",
"{",
"// replace the 2 byte crc16 with a single byte lrc",
"buf",
".",
"writeUInt8",
"(",
"calculateLrc",
"(",
"buf",
".",
"slice",
"(",
"0",
",",
"-",
"2",
")",
")",
",",
"buf",
".",
"length",
"-",
"2"... | Ascii encode a 'request' buffer and return it. This includes removing
the CRC bytes and replacing them with an LRC.
@param {Buffer} buf the data buffer to encode.
@return {Buffer} the ascii encoded buffer
@private | [
"Ascii",
"encode",
"a",
"request",
"buffer",
"and",
"return",
"it",
".",
"This",
"includes",
"removing",
"the",
"CRC",
"bytes",
"and",
"replacing",
"them",
"with",
"an",
"LRC",
"."
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/ports/asciiport.js#L22-L41 | train |
yaacov/node-modbus-serial | ports/asciiport.js | _asciiDecodeResponseBuffer | function _asciiDecodeResponseBuffer(bufAscii) {
// create a new buffer of the correct size (based on ascii encoded buffer length)
var bufDecoded = Buffer.alloc((bufAscii.length - 1) / 2);
// decode into new buffer (removing delimiters at start and end)
for (var i = 0; i < (bufAscii.length - 3) / 2; i+... | javascript | function _asciiDecodeResponseBuffer(bufAscii) {
// create a new buffer of the correct size (based on ascii encoded buffer length)
var bufDecoded = Buffer.alloc((bufAscii.length - 1) / 2);
// decode into new buffer (removing delimiters at start and end)
for (var i = 0; i < (bufAscii.length - 3) / 2; i+... | [
"function",
"_asciiDecodeResponseBuffer",
"(",
"bufAscii",
")",
"{",
"// create a new buffer of the correct size (based on ascii encoded buffer length)",
"var",
"bufDecoded",
"=",
"Buffer",
".",
"alloc",
"(",
"(",
"bufAscii",
".",
"length",
"-",
"1",
")",
"/",
"2",
")",... | Ascii decode a 'response' buffer and return it.
@param {Buffer} bufAscii the ascii data buffer to decode.
@return {Buffer} the decoded buffer, or null if decode error
@private | [
"Ascii",
"decode",
"a",
"response",
"buffer",
"and",
"return",
"it",
"."
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/ports/asciiport.js#L50-L74 | train |
yaacov/node-modbus-serial | ports/asciiport.js | _checkData | function _checkData(modbus, buf) {
// check buffer size
if (buf.length !== modbus._length && buf.length !== 5) {
modbusSerialDebug({ action: "length error", recive: buf.length, expected: modbus._length });
return false;
}
// check buffer unit-id and command
return (buf[0] === modbu... | javascript | function _checkData(modbus, buf) {
// check buffer size
if (buf.length !== modbus._length && buf.length !== 5) {
modbusSerialDebug({ action: "length error", recive: buf.length, expected: modbus._length });
return false;
}
// check buffer unit-id and command
return (buf[0] === modbu... | [
"function",
"_checkData",
"(",
"modbus",
",",
"buf",
")",
"{",
"// check buffer size",
"if",
"(",
"buf",
".",
"length",
"!==",
"modbus",
".",
"_length",
"&&",
"buf",
".",
"length",
"!==",
"5",
")",
"{",
"modbusSerialDebug",
"(",
"{",
"action",
":",
"\"le... | check if a buffer chunk can be a modbus answer
or modbus exception
@param {AsciiPort} modbus
@param {Buffer} buf the buffer to check.
@return {boolean} if the buffer can be an answer
@private | [
"check",
"if",
"a",
"buffer",
"chunk",
"can",
"be",
"a",
"modbus",
"answer",
"or",
"modbus",
"exception"
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/ports/asciiport.js#L85-L96 | train |
yaacov/node-modbus-serial | ports/asciiport.js | function(path, options) {
var modbus = this;
// options
options = options || {};
// disable auto open, as we handle the open
options.autoOpen = false;
// internal buffer
this._buffer = Buffer.from("");
this._id = 0;
this._cmd = 0;
this._length = 0;
// create the SerialPor... | javascript | function(path, options) {
var modbus = this;
// options
options = options || {};
// disable auto open, as we handle the open
options.autoOpen = false;
// internal buffer
this._buffer = Buffer.from("");
this._id = 0;
this._cmd = 0;
this._length = 0;
// create the SerialPor... | [
"function",
"(",
"path",
",",
"options",
")",
"{",
"var",
"modbus",
"=",
"this",
";",
"// options",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"// disable auto open, as we handle the open",
"options",
".",
"autoOpen",
"=",
"false",
";",
"// internal buffer"... | Simulate a modbus-ascii port using serial connection.
@param path
@param options
@constructor | [
"Simulate",
"a",
"modbus",
"-",
"ascii",
"port",
"using",
"serial",
"connection",
"."
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/ports/asciiport.js#L105-L185 | train | |
yaacov/node-modbus-serial | index.js | _startTimeout | function _startTimeout(duration, transaction) {
if (!duration) {
return undefined;
}
return setTimeout(function() {
transaction._timeoutFired = true;
if (transaction.next) {
transaction.next(new TransactionTimedOutError());
}
}, duration);
} | javascript | function _startTimeout(duration, transaction) {
if (!duration) {
return undefined;
}
return setTimeout(function() {
transaction._timeoutFired = true;
if (transaction.next) {
transaction.next(new TransactionTimedOutError());
}
}, duration);
} | [
"function",
"_startTimeout",
"(",
"duration",
",",
"transaction",
")",
"{",
"if",
"(",
"!",
"duration",
")",
"{",
"return",
"undefined",
";",
"}",
"return",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"transaction",
".",
"_timeoutFired",
"=",
"true",
";"... | Starts the timeout timer with the given duration.
If the timeout ends before it was cancelled, it will call the callback with an error.
@param {number} duration the timeout duration in milliseconds.
@param {Function} next the function to call next.
@return {number} The handle of the timeout
@private | [
"Starts",
"the",
"timeout",
"timer",
"with",
"the",
"given",
"duration",
".",
"If",
"the",
"timeout",
"ends",
"before",
"it",
"was",
"cancelled",
"it",
"will",
"call",
"the",
"callback",
"with",
"an",
"error",
"."
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/index.js#L174-L184 | train |
yaacov/node-modbus-serial | servers/servertcp_handler.js | _handlePromiseOrValue | function _handlePromiseOrValue(promiseOrValue, cb) {
if (promiseOrValue && promiseOrValue.then && typeof promiseOrValue.then === "function") {
promiseOrValue
.then(function(value) {
cb(null, value);
})
.catch(function(err) {
cb(err);
... | javascript | function _handlePromiseOrValue(promiseOrValue, cb) {
if (promiseOrValue && promiseOrValue.then && typeof promiseOrValue.then === "function") {
promiseOrValue
.then(function(value) {
cb(null, value);
})
.catch(function(err) {
cb(err);
... | [
"function",
"_handlePromiseOrValue",
"(",
"promiseOrValue",
",",
"cb",
")",
"{",
"if",
"(",
"promiseOrValue",
"&&",
"promiseOrValue",
".",
"then",
"&&",
"typeof",
"promiseOrValue",
".",
"then",
"===",
"\"function\"",
")",
"{",
"promiseOrValue",
".",
"then",
"(",... | Handle the callback invocation for Promises or synchronous values
@param promiseOrValue - the Promise to be resolved or value to be returned
@param cb - the callback to be invoked
@returns undefined
@private | [
"Handle",
"the",
"callback",
"invocation",
"for",
"Promises",
"or",
"synchronous",
"values"
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/servers/servertcp_handler.js#L45-L57 | train |
yaacov/node-modbus-serial | servers/servertcp_handler.js | _handleReadCoilsOrInputDiscretes | function _handleReadCoilsOrInputDiscretes(requestBuffer, vector, unitID, callback, fc) {
var address = requestBuffer.readUInt16BE(2);
var length = requestBuffer.readUInt16BE(4);
if (_errorRequestBufferLength(requestBuffer)) {
return;
}
// build answer
var dataBytes = parseInt((length -... | javascript | function _handleReadCoilsOrInputDiscretes(requestBuffer, vector, unitID, callback, fc) {
var address = requestBuffer.readUInt16BE(2);
var length = requestBuffer.readUInt16BE(4);
if (_errorRequestBufferLength(requestBuffer)) {
return;
}
// build answer
var dataBytes = parseInt((length -... | [
"function",
"_handleReadCoilsOrInputDiscretes",
"(",
"requestBuffer",
",",
"vector",
",",
"unitID",
",",
"callback",
",",
"fc",
")",
"{",
"var",
"address",
"=",
"requestBuffer",
".",
"readUInt16BE",
"(",
"2",
")",
";",
"var",
"length",
"=",
"requestBuffer",
".... | Function to handle FC1 or FC2 request.
@param requestBuffer - request Buffer from client
@param vector - vector of functions for read and write
@param unitID - Id of the requesting unit
@param {function} callback - callback to be invoked passing {Buffer} response
@returns undefined
@private | [
"Function",
"to",
"handle",
"FC1",
"or",
"FC2",
"request",
"."
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/servers/servertcp_handler.js#L70-L145 | train |
yaacov/node-modbus-serial | servers/servertcp_handler.js | _handleWriteCoil | function _handleWriteCoil(requestBuffer, vector, unitID, callback) {
var address = requestBuffer.readUInt16BE(2);
var state = requestBuffer.readUInt16BE(4);
if (_errorRequestBufferLength(requestBuffer)) {
return;
}
// build answer
var responseBuffer = Buffer.alloc(8);
responseBuffe... | javascript | function _handleWriteCoil(requestBuffer, vector, unitID, callback) {
var address = requestBuffer.readUInt16BE(2);
var state = requestBuffer.readUInt16BE(4);
if (_errorRequestBufferLength(requestBuffer)) {
return;
}
// build answer
var responseBuffer = Buffer.alloc(8);
responseBuffe... | [
"function",
"_handleWriteCoil",
"(",
"requestBuffer",
",",
"vector",
",",
"unitID",
",",
"callback",
")",
"{",
"var",
"address",
"=",
"requestBuffer",
".",
"readUInt16BE",
"(",
"2",
")",
";",
"var",
"state",
"=",
"requestBuffer",
".",
"readUInt16BE",
"(",
"4... | Function to handle FC5 request.
@param requestBuffer - request Buffer from client
@param vector - vector of functions for read and write
@param unitID - Id of the requesting unit
@param {function} callback - callback to be invoked passing {Buffer} response
@returns undefined
@private | [
"Function",
"to",
"handle",
"FC5",
"request",
"."
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/servers/servertcp_handler.js#L408-L454 | train |
yaacov/node-modbus-serial | servers/servertcp_handler.js | _handleWriteSingleRegister | function _handleWriteSingleRegister(requestBuffer, vector, unitID, callback) {
var address = requestBuffer.readUInt16BE(2);
var value = requestBuffer.readUInt16BE(4);
if (_errorRequestBufferLength(requestBuffer)) {
return;
}
// build answer
var responseBuffer = Buffer.alloc(8);
res... | javascript | function _handleWriteSingleRegister(requestBuffer, vector, unitID, callback) {
var address = requestBuffer.readUInt16BE(2);
var value = requestBuffer.readUInt16BE(4);
if (_errorRequestBufferLength(requestBuffer)) {
return;
}
// build answer
var responseBuffer = Buffer.alloc(8);
res... | [
"function",
"_handleWriteSingleRegister",
"(",
"requestBuffer",
",",
"vector",
",",
"unitID",
",",
"callback",
")",
"{",
"var",
"address",
"=",
"requestBuffer",
".",
"readUInt16BE",
"(",
"2",
")",
";",
"var",
"value",
"=",
"requestBuffer",
".",
"readUInt16BE",
... | Function to handle FC6 request.
@param requestBuffer - request Buffer from client
@param vector - vector of functions for read and write
@param unitID - Id of the requesting unit
@param {function} callback - callback to be invoked passing {Buffer} response
@returns undefined
@private | [
"Function",
"to",
"handle",
"FC6",
"request",
"."
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/servers/servertcp_handler.js#L466-L511 | train |
yaacov/node-modbus-serial | servers/servertcp_handler.js | _handleForceMultipleCoils | function _handleForceMultipleCoils(requestBuffer, vector, unitID, callback) {
var address = requestBuffer.readUInt16BE(2);
var length = requestBuffer.readUInt16BE(4);
// if length is bad, ignore message
if (requestBuffer.length !== 7 + Math.ceil(length / 8) + 2) {
return;
}
// build an... | javascript | function _handleForceMultipleCoils(requestBuffer, vector, unitID, callback) {
var address = requestBuffer.readUInt16BE(2);
var length = requestBuffer.readUInt16BE(4);
// if length is bad, ignore message
if (requestBuffer.length !== 7 + Math.ceil(length / 8) + 2) {
return;
}
// build an... | [
"function",
"_handleForceMultipleCoils",
"(",
"requestBuffer",
",",
"vector",
",",
"unitID",
",",
"callback",
")",
"{",
"var",
"address",
"=",
"requestBuffer",
".",
"readUInt16BE",
"(",
"2",
")",
";",
"var",
"length",
"=",
"requestBuffer",
".",
"readUInt16BE",
... | Function to handle FC15 request.
@param requestBuffer - request Buffer from client
@param vector - vector of functions for read and write
@param unitID - Id of the requesting unit
@param {function} callback - callback to be invoked passing {Buffer} response
@returns undefined
@private | [
"Function",
"to",
"handle",
"FC15",
"request",
"."
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/servers/servertcp_handler.js#L523-L608 | train |
yaacov/node-modbus-serial | servers/servertcp_handler.js | _handleWriteMultipleRegisters | function _handleWriteMultipleRegisters(requestBuffer, vector, unitID, callback) {
var address = requestBuffer.readUInt16BE(2);
var length = requestBuffer.readUInt16BE(4);
// if length is bad, ignore message
if (requestBuffer.length !== (7 + length * 2 + 2)) {
return;
}
// build answer
... | javascript | function _handleWriteMultipleRegisters(requestBuffer, vector, unitID, callback) {
var address = requestBuffer.readUInt16BE(2);
var length = requestBuffer.readUInt16BE(4);
// if length is bad, ignore message
if (requestBuffer.length !== (7 + length * 2 + 2)) {
return;
}
// build answer
... | [
"function",
"_handleWriteMultipleRegisters",
"(",
"requestBuffer",
",",
"vector",
",",
"unitID",
",",
"callback",
")",
"{",
"var",
"address",
"=",
"requestBuffer",
".",
"readUInt16BE",
"(",
"2",
")",
";",
"var",
"length",
"=",
"requestBuffer",
".",
"readUInt16BE... | Function to handle FC16 request.
@param requestBuffer - request Buffer from client
@param vector - vector of functions for read and write
@param unitID - Id of the requesting unit
@param {function} callback - callback to be invoked passing {Buffer} response
@returns undefined
@private | [
"Function",
"to",
"handle",
"FC16",
"request",
"."
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/servers/servertcp_handler.js#L620-L707 | train |
yaacov/node-modbus-serial | servers/servertcp_handler.js | _handleMEI | function _handleMEI(requestBuffer, vector, unitID, callback) {
var MEIType = requestBuffer[2];
switch(parseInt(MEIType)) {
case 14:
_handleReadDeviceIdentification(requestBuffer, vector, unitID, callback);
break;
default:
callback({ modbusErrorCode: 0x01 }); /... | javascript | function _handleMEI(requestBuffer, vector, unitID, callback) {
var MEIType = requestBuffer[2];
switch(parseInt(MEIType)) {
case 14:
_handleReadDeviceIdentification(requestBuffer, vector, unitID, callback);
break;
default:
callback({ modbusErrorCode: 0x01 }); /... | [
"function",
"_handleMEI",
"(",
"requestBuffer",
",",
"vector",
",",
"unitID",
",",
"callback",
")",
"{",
"var",
"MEIType",
"=",
"requestBuffer",
"[",
"2",
"]",
";",
"switch",
"(",
"parseInt",
"(",
"MEIType",
")",
")",
"{",
"case",
"14",
":",
"_handleRead... | Function to handle FC43 request.
@param requestBuffer - request Buffer from client
@param vector - vector of functions for read and write
@param unitID - Id of the requesting unit
@param {function} callback - callback to be invoked passing {Buffer} response
@returns undefined
@private | [
"Function",
"to",
"handle",
"FC43",
"request",
"."
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/servers/servertcp_handler.js#L719-L728 | train |
yaacov/node-modbus-serial | servers/servertcp.js | _serverDebug | function _serverDebug(text, unitID, functionCode, responseBuffer) {
// If no responseBuffer, then assume this is an error
// o/w assume an action
if (typeof responseBuffer === "undefined") {
modbusSerialDebug({
error: text,
unitID: unitID,
functionCode: functionCo... | javascript | function _serverDebug(text, unitID, functionCode, responseBuffer) {
// If no responseBuffer, then assume this is an error
// o/w assume an action
if (typeof responseBuffer === "undefined") {
modbusSerialDebug({
error: text,
unitID: unitID,
functionCode: functionCo... | [
"function",
"_serverDebug",
"(",
"text",
",",
"unitID",
",",
"functionCode",
",",
"responseBuffer",
")",
"{",
"// If no responseBuffer, then assume this is an error",
"// o/w assume an action",
"if",
"(",
"typeof",
"responseBuffer",
"===",
"\"undefined\"",
")",
"{",
"modb... | Helper function for sending debug objects.
@param {string} text - text of message, an error or an action
@param {int} unitID - Id of the requesting unit
@param {int} functionCode - a modbus function code.
@param {Buffer} requestBuffer - request Buffer from client
@returns undefined
@private | [
"Helper",
"function",
"for",
"sending",
"debug",
"objects",
"."
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/servers/servertcp.js#L49-L67 | train |
yaacov/node-modbus-serial | servers/servertcp.js | _callbackFactory | function _callbackFactory(unitID, functionCode, sockWriter) {
return function cb(err, responseBuffer) {
var crc;
// If we have an error.
if (err) {
var errorCode = 0x04; // slave device failure
if (!isNaN(err.modbusErrorCode)) {
errorCode = err.modbus... | javascript | function _callbackFactory(unitID, functionCode, sockWriter) {
return function cb(err, responseBuffer) {
var crc;
// If we have an error.
if (err) {
var errorCode = 0x04; // slave device failure
if (!isNaN(err.modbusErrorCode)) {
errorCode = err.modbus... | [
"function",
"_callbackFactory",
"(",
"unitID",
",",
"functionCode",
",",
"sockWriter",
")",
"{",
"return",
"function",
"cb",
"(",
"err",
",",
"responseBuffer",
")",
"{",
"var",
"crc",
";",
"// If we have an error.",
"if",
"(",
"err",
")",
"{",
"var",
"errorC... | Helper function for creating callback functions.
@param {int} unitID - Id of the requesting unit
@param {int} functionCode - a modbus function code
@param {function} sockWriter - write buffer (or error) to tcp socket
@returns {function} - a callback function
@private | [
"Helper",
"function",
"for",
"creating",
"callback",
"functions",
"."
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/servers/servertcp.js#L78-L115 | train |
yaacov/node-modbus-serial | servers/servertcp.js | _parseModbusBuffer | function _parseModbusBuffer(requestBuffer, vector, serverUnitID, sockWriter) {
var cb;
// Check requestBuffer length
if (!requestBuffer || requestBuffer.length < MBAP_LEN) {
modbusSerialDebug("wrong size of request Buffer " + requestBuffer.length);
return;
}
var unitID = requestBuf... | javascript | function _parseModbusBuffer(requestBuffer, vector, serverUnitID, sockWriter) {
var cb;
// Check requestBuffer length
if (!requestBuffer || requestBuffer.length < MBAP_LEN) {
modbusSerialDebug("wrong size of request Buffer " + requestBuffer.length);
return;
}
var unitID = requestBuf... | [
"function",
"_parseModbusBuffer",
"(",
"requestBuffer",
",",
"vector",
",",
"serverUnitID",
",",
"sockWriter",
")",
"{",
"var",
"cb",
";",
"// Check requestBuffer length",
"if",
"(",
"!",
"requestBuffer",
"||",
"requestBuffer",
".",
"length",
"<",
"MBAP_LEN",
")",... | Parse a ModbusRTU buffer and return an answer buffer.
@param {Buffer} requestBuffer - request Buffer from client
@param {object} vector - vector of functions for read and write
@param {function} callback - callback to be invoked passing {Buffer} response
@returns undefined
@private | [
"Parse",
"a",
"ModbusRTU",
"buffer",
"and",
"return",
"an",
"answer",
"buffer",
"."
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/servers/servertcp.js#L126-L195 | train |
yaacov/node-modbus-serial | ports/c701port.js | _checkData | function _checkData(modbus, buf) {
// check buffer size
if (buf.length !== modbus._length && buf.length !== 5) return false;
// calculate crc16
var crcIn = buf.readUInt16LE(buf.length - 2);
// check buffer unit-id, command and crc
return (buf[0] === modbus._id &&
(0x7f & buf[1]) === mo... | javascript | function _checkData(modbus, buf) {
// check buffer size
if (buf.length !== modbus._length && buf.length !== 5) return false;
// calculate crc16
var crcIn = buf.readUInt16LE(buf.length - 2);
// check buffer unit-id, command and crc
return (buf[0] === modbus._id &&
(0x7f & buf[1]) === mo... | [
"function",
"_checkData",
"(",
"modbus",
",",
"buf",
")",
"{",
"// check buffer size",
"if",
"(",
"buf",
".",
"length",
"!==",
"modbus",
".",
"_length",
"&&",
"buf",
".",
"length",
"!==",
"5",
")",
"return",
"false",
";",
"// calculate crc16",
"var",
"crcI... | Check if a buffer chunk can be a Modbus answer or modbus exception.
@param {UdpPort} modbus
@param {Buffer} buf the buffer to check.
@return {boolean} if the buffer can be an answer
@private | [
"Check",
"if",
"a",
"buffer",
"chunk",
"can",
"be",
"a",
"Modbus",
"answer",
"or",
"modbus",
"exception",
"."
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/ports/c701port.js#L23-L34 | train |
yaacov/node-modbus-serial | ports/c701port.js | function(ip, options) {
var modbus = this;
this.ip = ip;
this.openFlag = false;
// options
if (typeof(options) === "undefined") options = {};
this.port = options.port || C701_PORT; // C701 port
// create a socket
this._client = dgram.createSocket("udp4");
// wait for answer
th... | javascript | function(ip, options) {
var modbus = this;
this.ip = ip;
this.openFlag = false;
// options
if (typeof(options) === "undefined") options = {};
this.port = options.port || C701_PORT; // C701 port
// create a socket
this._client = dgram.createSocket("udp4");
// wait for answer
th... | [
"function",
"(",
"ip",
",",
"options",
")",
"{",
"var",
"modbus",
"=",
"this",
";",
"this",
".",
"ip",
"=",
"ip",
";",
"this",
".",
"openFlag",
"=",
"false",
";",
"// options",
"if",
"(",
"typeof",
"(",
"options",
")",
"===",
"\"undefined\"",
")",
... | Simulate a modbus-RTU port using C701 UDP-to-Serial bridge.
@param ip
@param options
@constructor | [
"Simulate",
"a",
"modbus",
"-",
"RTU",
"port",
"using",
"C701",
"UDP",
"-",
"to",
"-",
"Serial",
"bridge",
"."
] | bc11a54bc256986deb749efbde23a3657d28ff20 | https://github.com/yaacov/node-modbus-serial/blob/bc11a54bc256986deb749efbde23a3657d28ff20/ports/c701port.js#L43-L120 | train | |
pahen/madge | lib/graph.js | checkGraphvizInstalled | function checkGraphvizInstalled(config) {
if (config.graphVizPath) {
const cmd = path.join(config.graphVizPath, 'gvpr -V');
return exec(cmd)
.catch(() => {
throw new Error('Could not execute ' + cmd);
});
}
return exec('gvpr -V')
.catch((error) => {
throw new Error('Graphviz could not be found. E... | javascript | function checkGraphvizInstalled(config) {
if (config.graphVizPath) {
const cmd = path.join(config.graphVizPath, 'gvpr -V');
return exec(cmd)
.catch(() => {
throw new Error('Could not execute ' + cmd);
});
}
return exec('gvpr -V')
.catch((error) => {
throw new Error('Graphviz could not be found. E... | [
"function",
"checkGraphvizInstalled",
"(",
"config",
")",
"{",
"if",
"(",
"config",
".",
"graphVizPath",
")",
"{",
"const",
"cmd",
"=",
"path",
".",
"join",
"(",
"config",
".",
"graphVizPath",
",",
"'gvpr -V'",
")",
";",
"return",
"exec",
"(",
"cmd",
")"... | Check if Graphviz is installed on the system.
@param {Object} config
@return {Promise} | [
"Check",
"if",
"Graphviz",
"is",
"installed",
"on",
"the",
"system",
"."
] | f8c3e640a51825ff7dc0aefe79510c8a584cf6cf | https://github.com/pahen/madge/blob/f8c3e640a51825ff7dc0aefe79510c8a584cf6cf/lib/graph.js#L25-L38 | train |
pahen/madge | lib/graph.js | createGraphvizOptions | function createGraphvizOptions(config) {
const graphVizOptions = config.graphVizOptions || {};
return {
G: Object.assign({
overlap: false,
pad: 0.3,
rankdir: config.rankdir,
layout: config.layout,
bgcolor: config.backgroundColor
}, graphVizOptions.G),
E: Object.assign({
color: config.edgeColo... | javascript | function createGraphvizOptions(config) {
const graphVizOptions = config.graphVizOptions || {};
return {
G: Object.assign({
overlap: false,
pad: 0.3,
rankdir: config.rankdir,
layout: config.layout,
bgcolor: config.backgroundColor
}, graphVizOptions.G),
E: Object.assign({
color: config.edgeColo... | [
"function",
"createGraphvizOptions",
"(",
"config",
")",
"{",
"const",
"graphVizOptions",
"=",
"config",
".",
"graphVizOptions",
"||",
"{",
"}",
";",
"return",
"{",
"G",
":",
"Object",
".",
"assign",
"(",
"{",
"overlap",
":",
"false",
",",
"pad",
":",
"0... | Return options to use with graphviz digraph.
@param {Object} config
@return {Object} | [
"Return",
"options",
"to",
"use",
"with",
"graphviz",
"digraph",
"."
] | f8c3e640a51825ff7dc0aefe79510c8a584cf6cf | https://github.com/pahen/madge/blob/f8c3e640a51825ff7dc0aefe79510c8a584cf6cf/lib/graph.js#L45-L69 | train |
pahen/madge | lib/graph.js | createGraph | function createGraph(modules, circular, config, options) {
const g = graphviz.digraph('G');
const nodes = {};
const cyclicModules = circular.reduce((a, b) => a.concat(b), []);
if (config.graphVizPath) {
g.setGraphVizPath(config.graphVizPath);
}
Object.keys(modules).forEach((id) => {
nodes[id] = nodes[id] ||... | javascript | function createGraph(modules, circular, config, options) {
const g = graphviz.digraph('G');
const nodes = {};
const cyclicModules = circular.reduce((a, b) => a.concat(b), []);
if (config.graphVizPath) {
g.setGraphVizPath(config.graphVizPath);
}
Object.keys(modules).forEach((id) => {
nodes[id] = nodes[id] ||... | [
"function",
"createGraph",
"(",
"modules",
",",
"circular",
",",
"config",
",",
"options",
")",
"{",
"const",
"g",
"=",
"graphviz",
".",
"digraph",
"(",
"'G'",
")",
";",
"const",
"nodes",
"=",
"{",
"}",
";",
"const",
"cyclicModules",
"=",
"circular",
"... | Creates the graphviz graph.
@param {Object} modules
@param {Array} circular
@param {Object} config
@param {Object} options
@return {Promise} | [
"Creates",
"the",
"graphviz",
"graph",
"."
] | f8c3e640a51825ff7dc0aefe79510c8a584cf6cf | https://github.com/pahen/madge/blob/f8c3e640a51825ff7dc0aefe79510c8a584cf6cf/lib/graph.js#L79-L113 | train |
pahen/madge | lib/cyclic.js | getPath | function getPath(parent, unresolved) {
let parentVisited = false;
return Object.keys(unresolved).filter((module) => {
if (module === parent) {
parentVisited = true;
}
return parentVisited && unresolved[module];
});
} | javascript | function getPath(parent, unresolved) {
let parentVisited = false;
return Object.keys(unresolved).filter((module) => {
if (module === parent) {
parentVisited = true;
}
return parentVisited && unresolved[module];
});
} | [
"function",
"getPath",
"(",
"parent",
",",
"unresolved",
")",
"{",
"let",
"parentVisited",
"=",
"false",
";",
"return",
"Object",
".",
"keys",
"(",
"unresolved",
")",
".",
"filter",
"(",
"(",
"module",
")",
"=>",
"{",
"if",
"(",
"module",
"===",
"paren... | Get path to the circular dependency.
@param {String} parent
@param {Object} unresolved
@return {Array} | [
"Get",
"path",
"to",
"the",
"circular",
"dependency",
"."
] | f8c3e640a51825ff7dc0aefe79510c8a584cf6cf | https://github.com/pahen/madge/blob/f8c3e640a51825ff7dc0aefe79510c8a584cf6cf/lib/cyclic.js#L9-L18 | train |
pahen/madge | lib/cyclic.js | resolver | function resolver(id, modules, circular, resolved, unresolved) {
unresolved[id] = true;
if (modules[id]) {
modules[id].forEach((dependency) => {
if (!resolved[dependency]) {
if (unresolved[dependency]) {
circular.push(getPath(dependency, unresolved));
return;
}
resolver(dependency, modules... | javascript | function resolver(id, modules, circular, resolved, unresolved) {
unresolved[id] = true;
if (modules[id]) {
modules[id].forEach((dependency) => {
if (!resolved[dependency]) {
if (unresolved[dependency]) {
circular.push(getPath(dependency, unresolved));
return;
}
resolver(dependency, modules... | [
"function",
"resolver",
"(",
"id",
",",
"modules",
",",
"circular",
",",
"resolved",
",",
"unresolved",
")",
"{",
"unresolved",
"[",
"id",
"]",
"=",
"true",
";",
"if",
"(",
"modules",
"[",
"id",
"]",
")",
"{",
"modules",
"[",
"id",
"]",
".",
"forEa... | A circular dependency is occurring when we see a software package
more than once, unless that software package has all its dependencies resolved.
@param {String} id
@param {Object} modules
@param {Object} circular
@param {Object} resolved
@param {Object} unresolved | [
"A",
"circular",
"dependency",
"is",
"occurring",
"when",
"we",
"see",
"a",
"software",
"package",
"more",
"than",
"once",
"unless",
"that",
"software",
"package",
"has",
"all",
"its",
"dependencies",
"resolved",
"."
] | f8c3e640a51825ff7dc0aefe79510c8a584cf6cf | https://github.com/pahen/madge/blob/f8c3e640a51825ff7dc0aefe79510c8a584cf6cf/lib/cyclic.js#L29-L46 | train |
WeCodePixels/theia-sticky-sidebar | js/theia-sticky-sidebar.js | tryInitOrHookIntoEvents | function tryInitOrHookIntoEvents(options, $that) {
var success = tryInit(options, $that);
if (!success) {
console.log('TSS: Body width smaller than options.minWidth. Init is delayed.');
$(document).on('scroll.' + options.namespace, function (options, $that) {
... | javascript | function tryInitOrHookIntoEvents(options, $that) {
var success = tryInit(options, $that);
if (!success) {
console.log('TSS: Body width smaller than options.minWidth. Init is delayed.');
$(document).on('scroll.' + options.namespace, function (options, $that) {
... | [
"function",
"tryInitOrHookIntoEvents",
"(",
"options",
",",
"$that",
")",
"{",
"var",
"success",
"=",
"tryInit",
"(",
"options",
",",
"$that",
")",
";",
"if",
"(",
"!",
"success",
")",
"{",
"console",
".",
"log",
"(",
"'TSS: Body width smaller than options.min... | Try doing init, otherwise hook into window.resize and document.scroll and try again then. | [
"Try",
"doing",
"init",
"otherwise",
"hook",
"into",
"window",
".",
"resize",
"and",
"document",
".",
"scroll",
"and",
"try",
"again",
"then",
"."
] | 8f13b3ce686c824d52118e73a812d374c5c00656 | https://github.com/WeCodePixels/theia-sticky-sidebar/blob/8f13b3ce686c824d52118e73a812d374c5c00656/js/theia-sticky-sidebar.js#L33-L58 | train |
WeCodePixels/theia-sticky-sidebar | js/theia-sticky-sidebar.js | tryInit | function tryInit(options, $that) {
if (options.initialized === true) {
return true;
}
if ($('body').width() < options.minWidth) {
return false;
}
init(options, $that);
return true;
} | javascript | function tryInit(options, $that) {
if (options.initialized === true) {
return true;
}
if ($('body').width() < options.minWidth) {
return false;
}
init(options, $that);
return true;
} | [
"function",
"tryInit",
"(",
"options",
",",
"$that",
")",
"{",
"if",
"(",
"options",
".",
"initialized",
"===",
"true",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"(",
"'body'",
")",
".",
"width",
"(",
")",
"<",
"options",
".",
"minWidth... | Try doing init if proper conditions are met. | [
"Try",
"doing",
"init",
"if",
"proper",
"conditions",
"are",
"met",
"."
] | 8f13b3ce686c824d52118e73a812d374c5c00656 | https://github.com/WeCodePixels/theia-sticky-sidebar/blob/8f13b3ce686c824d52118e73a812d374c5c00656/js/theia-sticky-sidebar.js#L61-L73 | train |
WeCodePixels/theia-sticky-sidebar | js/theia-sticky-sidebar.js | getClearedHeight | function getClearedHeight(e) {
var height = e.height();
e.children().each(function () {
height = Math.max(height, $(this).height());
});
return height;
} | javascript | function getClearedHeight(e) {
var height = e.height();
e.children().each(function () {
height = Math.max(height, $(this).height());
});
return height;
} | [
"function",
"getClearedHeight",
"(",
"e",
")",
"{",
"var",
"height",
"=",
"e",
".",
"height",
"(",
")",
";",
"e",
".",
"children",
"(",
")",
".",
"each",
"(",
"function",
"(",
")",
"{",
"height",
"=",
"Math",
".",
"max",
"(",
"height",
",",
"$",
... | Get the height of a div as if its floated children were cleared. Note that this function fails if the floats are more than one level deep. | [
"Get",
"the",
"height",
"of",
"a",
"div",
"as",
"if",
"its",
"floated",
"children",
"were",
"cleared",
".",
"Note",
"that",
"this",
"function",
"fails",
"if",
"the",
"floats",
"are",
"more",
"than",
"one",
"level",
"deep",
"."
] | 8f13b3ce686c824d52118e73a812d374c5c00656 | https://github.com/WeCodePixels/theia-sticky-sidebar/blob/8f13b3ce686c824d52118e73a812d374c5c00656/js/theia-sticky-sidebar.js#L341-L349 | train |
survivejs/webpack-merge | src/join-arrays-smart.js | isSameValue | function isSameValue(a, b) {
const [propA, propB] = [a, b].map(value => (
isArray(value) ? [...value].sort() : value
));
return isEqual(propA, propB);
} | javascript | function isSameValue(a, b) {
const [propA, propB] = [a, b].map(value => (
isArray(value) ? [...value].sort() : value
));
return isEqual(propA, propB);
} | [
"function",
"isSameValue",
"(",
"a",
",",
"b",
")",
"{",
"const",
"[",
"propA",
",",
"propB",
"]",
"=",
"[",
"a",
",",
"b",
"]",
".",
"map",
"(",
"value",
"=>",
"(",
"isArray",
"(",
"value",
")",
"?",
"[",
"...",
"value",
"]",
".",
"sort",
"(... | Check equality of two values using lodash's isEqual
Arrays need to be sorted for equality checking
but clone them first so as not to disrupt the sort order in tests | [
"Check",
"equality",
"of",
"two",
"values",
"using",
"lodash",
"s",
"isEqual",
"Arrays",
"need",
"to",
"be",
"sorted",
"for",
"equality",
"checking",
"but",
"clone",
"them",
"first",
"so",
"as",
"not",
"to",
"disrupt",
"the",
"sort",
"order",
"in",
"tests"... | c3a515687844ab97a416efebb2bdeadc802b0668 | https://github.com/survivejs/webpack-merge/blob/c3a515687844ab97a416efebb2bdeadc802b0668/src/join-arrays-smart.js#L110-L116 | train |
WebReflection/hyperHTML | cjs/hyper/render.js | upgrade | function upgrade(template) {
const type = OWNER_SVG_ELEMENT in this ? 'svg' : 'html';
const tagger = new Tagger(type);
bewitched.set(this, {tagger, template: template});
this.textContent = '';
this.appendChild(tagger.apply(null, arguments));
} | javascript | function upgrade(template) {
const type = OWNER_SVG_ELEMENT in this ? 'svg' : 'html';
const tagger = new Tagger(type);
bewitched.set(this, {tagger, template: template});
this.textContent = '';
this.appendChild(tagger.apply(null, arguments));
} | [
"function",
"upgrade",
"(",
"template",
")",
"{",
"const",
"type",
"=",
"OWNER_SVG_ELEMENT",
"in",
"this",
"?",
"'svg'",
":",
"'html'",
";",
"const",
"tagger",
"=",
"new",
"Tagger",
"(",
"type",
")",
";",
"bewitched",
".",
"set",
"(",
"this",
",",
"{",... | an upgrade is in charge of collecting template info, parse it once, if unknown, to map all interpolations as single DOM callbacks, relate such template to the current context, and render it after cleaning the context up | [
"an",
"upgrade",
"is",
"in",
"charge",
"of",
"collecting",
"template",
"info",
"parse",
"it",
"once",
"if",
"unknown",
"to",
"map",
"all",
"interpolations",
"as",
"single",
"DOM",
"callbacks",
"relate",
"such",
"template",
"to",
"the",
"current",
"context",
... | 34f1006a9803c28cecd757a55f023752a6cfb8e1 | https://github.com/WebReflection/hyperHTML/blob/34f1006a9803c28cecd757a55f023752a6cfb8e1/cjs/hyper/render.js#L31-L37 | train |
WebReflection/hyperHTML | cjs/index.js | hyper | function hyper(HTML) {
return arguments.length < 2 ?
(HTML == null ?
content('html') :
(typeof HTML === 'string' ?
hyper.wire(null, HTML) :
('raw' in HTML ?
content('html')(HTML) :
('nodeType' in HTML ?
hyper.bind(HTML) :
weakly(HTML, 'html')... | javascript | function hyper(HTML) {
return arguments.length < 2 ?
(HTML == null ?
content('html') :
(typeof HTML === 'string' ?
hyper.wire(null, HTML) :
('raw' in HTML ?
content('html')(HTML) :
('nodeType' in HTML ?
hyper.bind(HTML) :
weakly(HTML, 'html')... | [
"function",
"hyper",
"(",
"HTML",
")",
"{",
"return",
"arguments",
".",
"length",
"<",
"2",
"?",
"(",
"HTML",
"==",
"null",
"?",
"content",
"(",
"'html'",
")",
":",
"(",
"typeof",
"HTML",
"===",
"'string'",
"?",
"hyper",
".",
"wire",
"(",
"null",
"... | by default, hyperHTML is a smart function that "magically" understands what's the best thing to do with passed arguments | [
"by",
"default",
"hyperHTML",
"is",
"a",
"smart",
"function",
"that",
"magically",
"understands",
"what",
"s",
"the",
"best",
"thing",
"to",
"do",
"with",
"passed",
"arguments"
] | 34f1006a9803c28cecd757a55f023752a6cfb8e1 | https://github.com/WebReflection/hyperHTML/blob/34f1006a9803c28cecd757a55f023752a6cfb8e1/cjs/index.js#L59-L76 | train |
scottdejonge/map-icons | dist/js/map-icons.js | function (options) {
google.maps.Marker.prototype.setMap.apply(this, [options]);
(this.MarkerLabel) && this.MarkerLabel.setMap.apply(this.MarkerLabel, [options]);
} | javascript | function (options) {
google.maps.Marker.prototype.setMap.apply(this, [options]);
(this.MarkerLabel) && this.MarkerLabel.setMap.apply(this.MarkerLabel, [options]);
} | [
"function",
"(",
"options",
")",
"{",
"google",
".",
"maps",
".",
"Marker",
".",
"prototype",
".",
"setMap",
".",
"apply",
"(",
"this",
",",
"[",
"options",
"]",
")",
";",
"(",
"this",
".",
"MarkerLabel",
")",
"&&",
"this",
".",
"MarkerLabel",
".",
... | Custom Marker SetMap | [
"Custom",
"Marker",
"SetMap"
] | dbf6fd7caedd60d11b5bfb5f267a114a6847d012 | https://github.com/scottdejonge/map-icons/blob/dbf6fd7caedd60d11b5bfb5f267a114a6847d012/dist/js/map-icons.js#L95-L98 | train | |
scottdejonge/map-icons | dist/js/map-icons.js | function () {
this.div.parentNode.removeChild(this.div);
for (var i = 0, I = this.listeners.length; i < I; ++i) {
google.maps.event.removeListener(this.listeners[i]);
}
} | javascript | function () {
this.div.parentNode.removeChild(this.div);
for (var i = 0, I = this.listeners.length; i < I; ++i) {
google.maps.event.removeListener(this.listeners[i]);
}
} | [
"function",
"(",
")",
"{",
"this",
".",
"div",
".",
"parentNode",
".",
"removeChild",
"(",
"this",
".",
"div",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"I",
"=",
"this",
".",
"listeners",
".",
"length",
";",
"i",
"<",
"I",
";",
"++",
... | Marker Label onRemove | [
"Marker",
"Label",
"onRemove"
] | dbf6fd7caedd60d11b5bfb5f267a114a6847d012 | https://github.com/scottdejonge/map-icons/blob/dbf6fd7caedd60d11b5bfb5f267a114a6847d012/dist/js/map-icons.js#L119-L125 | train | |
c9/architect | demos/calculator/plugins/calculator/calculator.js | basicAuth | function basicAuth(checker, realm) {
realm = realm || 'Authorization Required';
function unauthorized(res) {
res.writeHead(401, {
'WWW-Authenticate': 'Basic realm="' + realm + '"',
'Content-Length': 13
});
res.end("Unauthorize... | javascript | function basicAuth(checker, realm) {
realm = realm || 'Authorization Required';
function unauthorized(res) {
res.writeHead(401, {
'WWW-Authenticate': 'Basic realm="' + realm + '"',
'Content-Length': 13
});
res.end("Unauthorize... | [
"function",
"basicAuth",
"(",
"checker",
",",
"realm",
")",
"{",
"realm",
"=",
"realm",
"||",
"'Authorization Required'",
";",
"function",
"unauthorized",
"(",
"res",
")",
"{",
"res",
".",
"writeHead",
"(",
"401",
",",
"{",
"'WWW-Authenticate'",
":",
"'Basic... | Based loosly on basicAuth from Connect Checker takes username and password and returns a user if valid Will force redirect if requested over HTTP instead of HTTPS | [
"Based",
"loosly",
"on",
"basicAuth",
"from",
"Connect",
"Checker",
"takes",
"username",
"and",
"password",
"and",
"returns",
"a",
"user",
"if",
"valid",
"Will",
"force",
"redirect",
"if",
"requested",
"over",
"HTTP",
"instead",
"of",
"HTTPS"
] | aee3404bc6da8591858c5807b49ac66bc6ad2280 | https://github.com/c9/architect/blob/aee3404bc6da8591858c5807b49ac66bc6ad2280/demos/calculator/plugins/calculator/calculator.js#L36-L68 | train |
team-gryff/react-monocle | src/reactParser.js | getReactProps | function getReactProps(node, parent) {
if (node.openingElement.attributes.length === 0 ||
htmlElements.indexOf(node.openingElement.name.name) > 0) return {};
const result = node.openingElement.attributes
.map(attribute => {
const name = attribute.name.name;
let valueName;
if (attribute.value... | javascript | function getReactProps(node, parent) {
if (node.openingElement.attributes.length === 0 ||
htmlElements.indexOf(node.openingElement.name.name) > 0) return {};
const result = node.openingElement.attributes
.map(attribute => {
const name = attribute.name.name;
let valueName;
if (attribute.value... | [
"function",
"getReactProps",
"(",
"node",
",",
"parent",
")",
"{",
"if",
"(",
"node",
".",
"openingElement",
".",
"attributes",
".",
"length",
"===",
"0",
"||",
"htmlElements",
".",
"indexOf",
"(",
"node",
".",
"openingElement",
".",
"name",
".",
"name",
... | Returns array of props from React component passed to input
@param {Node} node
@returns {Array} Array of all JSX props on React component | [
"Returns",
"array",
"of",
"props",
"from",
"React",
"component",
"passed",
"to",
"input"
] | b90f26e2e6440d7e8f2e596237ec1ed598827453 | https://github.com/team-gryff/react-monocle/blob/b90f26e2e6440d7e8f2e596237ec1ed598827453/src/reactParser.js#L33-L87 | train |
team-gryff/react-monocle | src/reactParser.js | getChildJSXElements | function getChildJSXElements(node, parent) {
if (node.children.length === 0) return [];
const childJsxComponentsArr = node
.children
.filter(jsx => jsx.type === 'JSXElement'
&& htmlElements.indexOf(jsx.openingElement.name.name) < 0);
return childJsxComponentsArr
.map(child => {
return {
... | javascript | function getChildJSXElements(node, parent) {
if (node.children.length === 0) return [];
const childJsxComponentsArr = node
.children
.filter(jsx => jsx.type === 'JSXElement'
&& htmlElements.indexOf(jsx.openingElement.name.name) < 0);
return childJsxComponentsArr
.map(child => {
return {
... | [
"function",
"getChildJSXElements",
"(",
"node",
",",
"parent",
")",
"{",
"if",
"(",
"node",
".",
"children",
".",
"length",
"===",
"0",
")",
"return",
"[",
"]",
";",
"const",
"childJsxComponentsArr",
"=",
"node",
".",
"children",
".",
"filter",
"(",
"jsx... | Returns array of children components of React component passed to input
@param {Node} node
@returns {Array} Array of (nested) children of React component passed in | [
"Returns",
"array",
"of",
"children",
"components",
"of",
"React",
"component",
"passed",
"to",
"input"
] | b90f26e2e6440d7e8f2e596237ec1ed598827453 | https://github.com/team-gryff/react-monocle/blob/b90f26e2e6440d7e8f2e596237ec1ed598827453/src/reactParser.js#L94-L110 | train |
team-gryff/react-monocle | src/reactParser.js | isES6ReactComponent | function isES6ReactComponent(node) {
return (node.superClass.property && node.superClass.property.name === 'Component')
|| node.superClass.name === 'Component';
} | javascript | function isES6ReactComponent(node) {
return (node.superClass.property && node.superClass.property.name === 'Component')
|| node.superClass.name === 'Component';
} | [
"function",
"isES6ReactComponent",
"(",
"node",
")",
"{",
"return",
"(",
"node",
".",
"superClass",
".",
"property",
"&&",
"node",
".",
"superClass",
".",
"property",
".",
"name",
"===",
"'Component'",
")",
"||",
"node",
".",
"superClass",
".",
"name",
"==... | Returns if AST node is an ES6 React component
@param {Node} node
@return {Boolean} Determines if AST node is a React component node | [
"Returns",
"if",
"AST",
"node",
"is",
"an",
"ES6",
"React",
"component"
] | b90f26e2e6440d7e8f2e596237ec1ed598827453 | https://github.com/team-gryff/react-monocle/blob/b90f26e2e6440d7e8f2e596237ec1ed598827453/src/reactParser.js#L275-L278 | train |
team-gryff/react-monocle | src/reactParser.js | jsToAst | function jsToAst(js) {
const ast = acorn.parse(js, {
plugins: { jsx: true },
});
if (ast.body.length === 0) throw new Error('Empty AST input');
return ast;
} | javascript | function jsToAst(js) {
const ast = acorn.parse(js, {
plugins: { jsx: true },
});
if (ast.body.length === 0) throw new Error('Empty AST input');
return ast;
} | [
"function",
"jsToAst",
"(",
"js",
")",
"{",
"const",
"ast",
"=",
"acorn",
".",
"parse",
"(",
"js",
",",
"{",
"plugins",
":",
"{",
"jsx",
":",
"true",
"}",
",",
"}",
")",
";",
"if",
"(",
"ast",
".",
"body",
".",
"length",
"===",
"0",
")",
"thr... | Helper function to convert Javascript stringified code to an AST using acorn-jsx library
@param js | [
"Helper",
"function",
"to",
"convert",
"Javascript",
"stringified",
"code",
"to",
"an",
"AST",
"using",
"acorn",
"-",
"jsx",
"library"
] | b90f26e2e6440d7e8f2e596237ec1ed598827453 | https://github.com/team-gryff/react-monocle/blob/b90f26e2e6440d7e8f2e596237ec1ed598827453/src/reactParser.js#L549-L555 | train |
team-gryff/react-monocle | src/d3DataBuilder.js | d3DataBuilder | function d3DataBuilder(obj) {
if (!obj.ENTRY) throw new Error('Entry component not found');
const formatted = {};
// parsing AST into formatted objects based on ES5/ES6 syntax
Object.entries(obj).forEach(entry => {
if (entry[0] === 'ENTRY') return;
const componentChecker = reactParser.componentChecker(... | javascript | function d3DataBuilder(obj) {
if (!obj.ENTRY) throw new Error('Entry component not found');
const formatted = {};
// parsing AST into formatted objects based on ES5/ES6 syntax
Object.entries(obj).forEach(entry => {
if (entry[0] === 'ENTRY') return;
const componentChecker = reactParser.componentChecker(... | [
"function",
"d3DataBuilder",
"(",
"obj",
")",
"{",
"if",
"(",
"!",
"obj",
".",
"ENTRY",
")",
"throw",
"new",
"Error",
"(",
"'Entry component not found'",
")",
";",
"const",
"formatted",
"=",
"{",
"}",
";",
"// parsing AST into formatted objects based on ES5/ES6 sy... | Takes in a formatted object and returns the tree object that D3 will need
@param {obj} Object
@return {Object} Tree object for D3 | [
"Takes",
"in",
"a",
"formatted",
"object",
"and",
"returns",
"the",
"tree",
"object",
"that",
"D3",
"will",
"need"
] | b90f26e2e6440d7e8f2e596237ec1ed598827453 | https://github.com/team-gryff/react-monocle/blob/b90f26e2e6440d7e8f2e596237ec1ed598827453/src/d3DataBuilder.js#L10-L48 | train |
brandonmowat/react-chat-ui | demo/bundle.js | assignFiberPropertiesInDEV | function assignFiberPropertiesInDEV(target, source) {
if (target === null) {
// This Fiber's initial properties will always be overwritten.
// We only use a Fiber to ensure the same hidden class so DEV isn't slow.
target = createFiber(IndeterminateComponent, null, null, NoContext);
}
// This is inten... | javascript | function assignFiberPropertiesInDEV(target, source) {
if (target === null) {
// This Fiber's initial properties will always be overwritten.
// We only use a Fiber to ensure the same hidden class so DEV isn't slow.
target = createFiber(IndeterminateComponent, null, null, NoContext);
}
// This is inten... | [
"function",
"assignFiberPropertiesInDEV",
"(",
"target",
",",
"source",
")",
"{",
"if",
"(",
"target",
"===",
"null",
")",
"{",
"// This Fiber's initial properties will always be overwritten.",
"// We only use a Fiber to ensure the same hidden class so DEV isn't slow.",
"target",
... | Used for stashing WIP properties to replay failed work in DEV. | [
"Used",
"for",
"stashing",
"WIP",
"properties",
"to",
"replay",
"failed",
"work",
"in",
"DEV",
"."
] | de554aa20b8751fbe389585bb7bade581ce63659 | https://github.com/brandonmowat/react-chat-ui/blob/de554aa20b8751fbe389585bb7bade581ce63659/demo/bundle.js#L11329-L11377 | train |
unifiedjs/unified | index.js | processor | function processor() {
var destination = unified()
var length = attachers.length
var index = -1
while (++index < length) {
destination.use.apply(null, attachers[index])
}
destination.data(extend(true, {}, namespace))
return destination
} | javascript | function processor() {
var destination = unified()
var length = attachers.length
var index = -1
while (++index < length) {
destination.use.apply(null, attachers[index])
}
destination.data(extend(true, {}, namespace))
return destination
} | [
"function",
"processor",
"(",
")",
"{",
"var",
"destination",
"=",
"unified",
"(",
")",
"var",
"length",
"=",
"attachers",
".",
"length",
"var",
"index",
"=",
"-",
"1",
"while",
"(",
"++",
"index",
"<",
"length",
")",
"{",
"destination",
".",
"use",
... | Create a new processor based on the processor in the current scope. | [
"Create",
"a",
"new",
"processor",
"based",
"on",
"the",
"processor",
"in",
"the",
"current",
"scope",
"."
] | 0dc92d6397a7fbbe70a93475db1bd585e12d1845 | https://github.com/unifiedjs/unified/blob/0dc92d6397a7fbbe70a93475db1bd585e12d1845/index.js#L74-L86 | train |
tradle/react-native-udp | examples/rctsockets/index.ios.js | toByteArray | function toByteArray(obj) {
var uint = new Uint8Array(obj.length);
for (var i = 0, l = obj.length; i < l; i++){
uint[i] = obj.charCodeAt(i);
}
return new Uint8Array(uint);
} | javascript | function toByteArray(obj) {
var uint = new Uint8Array(obj.length);
for (var i = 0, l = obj.length; i < l; i++){
uint[i] = obj.charCodeAt(i);
}
return new Uint8Array(uint);
} | [
"function",
"toByteArray",
"(",
"obj",
")",
"{",
"var",
"uint",
"=",
"new",
"Uint8Array",
"(",
"obj",
".",
"length",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"obj",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{"... | only works for 8-bit chars | [
"only",
"works",
"for",
"8",
"-",
"bit",
"chars"
] | 9d55560d28a3a4603bca79329185aa4ce86a7e99 | https://github.com/tradle/react-native-udp/blob/9d55560d28a3a4603bca79329185aa4ce86a7e99/examples/rctsockets/index.ios.js#L24-L31 | train |
smartcar/node-sdk | lib/vehicle.js | Vehicle | function Vehicle(id, token, unitSystem) {
if (!(this instanceof Vehicle)) {
// eslint-disable-next-line max-len
throw new TypeError("Class constructor Vehicle cannot be invoked without 'new'");
}
this.id = id;
this.token = token;
this.request = util.request.defaults({
baseUrl: util.getUrl(this.id... | javascript | function Vehicle(id, token, unitSystem) {
if (!(this instanceof Vehicle)) {
// eslint-disable-next-line max-len
throw new TypeError("Class constructor Vehicle cannot be invoked without 'new'");
}
this.id = id;
this.token = token;
this.request = util.request.defaults({
baseUrl: util.getUrl(this.id... | [
"function",
"Vehicle",
"(",
"id",
",",
"token",
",",
"unitSystem",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Vehicle",
")",
")",
"{",
"// eslint-disable-next-line max-len",
"throw",
"new",
"TypeError",
"(",
"\"Class constructor Vehicle cannot be invoked ... | Initializes a new Vehicle to use for making requests to the Smartcar API.
@constructor
@param {String} id - The vehicle's unique identifier. Retrieve a user's
vehicle id using {@link module:smartcar.getVehicleIds}.
@param {String} token - A valid access token
@param {String} [unitSystem=metric] - The unit system to us... | [
"Initializes",
"a",
"new",
"Vehicle",
"to",
"use",
"for",
"making",
"requests",
"to",
"the",
"Smartcar",
"API",
"."
] | b783137f2e98abf97bbb199d9de7ed597f7dec81 | https://github.com/smartcar/node-sdk/blob/b783137f2e98abf97bbb199d9de7ed597f7dec81/lib/vehicle.js#L28-L43 | train |
gruntjs/grunt-contrib-uglify | tasks/uglify.js | relativePath | function relativePath(file1, file2) {
var file1Dirname = path.dirname(file1);
var file2Dirname = path.dirname(file2);
if (file1Dirname !== file2Dirname) {
return path.relative(file1Dirname, file2Dirname);
}
return '';
} | javascript | function relativePath(file1, file2) {
var file1Dirname = path.dirname(file1);
var file2Dirname = path.dirname(file2);
if (file1Dirname !== file2Dirname) {
return path.relative(file1Dirname, file2Dirname);
}
return '';
} | [
"function",
"relativePath",
"(",
"file1",
",",
"file2",
")",
"{",
"var",
"file1Dirname",
"=",
"path",
".",
"dirname",
"(",
"file1",
")",
";",
"var",
"file2Dirname",
"=",
"path",
".",
"dirname",
"(",
"file2",
")",
";",
"if",
"(",
"file1Dirname",
"!==",
... | Return the relative path from file1 => file2 | [
"Return",
"the",
"relative",
"path",
"from",
"file1",
"=",
">",
"file2"
] | f65dbb96ec0e080ae5892d5144b0048379d1fec0 | https://github.com/gruntjs/grunt-contrib-uglify/blob/f65dbb96ec0e080ae5892d5144b0048379d1fec0/tasks/uglify.js#L18-L26 | train |
kswedberg/jquery-smooth-scroll | lib/jquery.ba-bbq.js | curry | function curry( func ) {
var args = aps.call( arguments, 1 );
return function() {
return func.apply( this, args.concat( aps.call( arguments ) ) );
};
} | javascript | function curry( func ) {
var args = aps.call( arguments, 1 );
return function() {
return func.apply( this, args.concat( aps.call( arguments ) ) );
};
} | [
"function",
"curry",
"(",
"func",
")",
"{",
"var",
"args",
"=",
"aps",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"return",
"function",
"(",
")",
"{",
"return",
"func",
".",
"apply",
"(",
"this",
",",
"args",
".",
"concat",
"(",
"aps",
".... | Why write the same function twice? Let's curry! Mmmm, curry.. | [
"Why",
"write",
"the",
"same",
"function",
"twice?",
"Let",
"s",
"curry!",
"Mmmm",
"curry",
".."
] | 965affd7edd2dffb034bf5b706c93d6a56d8ab97 | https://github.com/kswedberg/jquery-smooth-scroll/blob/965affd7edd2dffb034bf5b706c93d6a56d8ab97/lib/jquery.ba-bbq.js#L124-L130 | train |
benfred/venn.js | src/diagram.js | function(d) {
return function(t) {
var c = d.sets.map(function(set) {
var start = previous[set], end = circles[set];
if (!start) {
start = {x : width/2, y : height/2, radius : 1};
}
if (!e... | javascript | function(d) {
return function(t) {
var c = d.sets.map(function(set) {
var start = previous[set], end = circles[set];
if (!start) {
start = {x : width/2, y : height/2, radius : 1};
}
if (!e... | [
"function",
"(",
"d",
")",
"{",
"return",
"function",
"(",
"t",
")",
"{",
"var",
"c",
"=",
"d",
".",
"sets",
".",
"map",
"(",
"function",
"(",
"set",
")",
"{",
"var",
"start",
"=",
"previous",
"[",
"set",
"]",
",",
"end",
"=",
"circles",
"[",
... | interpolate intersection area paths between previous and current paths | [
"interpolate",
"intersection",
"area",
"paths",
"between",
"previous",
"and",
"current",
"paths"
] | 5ff0ef3ff450803a50c69493cd2bb6ce8b04f9fb | https://github.com/benfred/venn.js/blob/5ff0ef3ff450803a50c69493cd2bb6ce8b04f9fb/src/diagram.js#L114-L130 | train | |
benfred/venn.js | src/diagram.js | shouldExclude | function shouldExclude(sets) {
for (var i = 0; i < sets.length; ++i) {
if (!(sets[i] in exclude)) {
return false;
}
}
return true;
} | javascript | function shouldExclude(sets) {
for (var i = 0; i < sets.length; ++i) {
if (!(sets[i] in exclude)) {
return false;
}
}
return true;
} | [
"function",
"shouldExclude",
"(",
"sets",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"sets",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"!",
"(",
"sets",
"[",
"i",
"]",
"in",
"exclude",
")",
")",
"{",
"return",
"false... | checks that all sets are in exclude; | [
"checks",
"that",
"all",
"sets",
"are",
"in",
"exclude",
";"
] | 5ff0ef3ff450803a50c69493cd2bb6ce8b04f9fb | https://github.com/benfred/venn.js/blob/5ff0ef3ff450803a50c69493cd2bb6ce8b04f9fb/src/diagram.js#L535-L542 | train |
benfred/venn.js | venn.js | containedInCircles | function containedInCircles(point, circles) {
for (var i = 0; i < circles.length; ++i) {
if (distance(point, circles[i]) > circles[i].radius + SMALL) {
return false;
}
}
return true;
} | javascript | function containedInCircles(point, circles) {
for (var i = 0; i < circles.length; ++i) {
if (distance(point, circles[i]) > circles[i].radius + SMALL) {
return false;
}
}
return true;
} | [
"function",
"containedInCircles",
"(",
"point",
",",
"circles",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"circles",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"distance",
"(",
"point",
",",
"circles",
"[",
"i",
"]",
")"... | returns whether a point is contained by all of a list of circles | [
"returns",
"whether",
"a",
"point",
"is",
"contained",
"by",
"all",
"of",
"a",
"list",
"of",
"circles"
] | 5ff0ef3ff450803a50c69493cd2bb6ce8b04f9fb | https://github.com/benfred/venn.js/blob/5ff0ef3ff450803a50c69493cd2bb6ce8b04f9fb/venn.js#L137-L144 | train |
benfred/venn.js | venn.js | getIntersectionPoints | function getIntersectionPoints(circles) {
var ret = [];
for (var i = 0; i < circles.length; ++i) {
for (var j = i + 1; j < circles.length; ++j) {
var intersect = circleCircleIntersection(circles[i],
circles[j]);
... | javascript | function getIntersectionPoints(circles) {
var ret = [];
for (var i = 0; i < circles.length; ++i) {
for (var j = i + 1; j < circles.length; ++j) {
var intersect = circleCircleIntersection(circles[i],
circles[j]);
... | [
"function",
"getIntersectionPoints",
"(",
"circles",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"circles",
".",
"length",
";",
"++",
"i",
")",
"{",
"for",
"(",
"var",
"j",
"=",
"i",
"+",
"1",
... | Gets all intersection points between a bunch of circles | [
"Gets",
"all",
"intersection",
"points",
"between",
"a",
"bunch",
"of",
"circles"
] | 5ff0ef3ff450803a50c69493cd2bb6ce8b04f9fb | https://github.com/benfred/venn.js/blob/5ff0ef3ff450803a50c69493cd2bb6ce8b04f9fb/venn.js#L147-L161 | train |
benfred/venn.js | venn.js | distance | function distance(p1, p2) {
return Math.sqrt((p1.x - p2.x) * (p1.x - p2.x) +
(p1.y - p2.y) * (p1.y - p2.y));
} | javascript | function distance(p1, p2) {
return Math.sqrt((p1.x - p2.x) * (p1.x - p2.x) +
(p1.y - p2.y) * (p1.y - p2.y));
} | [
"function",
"distance",
"(",
"p1",
",",
"p2",
")",
"{",
"return",
"Math",
".",
"sqrt",
"(",
"(",
"p1",
".",
"x",
"-",
"p2",
".",
"x",
")",
"*",
"(",
"p1",
".",
"x",
"-",
"p2",
".",
"x",
")",
"+",
"(",
"p1",
".",
"y",
"-",
"p2",
".",
"y"... | euclidean distance between two points | [
"euclidean",
"distance",
"between",
"two",
"points"
] | 5ff0ef3ff450803a50c69493cd2bb6ce8b04f9fb | https://github.com/benfred/venn.js/blob/5ff0ef3ff450803a50c69493cd2bb6ce8b04f9fb/venn.js#L169-L172 | train |
benfred/venn.js | venn.js | circleOverlap | function circleOverlap(r1, r2, d) {
// no overlap
if (d >= r1 + r2) {
return 0;
}
// completely overlapped
if (d <= Math.abs(r1 - r2)) {
return Math.PI * Math.min(r1, r2) * Math.min(r1, r2);
}
var w1 = r1 - (d * d - r2 * r2 + r1 * r1) / (... | javascript | function circleOverlap(r1, r2, d) {
// no overlap
if (d >= r1 + r2) {
return 0;
}
// completely overlapped
if (d <= Math.abs(r1 - r2)) {
return Math.PI * Math.min(r1, r2) * Math.min(r1, r2);
}
var w1 = r1 - (d * d - r2 * r2 + r1 * r1) / (... | [
"function",
"circleOverlap",
"(",
"r1",
",",
"r2",
",",
"d",
")",
"{",
"// no overlap",
"if",
"(",
"d",
">=",
"r1",
"+",
"r2",
")",
"{",
"return",
"0",
";",
"}",
"// completely overlapped",
"if",
"(",
"d",
"<=",
"Math",
".",
"abs",
"(",
"r1",
"-",
... | Returns the overlap area of two circles of radius r1 and r2 - that
have their centers separated by distance d. Simpler faster
circle intersection for only two circles | [
"Returns",
"the",
"overlap",
"area",
"of",
"two",
"circles",
"of",
"radius",
"r1",
"and",
"r2",
"-",
"that",
"have",
"their",
"centers",
"separated",
"by",
"distance",
"d",
".",
"Simpler",
"faster",
"circle",
"intersection",
"for",
"only",
"two",
"circles"
] | 5ff0ef3ff450803a50c69493cd2bb6ce8b04f9fb | https://github.com/benfred/venn.js/blob/5ff0ef3ff450803a50c69493cd2bb6ce8b04f9fb/venn.js#L178-L192 | train |
benfred/venn.js | venn.js | getCenter | function getCenter(points) {
var center = {x: 0, y: 0};
for (var i =0; i < points.length; ++i ) {
center.x += points[i].x;
center.y += points[i].y;
}
center.x /= points.length;
center.y /= points.length;
return center;
} | javascript | function getCenter(points) {
var center = {x: 0, y: 0};
for (var i =0; i < points.length; ++i ) {
center.x += points[i].x;
center.y += points[i].y;
}
center.x /= points.length;
center.y /= points.length;
return center;
} | [
"function",
"getCenter",
"(",
"points",
")",
"{",
"var",
"center",
"=",
"{",
"x",
":",
"0",
",",
"y",
":",
"0",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"points",
".",
"length",
";",
"++",
"i",
")",
"{",
"center",
".",
"x"... | Returns the center of a bunch of points | [
"Returns",
"the",
"center",
"of",
"a",
"bunch",
"of",
"points"
] | 5ff0ef3ff450803a50c69493cd2bb6ce8b04f9fb | https://github.com/benfred/venn.js/blob/5ff0ef3ff450803a50c69493cd2bb6ce8b04f9fb/venn.js#L220-L229 | train |
benfred/venn.js | venn.js | bisect | function bisect(f, a, b, parameters) {
parameters = parameters || {};
var maxIterations = parameters.maxIterations || 100,
tolerance = parameters.tolerance || 1e-10,
fA = f(a),
fB = f(b),
delta = b - a;
if (fA * fB > 0) {
throw "Initia... | javascript | function bisect(f, a, b, parameters) {
parameters = parameters || {};
var maxIterations = parameters.maxIterations || 100,
tolerance = parameters.tolerance || 1e-10,
fA = f(a),
fB = f(b),
delta = b - a;
if (fA * fB > 0) {
throw "Initia... | [
"function",
"bisect",
"(",
"f",
",",
"a",
",",
"b",
",",
"parameters",
")",
"{",
"parameters",
"=",
"parameters",
"||",
"{",
"}",
";",
"var",
"maxIterations",
"=",
"parameters",
".",
"maxIterations",
"||",
"100",
",",
"tolerance",
"=",
"parameters",
".",... | finds the zeros of a function, given two starting points (which must
have opposite signs | [
"finds",
"the",
"zeros",
"of",
"a",
"function",
"given",
"two",
"starting",
"points",
"(",
"which",
"must",
"have",
"opposite",
"signs"
] | 5ff0ef3ff450803a50c69493cd2bb6ce8b04f9fb | https://github.com/benfred/venn.js/blob/5ff0ef3ff450803a50c69493cd2bb6ce8b04f9fb/venn.js#L233-L262 | train |
benfred/venn.js | venn.js | distanceFromIntersectArea | function distanceFromIntersectArea(r1, r2, overlap) {
// handle complete overlapped circles
if (Math.min(r1, r2) * Math.min(r1,r2) * Math.PI <= overlap + SMALL$1) {
return Math.abs(r1 - r2);
}
return bisect(function(distance$$1) {
return circleOverlap(r1, r2, dis... | javascript | function distanceFromIntersectArea(r1, r2, overlap) {
// handle complete overlapped circles
if (Math.min(r1, r2) * Math.min(r1,r2) * Math.PI <= overlap + SMALL$1) {
return Math.abs(r1 - r2);
}
return bisect(function(distance$$1) {
return circleOverlap(r1, r2, dis... | [
"function",
"distanceFromIntersectArea",
"(",
"r1",
",",
"r2",
",",
"overlap",
")",
"{",
"// handle complete overlapped circles",
"if",
"(",
"Math",
".",
"min",
"(",
"r1",
",",
"r2",
")",
"*",
"Math",
".",
"min",
"(",
"r1",
",",
"r2",
")",
"*",
"Math",
... | Returns the distance necessary for two circles of radius r1 + r2 to
have the overlap area 'overlap' | [
"Returns",
"the",
"distance",
"necessary",
"for",
"two",
"circles",
"of",
"radius",
"r1",
"+",
"r2",
"to",
"have",
"the",
"overlap",
"area",
"overlap"
] | 5ff0ef3ff450803a50c69493cd2bb6ce8b04f9fb | https://github.com/benfred/venn.js/blob/5ff0ef3ff450803a50c69493cd2bb6ce8b04f9fb/venn.js#L623-L632 | train |
highsource/jsonix | scripts/src/main/javascript/org/hisrc/jsonix/Jsonix/Model/ClassInfo.js | function(value, context, scope) {
return this.isInstance(value, context, scope) || (Jsonix.Util.Type.isObject(value) && !Jsonix.Util.Type.isArray(value));
} | javascript | function(value, context, scope) {
return this.isInstance(value, context, scope) || (Jsonix.Util.Type.isObject(value) && !Jsonix.Util.Type.isArray(value));
} | [
"function",
"(",
"value",
",",
"context",
",",
"scope",
")",
"{",
"return",
"this",
".",
"isInstance",
"(",
"value",
",",
"context",
",",
"scope",
")",
"||",
"(",
"Jsonix",
".",
"Util",
".",
"Type",
".",
"isObject",
"(",
"value",
")",
"&&",
"!",
"J... | Checks if the value is marshallable | [
"Checks",
"if",
"the",
"value",
"is",
"marshallable"
] | cb622447c59435558dd3142f3c460fbb6a274a3a | https://github.com/highsource/jsonix/blob/cb622447c59435558dd3142f3c460fbb6a274a3a/scripts/src/main/javascript/org/hisrc/jsonix/Jsonix/Model/ClassInfo.js#L252-L254 | train | |
ded/script.js | vendor/mootools.js | function(value){
value = Function.from(value)();
value = (typeof value == 'string') ? value.split(' ') : Array.from(value);
return value.map(function(val){
val = String(val);
var found = false;
Object.each(Fx.CSS.Parsers, function(parser, key){
if (found) return;
var parsed = parser.parse(val);
... | javascript | function(value){
value = Function.from(value)();
value = (typeof value == 'string') ? value.split(' ') : Array.from(value);
return value.map(function(val){
val = String(val);
var found = false;
Object.each(Fx.CSS.Parsers, function(parser, key){
if (found) return;
var parsed = parser.parse(val);
... | [
"function",
"(",
"value",
")",
"{",
"value",
"=",
"Function",
".",
"from",
"(",
"value",
")",
"(",
")",
";",
"value",
"=",
"(",
"typeof",
"value",
"==",
"'string'",
")",
"?",
"value",
".",
"split",
"(",
"' '",
")",
":",
"Array",
".",
"from",
"(",... | parses a value into an array | [
"parses",
"a",
"value",
"into",
"an",
"array"
] | 95ca7a60c75e266a492262e29dacb3ec2ea15a95 | https://github.com/ded/script.js/blob/95ca7a60c75e266a492262e29dacb3ec2ea15a95/vendor/mootools.js#L4616-L4630 | train | |
ded/script.js | vendor/mootools.js | function(from, to, delta){
var computed = [];
(Math.min(from.length, to.length)).times(function(i){
computed.push({value: from[i].parser.compute(from[i].value, to[i].value, delta), parser: from[i].parser});
});
computed.$family = Function.from('fx:css:value');
return computed;
} | javascript | function(from, to, delta){
var computed = [];
(Math.min(from.length, to.length)).times(function(i){
computed.push({value: from[i].parser.compute(from[i].value, to[i].value, delta), parser: from[i].parser});
});
computed.$family = Function.from('fx:css:value');
return computed;
} | [
"function",
"(",
"from",
",",
"to",
",",
"delta",
")",
"{",
"var",
"computed",
"=",
"[",
"]",
";",
"(",
"Math",
".",
"min",
"(",
"from",
".",
"length",
",",
"to",
".",
"length",
")",
")",
".",
"times",
"(",
"function",
"(",
"i",
")",
"{",
"co... | computes by a from and to prepared objects, using their parsers. | [
"computes",
"by",
"a",
"from",
"and",
"to",
"prepared",
"objects",
"using",
"their",
"parsers",
"."
] | 95ca7a60c75e266a492262e29dacb3ec2ea15a95 | https://github.com/ded/script.js/blob/95ca7a60c75e266a492262e29dacb3ec2ea15a95/vendor/mootools.js#L4634-L4641 | train | |
ded/script.js | vendor/mootools.js | function(value, unit){
if (typeOf(value) != 'fx:css:value') value = this.parse(value);
var returned = [];
value.each(function(bit){
returned = returned.concat(bit.parser.serve(bit.value, unit));
});
return returned;
} | javascript | function(value, unit){
if (typeOf(value) != 'fx:css:value') value = this.parse(value);
var returned = [];
value.each(function(bit){
returned = returned.concat(bit.parser.serve(bit.value, unit));
});
return returned;
} | [
"function",
"(",
"value",
",",
"unit",
")",
"{",
"if",
"(",
"typeOf",
"(",
"value",
")",
"!=",
"'fx:css:value'",
")",
"value",
"=",
"this",
".",
"parse",
"(",
"value",
")",
";",
"var",
"returned",
"=",
"[",
"]",
";",
"value",
".",
"each",
"(",
"f... | serves the value as settable | [
"serves",
"the",
"value",
"as",
"settable"
] | 95ca7a60c75e266a492262e29dacb3ec2ea15a95 | https://github.com/ded/script.js/blob/95ca7a60c75e266a492262e29dacb3ec2ea15a95/vendor/mootools.js#L4645-L4652 | train | |
ded/script.js | vendor/mootools.js | function(element, property, value, unit){
element.setStyle(property, this.serve(value, unit));
} | javascript | function(element, property, value, unit){
element.setStyle(property, this.serve(value, unit));
} | [
"function",
"(",
"element",
",",
"property",
",",
"value",
",",
"unit",
")",
"{",
"element",
".",
"setStyle",
"(",
"property",
",",
"this",
".",
"serve",
"(",
"value",
",",
"unit",
")",
")",
";",
"}"
] | renders the change to an element | [
"renders",
"the",
"change",
"to",
"an",
"element"
] | 95ca7a60c75e266a492262e29dacb3ec2ea15a95 | https://github.com/ded/script.js/blob/95ca7a60c75e266a492262e29dacb3ec2ea15a95/vendor/mootools.js#L4656-L4658 | train | |
ded/script.js | vendor/lab2.js | isScriptLoaded | function isScriptLoaded(elem,scriptentry) {
if ((elem[sREADYSTATE] && elem[sREADYSTATE]!==sCOMPLETE && elem[sREADYSTATE]!=="loaded") || scriptentry[sDONE]) { return bFALSE; }
elem[sONLOAD] = elem[sONREADYSTATECHANGE] = nNULL; // prevent memory leak
return bTRUE;
} | javascript | function isScriptLoaded(elem,scriptentry) {
if ((elem[sREADYSTATE] && elem[sREADYSTATE]!==sCOMPLETE && elem[sREADYSTATE]!=="loaded") || scriptentry[sDONE]) { return bFALSE; }
elem[sONLOAD] = elem[sONREADYSTATECHANGE] = nNULL; // prevent memory leak
return bTRUE;
} | [
"function",
"isScriptLoaded",
"(",
"elem",
",",
"scriptentry",
")",
"{",
"if",
"(",
"(",
"elem",
"[",
"sREADYSTATE",
"]",
"&&",
"elem",
"[",
"sREADYSTATE",
"]",
"!==",
"sCOMPLETE",
"&&",
"elem",
"[",
"sREADYSTATE",
"]",
"!==",
"\"loaded\"",
")",
"||",
"s... | if all flags are turned off, preload is moot so disable it | [
"if",
"all",
"flags",
"are",
"turned",
"off",
"preload",
"is",
"moot",
"so",
"disable",
"it"
] | 95ca7a60c75e266a492262e29dacb3ec2ea15a95 | https://github.com/ded/script.js/blob/95ca7a60c75e266a492262e29dacb3ec2ea15a95/vendor/lab2.js#L113-L117 | train |
bigspotteddog/ScrollToFixed | jquery-scrolltofixed.js | resetScroll | function resetScroll() {
// Set the element to it original positioning.
target.trigger('preUnfixed.ScrollToFixed');
setUnfixed();
target.trigger('unfixed.ScrollToFixed');
// Reset the last offset used to determine if the page has moved
// horizont... | javascript | function resetScroll() {
// Set the element to it original positioning.
target.trigger('preUnfixed.ScrollToFixed');
setUnfixed();
target.trigger('unfixed.ScrollToFixed');
// Reset the last offset used to determine if the page has moved
// horizont... | [
"function",
"resetScroll",
"(",
")",
"{",
"// Set the element to it original positioning.",
"target",
".",
"trigger",
"(",
"'preUnfixed.ScrollToFixed'",
")",
";",
"setUnfixed",
"(",
")",
";",
"target",
".",
"trigger",
"(",
"'unfixed.ScrollToFixed'",
")",
";",
"// Rese... | Capture the original offsets for the target element. This needs to be called whenever the page size changes or when the page is first scrolled. For some reason, calling this before the page is first scrolled causes the element to become fixed too late. | [
"Capture",
"the",
"original",
"offsets",
"for",
"the",
"target",
"element",
".",
"This",
"needs",
"to",
"be",
"called",
"whenever",
"the",
"page",
"size",
"changes",
"or",
"when",
"the",
"page",
"is",
"first",
"scrolled",
".",
"For",
"some",
"reason",
"cal... | a2f9dc0d20cfc8fc2468f5b2937fbc11937e2a98 | https://github.com/bigspotteddog/ScrollToFixed/blob/a2f9dc0d20cfc8fc2468f5b2937fbc11937e2a98/jquery-scrolltofixed.js#L65-L100 | train |
bigspotteddog/ScrollToFixed | jquery-scrolltofixed.js | setFixed | function setFixed() {
// Only fix the target element and the spacer if we need to.
if (!isFixed()) {
//get REAL dimensions (decimal fix)
//Ref. http://stackoverflow.com/questions/3603065/how-to-make-jquery-to-not-round-value-returned-by-width
var d... | javascript | function setFixed() {
// Only fix the target element and the spacer if we need to.
if (!isFixed()) {
//get REAL dimensions (decimal fix)
//Ref. http://stackoverflow.com/questions/3603065/how-to-make-jquery-to-not-round-value-returned-by-width
var d... | [
"function",
"setFixed",
"(",
")",
"{",
"// Only fix the target element and the spacer if we need to.",
"if",
"(",
"!",
"isFixed",
"(",
")",
")",
"{",
"//get REAL dimensions (decimal fix)",
"//Ref. http://stackoverflow.com/questions/3603065/how-to-make-jquery-to-not-round-value-returned... | Sets the target element to fixed. Also, sets the spacer to fill the void left by the target element. | [
"Sets",
"the",
"target",
"element",
"to",
"fixed",
".",
"Also",
"sets",
"the",
"spacer",
"to",
"fill",
"the",
"void",
"left",
"by",
"the",
"target",
"element",
"."
] | a2f9dc0d20cfc8fc2468f5b2937fbc11937e2a98 | https://github.com/bigspotteddog/ScrollToFixed/blob/a2f9dc0d20cfc8fc2468f5b2937fbc11937e2a98/jquery-scrolltofixed.js#L128-L167 | train |
bigspotteddog/ScrollToFixed | jquery-scrolltofixed.js | setUnfixed | function setUnfixed() {
// Only unfix the target element and the spacer if we need to.
if (!isUnfixed()) {
lastOffsetLeft = -1;
// Hide the spacer now that the target element will fill the
// space.
spacer.css('display', 'none');
... | javascript | function setUnfixed() {
// Only unfix the target element and the spacer if we need to.
if (!isUnfixed()) {
lastOffsetLeft = -1;
// Hide the spacer now that the target element will fill the
// space.
spacer.css('display', 'none');
... | [
"function",
"setUnfixed",
"(",
")",
"{",
"// Only unfix the target element and the spacer if we need to.",
"if",
"(",
"!",
"isUnfixed",
"(",
")",
")",
"{",
"lastOffsetLeft",
"=",
"-",
"1",
";",
"// Hide the spacer now that the target element will fill the",
"// space.",
"sp... | Sets the target element back to unfixed. Also, hides the spacer. | [
"Sets",
"the",
"target",
"element",
"back",
"to",
"unfixed",
".",
"Also",
"hides",
"the",
"spacer",
"."
] | a2f9dc0d20cfc8fc2468f5b2937fbc11937e2a98 | https://github.com/bigspotteddog/ScrollToFixed/blob/a2f9dc0d20cfc8fc2468f5b2937fbc11937e2a98/jquery-scrolltofixed.js#L194-L222 | train |
bigspotteddog/ScrollToFixed | jquery-scrolltofixed.js | setLeft | function setLeft(x) {
// Only if the scroll is not what it was last time we did this.
if (x != lastOffsetLeft) {
// Move the target element horizontally relative to its original
// horizontal position.
target.css('left', offsetLeft - x);
... | javascript | function setLeft(x) {
// Only if the scroll is not what it was last time we did this.
if (x != lastOffsetLeft) {
// Move the target element horizontally relative to its original
// horizontal position.
target.css('left', offsetLeft - x);
... | [
"function",
"setLeft",
"(",
"x",
")",
"{",
"// Only if the scroll is not what it was last time we did this.",
"if",
"(",
"x",
"!=",
"lastOffsetLeft",
")",
"{",
"// Move the target element horizontally relative to its original",
"// horizontal position.",
"target",
".",
"css",
"... | Moves the target element left or right relative to the horizontal scroll position. | [
"Moves",
"the",
"target",
"element",
"left",
"or",
"right",
"relative",
"to",
"the",
"horizontal",
"scroll",
"position",
"."
] | a2f9dc0d20cfc8fc2468f5b2937fbc11937e2a98 | https://github.com/bigspotteddog/ScrollToFixed/blob/a2f9dc0d20cfc8fc2468f5b2937fbc11937e2a98/jquery-scrolltofixed.js#L226-L236 | train |
h2non/jshashes | hashes.js | rstr2binb | function rstr2binb(input) {
var i, l = input.length * 8,
output = Array(input.length >> 2),
lo = output.length;
for (i = 0; i < lo; i += 1) {
output[i] = 0;
}
for (i = 0; i < l; i += 8) {
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (24 - i % 32);
}
return output... | javascript | function rstr2binb(input) {
var i, l = input.length * 8,
output = Array(input.length >> 2),
lo = output.length;
for (i = 0; i < lo; i += 1) {
output[i] = 0;
}
for (i = 0; i < l; i += 8) {
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (24 - i % 32);
}
return output... | [
"function",
"rstr2binb",
"(",
"input",
")",
"{",
"var",
"i",
",",
"l",
"=",
"input",
".",
"length",
"*",
"8",
",",
"output",
"=",
"Array",
"(",
"input",
".",
"length",
">>",
"2",
")",
",",
"lo",
"=",
"output",
".",
"length",
";",
"for",
"(",
"i... | Convert a raw string to an array of big-endian words
Characters >255 have their high-byte silently ignored. | [
"Convert",
"a",
"raw",
"string",
"to",
"an",
"array",
"of",
"big",
"-",
"endian",
"words",
"Characters",
">",
"255",
"have",
"their",
"high",
"-",
"byte",
"silently",
"ignored",
"."
] | 88625b6c841ca3c90f8b9fefb0fedb78992017ad | https://github.com/h2non/jshashes/blob/88625b6c841ca3c90f8b9fefb0fedb78992017ad/hashes.js#L189-L200 | train |
h2non/jshashes | hashes.js | function(str) {
var crc = 0,
x = 0,
y = 0,
table, i, iTop;
str = utf8Encode(str);
table = [
'00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 ',
'79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3... | javascript | function(str) {
var crc = 0,
x = 0,
y = 0,
table, i, iTop;
str = utf8Encode(str);
table = [
'00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 ',
'79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3... | [
"function",
"(",
"str",
")",
"{",
"var",
"crc",
"=",
"0",
",",
"x",
"=",
"0",
",",
"y",
"=",
"0",
",",
"table",
",",
"i",
",",
"iTop",
";",
"str",
"=",
"utf8Encode",
"(",
"str",
")",
";",
"table",
"=",
"[",
"'00000000 77073096 EE0E612C 990951BA 076... | CRC-32 calculation
@member Hashes
@method CRC32
@static
@param {String} str Input String
@return {String} | [
"CRC",
"-",
"32",
"calculation"
] | 88625b6c841ca3c90f8b9fefb0fedb78992017ad | https://github.com/h2non/jshashes/blob/88625b6c841ca3c90f8b9fefb0fedb78992017ad/hashes.js#L384-L428 | train | |
h2non/jshashes | hashes.js | rstr | function rstr(s) {
s = (utf8) ? utf8Encode(s) : s;
return binl2rstr(binl(rstr2binl(s), s.length * 8));
} | javascript | function rstr(s) {
s = (utf8) ? utf8Encode(s) : s;
return binl2rstr(binl(rstr2binl(s), s.length * 8));
} | [
"function",
"rstr",
"(",
"s",
")",
"{",
"s",
"=",
"(",
"utf8",
")",
"?",
"utf8Encode",
"(",
"s",
")",
":",
"s",
";",
"return",
"binl2rstr",
"(",
"binl",
"(",
"rstr2binl",
"(",
"s",
")",
",",
"s",
".",
"length",
"*",
"8",
")",
")",
";",
"}"
] | private methods
Calculate the MD5 of a raw string | [
"private",
"methods",
"Calculate",
"the",
"MD5",
"of",
"a",
"raw",
"string"
] | 88625b6c841ca3c90f8b9fefb0fedb78992017ad | https://github.com/h2non/jshashes/blob/88625b6c841ca3c90f8b9fefb0fedb78992017ad/hashes.js#L518-L521 | train |
h2non/jshashes | hashes.js | rstr | function rstr(s, utf8) {
s = (utf8) ? utf8Encode(s) : s;
return binb2rstr(binb(rstr2binb(s), s.length * 8));
} | javascript | function rstr(s, utf8) {
s = (utf8) ? utf8Encode(s) : s;
return binb2rstr(binb(rstr2binb(s), s.length * 8));
} | [
"function",
"rstr",
"(",
"s",
",",
"utf8",
")",
"{",
"s",
"=",
"(",
"utf8",
")",
"?",
"utf8Encode",
"(",
"s",
")",
":",
"s",
";",
"return",
"binb2rstr",
"(",
"binb",
"(",
"rstr2binb",
"(",
"s",
")",
",",
"s",
".",
"length",
"*",
"8",
")",
")"... | private methods
Calculate the SHA-512 of a raw string | [
"private",
"methods",
"Calculate",
"the",
"SHA",
"-",
"512",
"of",
"a",
"raw",
"string"
] | 88625b6c841ca3c90f8b9fefb0fedb78992017ad | https://github.com/h2non/jshashes/blob/88625b6c841ca3c90f8b9fefb0fedb78992017ad/hashes.js#L956-L959 | train |
h2non/jshashes | hashes.js | int64copy | function int64copy(dst, src) {
dst.h = src.h;
dst.l = src.l;
} | javascript | function int64copy(dst, src) {
dst.h = src.h;
dst.l = src.l;
} | [
"function",
"int64copy",
"(",
"dst",
",",
"src",
")",
"{",
"dst",
".",
"h",
"=",
"src",
".",
"h",
";",
"dst",
".",
"l",
"=",
"src",
".",
"l",
";",
"}"
] | Copies src into dst, assuming both are 64-bit numbers | [
"Copies",
"src",
"into",
"dst",
"assuming",
"both",
"are",
"64",
"-",
"bit",
"numbers"
] | 88625b6c841ca3c90f8b9fefb0fedb78992017ad | https://github.com/h2non/jshashes/blob/88625b6c841ca3c90f8b9fefb0fedb78992017ad/hashes.js#L1417-L1420 | train |
h2non/jshashes | hashes.js | int64revrrot | function int64revrrot(dst, x, shift) {
dst.l = (x.h >>> shift) | (x.l << (32 - shift));
dst.h = (x.l >>> shift) | (x.h << (32 - shift));
} | javascript | function int64revrrot(dst, x, shift) {
dst.l = (x.h >>> shift) | (x.l << (32 - shift));
dst.h = (x.l >>> shift) | (x.h << (32 - shift));
} | [
"function",
"int64revrrot",
"(",
"dst",
",",
"x",
",",
"shift",
")",
"{",
"dst",
".",
"l",
"=",
"(",
"x",
".",
"h",
">>>",
"shift",
")",
"|",
"(",
"x",
".",
"l",
"<<",
"(",
"32",
"-",
"shift",
")",
")",
";",
"dst",
".",
"h",
"=",
"(",
"x"... | Reverses the dwords of the source and then rotates right by shift. This is equivalent to rotation by 32+shift | [
"Reverses",
"the",
"dwords",
"of",
"the",
"source",
"and",
"then",
"rotates",
"right",
"by",
"shift",
".",
"This",
"is",
"equivalent",
"to",
"rotation",
"by",
"32",
"+",
"shift"
] | 88625b6c841ca3c90f8b9fefb0fedb78992017ad | https://github.com/h2non/jshashes/blob/88625b6c841ca3c90f8b9fefb0fedb78992017ad/hashes.js#L1434-L1437 | train |
h2non/jshashes | hashes.js | int64shr | function int64shr(dst, x, shift) {
dst.l = (x.l >>> shift) | (x.h << (32 - shift));
dst.h = (x.h >>> shift);
} | javascript | function int64shr(dst, x, shift) {
dst.l = (x.l >>> shift) | (x.h << (32 - shift));
dst.h = (x.h >>> shift);
} | [
"function",
"int64shr",
"(",
"dst",
",",
"x",
",",
"shift",
")",
"{",
"dst",
".",
"l",
"=",
"(",
"x",
".",
"l",
">>>",
"shift",
")",
"|",
"(",
"x",
".",
"h",
"<<",
"(",
"32",
"-",
"shift",
")",
")",
";",
"dst",
".",
"h",
"=",
"(",
"x",
... | Bitwise-shifts right a 64-bit number by shift Won't handle shift>=32, but it's never needed in SHA512 | [
"Bitwise",
"-",
"shifts",
"right",
"a",
"64",
"-",
"bit",
"number",
"by",
"shift",
"Won",
"t",
"handle",
"shift",
">",
"=",
"32",
"but",
"it",
"s",
"never",
"needed",
"in",
"SHA512"
] | 88625b6c841ca3c90f8b9fefb0fedb78992017ad | https://github.com/h2non/jshashes/blob/88625b6c841ca3c90f8b9fefb0fedb78992017ad/hashes.js#L1442-L1445 | train |
h2non/jshashes | hashes.js | int64add | function int64add(dst, x, y) {
var w0 = (x.l & 0xffff) + (y.l & 0xffff);
var w1 = (x.l >>> 16) + (y.l >>> 16) + (w0 >>> 16);
var w2 = (x.h & 0xffff) + (y.h & 0xffff) + (w1 >>> 16);
var w3 = (x.h >>> 16) + (y.h >>> 16) + (w2 >>> 16);
dst.l = (w0 & 0xffff) | (w1 << 16);
dst... | javascript | function int64add(dst, x, y) {
var w0 = (x.l & 0xffff) + (y.l & 0xffff);
var w1 = (x.l >>> 16) + (y.l >>> 16) + (w0 >>> 16);
var w2 = (x.h & 0xffff) + (y.h & 0xffff) + (w1 >>> 16);
var w3 = (x.h >>> 16) + (y.h >>> 16) + (w2 >>> 16);
dst.l = (w0 & 0xffff) | (w1 << 16);
dst... | [
"function",
"int64add",
"(",
"dst",
",",
"x",
",",
"y",
")",
"{",
"var",
"w0",
"=",
"(",
"x",
".",
"l",
"&",
"0xffff",
")",
"+",
"(",
"y",
".",
"l",
"&",
"0xffff",
")",
";",
"var",
"w1",
"=",
"(",
"x",
".",
"l",
">>>",
"16",
")",
"+",
"... | Adds two 64-bit numbers Like the original implementation, does not rely on 32-bit operations | [
"Adds",
"two",
"64",
"-",
"bit",
"numbers",
"Like",
"the",
"original",
"implementation",
"does",
"not",
"rely",
"on",
"32",
"-",
"bit",
"operations"
] | 88625b6c841ca3c90f8b9fefb0fedb78992017ad | https://github.com/h2non/jshashes/blob/88625b6c841ca3c90f8b9fefb0fedb78992017ad/hashes.js#L1450-L1457 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.