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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
stylus/stylus | lib/functions/unit.js | unit | function unit(unit, type){
utils.assertType(unit, 'unit', 'unit');
// Assign
if (type) {
utils.assertString(type, 'type');
return new nodes.Unit(unit.val, type.string);
} else {
return unit.type || '';
}
} | javascript | function unit(unit, type){
utils.assertType(unit, 'unit', 'unit');
// Assign
if (type) {
utils.assertString(type, 'type');
return new nodes.Unit(unit.val, type.string);
} else {
return unit.type || '';
}
} | [
"function",
"unit",
"(",
"unit",
",",
"type",
")",
"{",
"utils",
".",
"assertType",
"(",
"unit",
",",
"'unit'",
",",
"'unit'",
")",
";",
"// Assign",
"if",
"(",
"type",
")",
"{",
"utils",
".",
"assertString",
"(",
"type",
",",
"'type'",
")",
";",
"... | Assign `type` to the given `unit` or return `unit`'s type.
@param {Unit} unit
@param {String|Ident} type
@return {Unit}
@api public | [
"Assign",
"type",
"to",
"the",
"given",
"unit",
"or",
"return",
"unit",
"s",
"type",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/unit.js#L13-L23 | train |
stylus/stylus | lib/functions/hsl.js | hsl | function hsl(hue, saturation, lightness){
if (1 == arguments.length) {
utils.assertColor(hue, 'color');
return hue.hsla;
} else {
return hsla(
hue
, saturation
, lightness
, new nodes.Unit(1));
}
} | javascript | function hsl(hue, saturation, lightness){
if (1 == arguments.length) {
utils.assertColor(hue, 'color');
return hue.hsla;
} else {
return hsla(
hue
, saturation
, lightness
, new nodes.Unit(1));
}
} | [
"function",
"hsl",
"(",
"hue",
",",
"saturation",
",",
"lightness",
")",
"{",
"if",
"(",
"1",
"==",
"arguments",
".",
"length",
")",
"{",
"utils",
".",
"assertColor",
"(",
"hue",
",",
"'color'",
")",
";",
"return",
"hue",
".",
"hsla",
";",
"}",
"el... | Convert the given `color` to an `HSLA` node,
or h,s,l component values.
Examples:
hsl(10, 50, 30)
// => HSLA
hsl(#ffcc00)
// => HSLA
@param {Unit|HSLA|RGBA} hue
@param {Unit} saturation
@param {Unit} lightness
@return {HSLA}
@api public | [
"Convert",
"the",
"given",
"color",
"to",
"an",
"HSLA",
"node",
"or",
"h",
"s",
"l",
"component",
"values",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/hsl.js#L24-L35 | train |
stylus/stylus | lib/functions/lookup.js | lookup | function lookup(name){
utils.assertType(name, 'string', 'name');
var node = this.lookup(name.val);
if (!node) return nodes.null;
return this.visit(node);
} | javascript | function lookup(name){
utils.assertType(name, 'string', 'name');
var node = this.lookup(name.val);
if (!node) return nodes.null;
return this.visit(node);
} | [
"function",
"lookup",
"(",
"name",
")",
"{",
"utils",
".",
"assertType",
"(",
"name",
",",
"'string'",
",",
"'name'",
")",
";",
"var",
"node",
"=",
"this",
".",
"lookup",
"(",
"name",
".",
"val",
")",
";",
"if",
"(",
"!",
"node",
")",
"return",
"... | Lookup variable `name` or return Null.
@param {String} name
@return {Mixed}
@api public | [
"Lookup",
"variable",
"name",
"or",
"return",
"Null",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/lookup.js#L12-L17 | train |
stylus/stylus | lib/functions/substr.js | substr | function substr(val, start, length){
utils.assertString(val, 'val');
utils.assertType(start, 'unit', 'start');
length = length && length.val;
var res = val.string.substr(start.val, length);
return val instanceof nodes.Ident
? new nodes.Ident(res)
: new nodes.String(res);
} | javascript | function substr(val, start, length){
utils.assertString(val, 'val');
utils.assertType(start, 'unit', 'start');
length = length && length.val;
var res = val.string.substr(start.val, length);
return val instanceof nodes.Ident
? new nodes.Ident(res)
: new nodes.String(res);
} | [
"function",
"substr",
"(",
"val",
",",
"start",
",",
"length",
")",
"{",
"utils",
".",
"assertString",
"(",
"val",
",",
"'val'",
")",
";",
"utils",
".",
"assertType",
"(",
"start",
",",
"'unit'",
",",
"'start'",
")",
";",
"length",
"=",
"length",
"&&... | Returns substring of the given `val`.
@param {String|Ident} val
@param {Number} start
@param {Number} [length]
@return {String|Ident}
@api public | [
"Returns",
"substring",
"of",
"the",
"given",
"val",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/substr.js#L14-L22 | train |
stylus/stylus | lib/functions/image-size.js | imageSize | function imageSize(img, ignoreErr) {
utils.assertType(img, 'string', 'img');
try {
var img = new Image(this, img.string);
} catch (err) {
if (ignoreErr) {
return [new nodes.Unit(0), new nodes.Unit(0)];
} else {
throw err;
}
}
// Read size
img.open();
var size = img.size();
i... | javascript | function imageSize(img, ignoreErr) {
utils.assertType(img, 'string', 'img');
try {
var img = new Image(this, img.string);
} catch (err) {
if (ignoreErr) {
return [new nodes.Unit(0), new nodes.Unit(0)];
} else {
throw err;
}
}
// Read size
img.open();
var size = img.size();
i... | [
"function",
"imageSize",
"(",
"img",
",",
"ignoreErr",
")",
"{",
"utils",
".",
"assertType",
"(",
"img",
",",
"'string'",
",",
"'img'",
")",
";",
"try",
"{",
"var",
"img",
"=",
"new",
"Image",
"(",
"this",
",",
"img",
".",
"string",
")",
";",
"}",
... | Return the width and height of the given `img` path.
Examples:
image-size('foo.png')
// => 200px 100px
image-size('foo.png')[0]
// => 200px
image-size('foo.png')[1]
// => 100px
Can be used to test if the image exists,
using an optional argument set to `true`
(without this argument this function throws error
if the... | [
"Return",
"the",
"width",
"and",
"height",
"of",
"the",
"given",
"img",
"path",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/image-size.js#L35-L58 | train |
stylus/stylus | lib/functions/saturation.js | saturation | function saturation(color, value){
if (value) {
var hslaColor = color.hsla;
return hsla(
new nodes.Unit(hslaColor.h),
value,
new nodes.Unit(hslaColor.l),
new nodes.Unit(hslaColor.a)
)
}
return component(color, new nodes.String('saturation'));
} | javascript | function saturation(color, value){
if (value) {
var hslaColor = color.hsla;
return hsla(
new nodes.Unit(hslaColor.h),
value,
new nodes.Unit(hslaColor.l),
new nodes.Unit(hslaColor.a)
)
}
return component(color, new nodes.String('saturation'));
} | [
"function",
"saturation",
"(",
"color",
",",
"value",
")",
"{",
"if",
"(",
"value",
")",
"{",
"var",
"hslaColor",
"=",
"color",
".",
"hsla",
";",
"return",
"hsla",
"(",
"new",
"nodes",
".",
"Unit",
"(",
"hslaColor",
".",
"h",
")",
",",
"value",
","... | Return the saturation component of the given `color`,
or set the saturation component to the optional second `value` argument.
Examples:
saturation(#00c)
// => 100%
saturation(#00c, 50%)
// => #339
@param {RGBA|HSLA} color
@param {Unit} [value]
@return {Unit|RGBA}
@api public | [
"Return",
"the",
"saturation",
"component",
"of",
"the",
"given",
"color",
"or",
"set",
"the",
"saturation",
"component",
"to",
"the",
"optional",
"second",
"value",
"argument",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/saturation.js#L23-L34 | train |
stylus/stylus | lib/functions/error.js | error | function error(msg){
utils.assertType(msg, 'string', 'msg');
var err = new Error(msg.val);
err.fromStylus = true;
throw err;
} | javascript | function error(msg){
utils.assertType(msg, 'string', 'msg');
var err = new Error(msg.val);
err.fromStylus = true;
throw err;
} | [
"function",
"error",
"(",
"msg",
")",
"{",
"utils",
".",
"assertType",
"(",
"msg",
",",
"'string'",
",",
"'msg'",
")",
";",
"var",
"err",
"=",
"new",
"Error",
"(",
"msg",
".",
"val",
")",
";",
"err",
".",
"fromStylus",
"=",
"true",
";",
"throw",
... | Throw an error with the given `msg`.
@param {String} msg
@api public | [
"Throw",
"an",
"error",
"with",
"the",
"given",
"msg",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/error.js#L10-L15 | train |
stylus/stylus | lib/visitor/evaluator.js | importFile | function importFile(node, file, literal) {
var importStack = this.importStack
, Parser = require('../parser')
, stat;
// Handling the `require`
if (node.once) {
if (this.requireHistory[file]) return nodes.null;
this.requireHistory[file] = true;
if (literal && !this.includeCSS) {
return... | javascript | function importFile(node, file, literal) {
var importStack = this.importStack
, Parser = require('../parser')
, stat;
// Handling the `require`
if (node.once) {
if (this.requireHistory[file]) return nodes.null;
this.requireHistory[file] = true;
if (literal && !this.includeCSS) {
return... | [
"function",
"importFile",
"(",
"node",
",",
"file",
",",
"literal",
")",
"{",
"var",
"importStack",
"=",
"this",
".",
"importStack",
",",
"Parser",
"=",
"require",
"(",
"'../parser'",
")",
",",
"stat",
";",
"// Handling the `require`",
"if",
"(",
"node",
"... | Import `file` and return Block node.
@api private | [
"Import",
"file",
"and",
"return",
"Block",
"node",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/visitor/evaluator.js#L29-L104 | train |
stylus/stylus | lib/functions/define.js | define | function define(name, expr, global){
utils.assertType(name, 'string', 'name');
expr = utils.unwrap(expr);
var scope = this.currentScope;
if (global && global.toBoolean().isTrue) {
scope = this.global.scope;
}
var node = new nodes.Ident(name.val, expr);
scope.add(node);
return nodes.null;
} | javascript | function define(name, expr, global){
utils.assertType(name, 'string', 'name');
expr = utils.unwrap(expr);
var scope = this.currentScope;
if (global && global.toBoolean().isTrue) {
scope = this.global.scope;
}
var node = new nodes.Ident(name.val, expr);
scope.add(node);
return nodes.null;
} | [
"function",
"define",
"(",
"name",
",",
"expr",
",",
"global",
")",
"{",
"utils",
".",
"assertType",
"(",
"name",
",",
"'string'",
",",
"'name'",
")",
";",
"expr",
"=",
"utils",
".",
"unwrap",
"(",
"expr",
")",
";",
"var",
"scope",
"=",
"this",
"."... | Set a variable `name` on current scope.
@param {String} name
@param {Expression} expr
@param {Boolean} [global]
@api public | [
"Set",
"a",
"variable",
"name",
"on",
"current",
"scope",
"."
] | 7e98dc17368c62a6f8a95aa2e300e4ab02faf007 | https://github.com/stylus/stylus/blob/7e98dc17368c62a6f8a95aa2e300e4ab02faf007/lib/functions/define.js#L13-L23 | train |
ssbc/patchwork | modules/invite/invite.js | function (invite, cb) {
var id = api.keys.sync.id()
var data = ref.parseInvite(invite)
api.contact.async.followerOf(id, data.key, function (_, follows) {
if (follows) console.log('already following', cb())
else console.log('accept invite:' + invite, accept(invite, cb))
})
} | javascript | function (invite, cb) {
var id = api.keys.sync.id()
var data = ref.parseInvite(invite)
api.contact.async.followerOf(id, data.key, function (_, follows) {
if (follows) console.log('already following', cb())
else console.log('accept invite:' + invite, accept(invite, cb))
})
} | [
"function",
"(",
"invite",
",",
"cb",
")",
"{",
"var",
"id",
"=",
"api",
".",
"keys",
".",
"sync",
".",
"id",
"(",
")",
"var",
"data",
"=",
"ref",
".",
"parseInvite",
"(",
"invite",
")",
"api",
".",
"contact",
".",
"async",
".",
"followerOf",
"("... | like invite, but check whether we already follow them first | [
"like",
"invite",
"but",
"check",
"whether",
"we",
"already",
"follow",
"them",
"first"
] | 24108357c6dba54c0cbb481db26b5376510af529 | https://github.com/ssbc/patchwork/blob/24108357c6dba54c0cbb481db26b5376510af529/modules/invite/invite.js#L84-L91 | train | |
ssbc/patchwork | modules/intl/sync/i18n.js | _init | function _init () {
if (_locale) return
// TODO: Depject this!
i18nL.configure({
directory: appRoot + '/locales',
defaultLocale: 'en'
})
watch(api.settings.obs.get('patchwork.lang'), currentLocale => {
currentLocale = currentLocale || navigator.language
var locales = i18nL.g... | javascript | function _init () {
if (_locale) return
// TODO: Depject this!
i18nL.configure({
directory: appRoot + '/locales',
defaultLocale: 'en'
})
watch(api.settings.obs.get('patchwork.lang'), currentLocale => {
currentLocale = currentLocale || navigator.language
var locales = i18nL.g... | [
"function",
"_init",
"(",
")",
"{",
"if",
"(",
"_locale",
")",
"return",
"// TODO: Depject this!",
"i18nL",
".",
"configure",
"(",
"{",
"directory",
":",
"appRoot",
"+",
"'/locales'",
",",
"defaultLocale",
":",
"'en'",
"}",
")",
"watch",
"(",
"api",
".",
... | Init an subscribe to settings changes. | [
"Init",
"an",
"subscribe",
"to",
"settings",
"changes",
"."
] | 24108357c6dba54c0cbb481db26b5376510af529 | https://github.com/ssbc/patchwork/blob/24108357c6dba54c0cbb481db26b5376510af529/modules/intl/sync/i18n.js#L95-L122 | train |
ssbc/patchwork | index.js | quitIfAlreadyRunning | function quitIfAlreadyRunning () {
if (!electron.app.requestSingleInstanceLock()) {
return electron.app.quit()
}
electron.app.on('second-instance', (event, commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (windows.main) {
if (windows.m... | javascript | function quitIfAlreadyRunning () {
if (!electron.app.requestSingleInstanceLock()) {
return electron.app.quit()
}
electron.app.on('second-instance', (event, commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (windows.main) {
if (windows.m... | [
"function",
"quitIfAlreadyRunning",
"(",
")",
"{",
"if",
"(",
"!",
"electron",
".",
"app",
".",
"requestSingleInstanceLock",
"(",
")",
")",
"{",
"return",
"electron",
".",
"app",
".",
"quit",
"(",
")",
"}",
"electron",
".",
"app",
".",
"on",
"(",
"'sec... | It's not possible to run two instances of patchwork as it would create two
ssb-server instances that conflict on the same port. Before opening patchwork,
we check if it's already running and if it is we focus the existing window
rather than opening a new instance. | [
"It",
"s",
"not",
"possible",
"to",
"run",
"two",
"instances",
"of",
"patchwork",
"as",
"it",
"would",
"create",
"two",
"ssb",
"-",
"server",
"instances",
"that",
"conflict",
"on",
"the",
"same",
"port",
".",
"Before",
"opening",
"patchwork",
"we",
"check"... | 24108357c6dba54c0cbb481db26b5376510af529 | https://github.com/ssbc/patchwork/blob/24108357c6dba54c0cbb481db26b5376510af529/index.js#L28-L39 | train |
ssbc/patchwork | lib/sustained.js | Sustained | function Sustained (obs, timeThreshold, checkUpdateImmediately) {
var outputValue = Value(obs())
var lastValue = null
var timer = null
return computed(outputValue, v => v, {
onListen: () => watch(obs, onChange)
})
function onChange (value) {
if (checkUpdateImmediately && checkUpdateImmediately(val... | javascript | function Sustained (obs, timeThreshold, checkUpdateImmediately) {
var outputValue = Value(obs())
var lastValue = null
var timer = null
return computed(outputValue, v => v, {
onListen: () => watch(obs, onChange)
})
function onChange (value) {
if (checkUpdateImmediately && checkUpdateImmediately(val... | [
"function",
"Sustained",
"(",
"obs",
",",
"timeThreshold",
",",
"checkUpdateImmediately",
")",
"{",
"var",
"outputValue",
"=",
"Value",
"(",
"obs",
"(",
")",
")",
"var",
"lastValue",
"=",
"null",
"var",
"timer",
"=",
"null",
"return",
"computed",
"(",
"out... | only broadcast value changes once a truthy value has stayed constant for more than timeThreshold | [
"only",
"broadcast",
"value",
"changes",
"once",
"a",
"truthy",
"value",
"has",
"stayed",
"constant",
"for",
"more",
"than",
"timeThreshold"
] | 24108357c6dba54c0cbb481db26b5376510af529 | https://github.com/ssbc/patchwork/blob/24108357c6dba54c0cbb481db26b5376510af529/lib/sustained.js#L9-L36 | train |
katspaugh/wavesurfer.js | build-config/fragments/plugins.js | buildPluginEntry | function buildPluginEntry(plugins) {
const result = {};
plugins.forEach(
plugin =>
(result[path.basename(plugin, '.js')] = path.join(
pluginSrcDir,
plugin
))
);
return result;
} | javascript | function buildPluginEntry(plugins) {
const result = {};
plugins.forEach(
plugin =>
(result[path.basename(plugin, '.js')] = path.join(
pluginSrcDir,
plugin
))
);
return result;
} | [
"function",
"buildPluginEntry",
"(",
"plugins",
")",
"{",
"const",
"result",
"=",
"{",
"}",
";",
"plugins",
".",
"forEach",
"(",
"plugin",
"=>",
"(",
"result",
"[",
"path",
".",
"basename",
"(",
"plugin",
",",
"'.js'",
")",
"]",
"=",
"path",
".",
"jo... | buildPluginEntry - Description
@param {Array} plugins Name of plugins in src/plugin
@returns {object} Entry object { name: nameUrl } | [
"buildPluginEntry",
"-",
"Description"
] | 45144cf7d4a0424aff3878d918bda9a44197b6e4 | https://github.com/katspaugh/wavesurfer.js/blob/45144cf7d4a0424aff3878d918bda9a44197b6e4/build-config/fragments/plugins.js#L22-L32 | train |
katspaugh/wavesurfer.js | example/panner/main.js | function() {
var xDeg = parseInt(slider.value);
var x = Math.sin(xDeg * (Math.PI / 180));
wavesurfer.panner.setPosition(x, 0, 0);
} | javascript | function() {
var xDeg = parseInt(slider.value);
var x = Math.sin(xDeg * (Math.PI / 180));
wavesurfer.panner.setPosition(x, 0, 0);
} | [
"function",
"(",
")",
"{",
"var",
"xDeg",
"=",
"parseInt",
"(",
"slider",
".",
"value",
")",
";",
"var",
"x",
"=",
"Math",
".",
"sin",
"(",
"xDeg",
"*",
"(",
"Math",
".",
"PI",
"/",
"180",
")",
")",
";",
"wavesurfer",
".",
"panner",
".",
"setPo... | Bind panner slider @see http://stackoverflow.com/a/14412601/352796 | [
"Bind",
"panner",
"slider"
] | 45144cf7d4a0424aff3878d918bda9a44197b6e4 | https://github.com/katspaugh/wavesurfer.js/blob/45144cf7d4a0424aff3878d918bda9a44197b6e4/example/panner/main.js#L28-L32 | train | |
katspaugh/wavesurfer.js | example/stretcher/soundtouch.js | function(
aSampleRate,
aSequenceMS,
aSeekWindowMS,
aOverlapMS
) {
// accept only positive parameter values - if zero or negative, use old values instead
if (aSampleRate > 0) {
this.sampleRate = aSampleRate;
}
... | javascript | function(
aSampleRate,
aSequenceMS,
aSeekWindowMS,
aOverlapMS
) {
// accept only positive parameter values - if zero or negative, use old values instead
if (aSampleRate > 0) {
this.sampleRate = aSampleRate;
}
... | [
"function",
"(",
"aSampleRate",
",",
"aSequenceMS",
",",
"aSeekWindowMS",
",",
"aOverlapMS",
")",
"{",
"// accept only positive parameter values - if zero or negative, use old values instead",
"if",
"(",
"aSampleRate",
">",
"0",
")",
"{",
"this",
".",
"sampleRate",
"=",
... | Sets routine control parameters. These control are certain time constants
defining how the sound is stretched to the desired duration.
'sampleRate' = sample rate of the sound
'sequenceMS' = one processing sequence length in milliseconds (default = 82 ms)
'seekwindowMS' = seeking window length for scanning the best ove... | [
"Sets",
"routine",
"control",
"parameters",
".",
"These",
"control",
"are",
"certain",
"time",
"constants",
"defining",
"how",
"the",
"sound",
"is",
"stretched",
"to",
"the",
"desired",
"duration",
"."
] | 45144cf7d4a0424aff3878d918bda9a44197b6e4 | https://github.com/katspaugh/wavesurfer.js/blob/45144cf7d4a0424aff3878d918bda9a44197b6e4/example/stretcher/soundtouch.js#L588-L624 | train | |
katspaugh/wavesurfer.js | example/stretcher/soundtouch.js | function(overlapInMsec) {
var newOvl;
// TODO assert(overlapInMsec >= 0);
newOvl = (this.sampleRate * overlapInMsec) / 1000;
if (newOvl < 16) newOvl = 16;
// must be divisible by 8
newOvl -= newOvl % 8;
this.overlapLength = newOvl;
... | javascript | function(overlapInMsec) {
var newOvl;
// TODO assert(overlapInMsec >= 0);
newOvl = (this.sampleRate * overlapInMsec) / 1000;
if (newOvl < 16) newOvl = 16;
// must be divisible by 8
newOvl -= newOvl % 8;
this.overlapLength = newOvl;
... | [
"function",
"(",
"overlapInMsec",
")",
"{",
"var",
"newOvl",
";",
"// TODO assert(overlapInMsec >= 0);",
"newOvl",
"=",
"(",
"this",
".",
"sampleRate",
"*",
"overlapInMsec",
")",
"/",
"1000",
";",
"if",
"(",
"newOvl",
"<",
"16",
")",
"newOvl",
"=",
"16",
"... | Calculates overlapInMsec period length in samples. | [
"Calculates",
"overlapInMsec",
"period",
"length",
"in",
"samples",
"."
] | 45144cf7d4a0424aff3878d918bda9a44197b6e4 | https://github.com/katspaugh/wavesurfer.js/blob/45144cf7d4a0424aff3878d918bda9a44197b6e4/example/stretcher/soundtouch.js#L663-L677 | train | |
katspaugh/wavesurfer.js | example/stretcher/soundtouch.js | function() {
var seq;
var seek;
if (this.bAutoSeqSetting) {
seq = AUTOSEQ_C + AUTOSEQ_K * this._tempo;
seq = this.checkLimits(seq, AUTOSEQ_AT_MAX, AUTOSEQ_AT_MIN);
this.sequenceMs = Math.floor(seq + 0.5);
}
if ... | javascript | function() {
var seq;
var seek;
if (this.bAutoSeqSetting) {
seq = AUTOSEQ_C + AUTOSEQ_K * this._tempo;
seq = this.checkLimits(seq, AUTOSEQ_AT_MAX, AUTOSEQ_AT_MIN);
this.sequenceMs = Math.floor(seq + 0.5);
}
if ... | [
"function",
"(",
")",
"{",
"var",
"seq",
";",
"var",
"seek",
";",
"if",
"(",
"this",
".",
"bAutoSeqSetting",
")",
"{",
"seq",
"=",
"AUTOSEQ_C",
"+",
"AUTOSEQ_K",
"*",
"this",
".",
"_tempo",
";",
"seq",
"=",
"this",
".",
"checkLimits",
"(",
"seq",
"... | Calculates processing sequence length according to tempo setting | [
"Calculates",
"processing",
"sequence",
"length",
"according",
"to",
"tempo",
"setting"
] | 45144cf7d4a0424aff3878d918bda9a44197b6e4 | https://github.com/katspaugh/wavesurfer.js/blob/45144cf7d4a0424aff3878d918bda9a44197b6e4/example/stretcher/soundtouch.js#L685-L708 | train | |
katspaugh/wavesurfer.js | example/stretcher/soundtouch.js | function() {
var i, cnt2, temp;
for (i = 0; i < this.overlapLength; i++) {
temp = i * (this.overlapLength - i);
cnt2 = i * 2;
this.pRefMidBuffer[cnt2] = this.pMidBuffer[cnt2] * temp;
this.pRefMidBuffer[cnt2 + 1] = this.pMidBuffer[c... | javascript | function() {
var i, cnt2, temp;
for (i = 0; i < this.overlapLength; i++) {
temp = i * (this.overlapLength - i);
cnt2 = i * 2;
this.pRefMidBuffer[cnt2] = this.pMidBuffer[cnt2] * temp;
this.pRefMidBuffer[cnt2 + 1] = this.pMidBuffer[c... | [
"function",
"(",
")",
"{",
"var",
"i",
",",
"cnt2",
",",
"temp",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"overlapLength",
";",
"i",
"++",
")",
"{",
"temp",
"=",
"i",
"*",
"(",
"this",
".",
"overlapLength",
"-",
"i",
")",
... | Slopes the amplitude of the 'midBuffer' samples so that cross correlation
is faster to calculate | [
"Slopes",
"the",
"amplitude",
"of",
"the",
"midBuffer",
"samples",
"so",
"that",
"cross",
"correlation",
"is",
"faster",
"to",
"calculate"
] | 45144cf7d4a0424aff3878d918bda9a44197b6e4 | https://github.com/katspaugh/wavesurfer.js/blob/45144cf7d4a0424aff3878d918bda9a44197b6e4/example/stretcher/soundtouch.js#L817-L826 | train | |
katspaugh/wavesurfer.js | example/stretcher/soundtouch.js | function(pInputPos) {
var pInput = this._inputBuffer.vector;
pInputPos += this._inputBuffer.startIndex;
var pOutput = this._outputBuffer.vector,
pOutputPos = this._outputBuffer.endIndex,
i,
cnt2,
fTemp,
... | javascript | function(pInputPos) {
var pInput = this._inputBuffer.vector;
pInputPos += this._inputBuffer.startIndex;
var pOutput = this._outputBuffer.vector,
pOutputPos = this._outputBuffer.endIndex,
i,
cnt2,
fTemp,
... | [
"function",
"(",
"pInputPos",
")",
"{",
"var",
"pInput",
"=",
"this",
".",
"_inputBuffer",
".",
"vector",
";",
"pInputPos",
"+=",
"this",
".",
"_inputBuffer",
".",
"startIndex",
";",
"var",
"pOutput",
"=",
"this",
".",
"_outputBuffer",
".",
"vector",
",",
... | Overlaps samples in 'midBuffer' with the samples in 'pInput' | [
"Overlaps",
"samples",
"in",
"midBuffer",
"with",
"the",
"samples",
"in",
"pInput"
] | 45144cf7d4a0424aff3878d918bda9a44197b6e4 | https://github.com/katspaugh/wavesurfer.js/blob/45144cf7d4a0424aff3878d918bda9a44197b6e4/example/stretcher/soundtouch.js#L855-L883 | train | |
katspaugh/wavesurfer.js | example/timeline-notches/main.js | formatTimeCallback | function formatTimeCallback(seconds, pxPerSec) {
seconds = Number(seconds);
var minutes = Math.floor(seconds / 60);
seconds = seconds % 60;
// fill up seconds with zeroes
var secondsStr = Math.round(seconds).toString();
if (pxPerSec >= 25 * 10) {
secondsStr = seconds.toFixed(2);
} e... | javascript | function formatTimeCallback(seconds, pxPerSec) {
seconds = Number(seconds);
var minutes = Math.floor(seconds / 60);
seconds = seconds % 60;
// fill up seconds with zeroes
var secondsStr = Math.round(seconds).toString();
if (pxPerSec >= 25 * 10) {
secondsStr = seconds.toFixed(2);
} e... | [
"function",
"formatTimeCallback",
"(",
"seconds",
",",
"pxPerSec",
")",
"{",
"seconds",
"=",
"Number",
"(",
"seconds",
")",
";",
"var",
"minutes",
"=",
"Math",
".",
"floor",
"(",
"seconds",
"/",
"60",
")",
";",
"seconds",
"=",
"seconds",
"%",
"60",
";"... | Use formatTimeCallback to style the notch labels as you wish, such
as with more detail as the number of pixels per second increases.
Here we format as M:SS.frac, with M suppressed for times < 1 minute,
and frac having 0, 1, or 2 digits as the zoom increases.
Note that if you override the default function, you'll almo... | [
"Use",
"formatTimeCallback",
"to",
"style",
"the",
"notch",
"labels",
"as",
"you",
"wish",
"such",
"as",
"with",
"more",
"detail",
"as",
"the",
"number",
"of",
"pixels",
"per",
"second",
"increases",
"."
] | 45144cf7d4a0424aff3878d918bda9a44197b6e4 | https://github.com/katspaugh/wavesurfer.js/blob/45144cf7d4a0424aff3878d918bda9a44197b6e4/example/timeline-notches/main.js#L20-L40 | train |
katspaugh/wavesurfer.js | example/timeline-notches/main.js | timeInterval | function timeInterval(pxPerSec) {
var retval = 1;
if (pxPerSec >= 25 * 100) {
retval = 0.01;
} else if (pxPerSec >= 25 * 40) {
retval = 0.025;
} else if (pxPerSec >= 25 * 10) {
retval = 0.1;
} else if (pxPerSec >= 25 * 4) {
retval = 0.25;
} else if (pxPerSec >= 25... | javascript | function timeInterval(pxPerSec) {
var retval = 1;
if (pxPerSec >= 25 * 100) {
retval = 0.01;
} else if (pxPerSec >= 25 * 40) {
retval = 0.025;
} else if (pxPerSec >= 25 * 10) {
retval = 0.1;
} else if (pxPerSec >= 25 * 4) {
retval = 0.25;
} else if (pxPerSec >= 25... | [
"function",
"timeInterval",
"(",
"pxPerSec",
")",
"{",
"var",
"retval",
"=",
"1",
";",
"if",
"(",
"pxPerSec",
">=",
"25",
"*",
"100",
")",
"{",
"retval",
"=",
"0.01",
";",
"}",
"else",
"if",
"(",
"pxPerSec",
">=",
"25",
"*",
"40",
")",
"{",
"retv... | Use timeInterval to set the period between notches, in seconds,
adding notches as the number of pixels per second increases.
Note that if you override the default function, you'll almost
certainly want to override formatTimeCallback, primaryLabelInterval
and/or secondaryLabelInterval so they all work together.
@param... | [
"Use",
"timeInterval",
"to",
"set",
"the",
"period",
"between",
"notches",
"in",
"seconds",
"adding",
"notches",
"as",
"the",
"number",
"of",
"pixels",
"per",
"second",
"increases",
"."
] | 45144cf7d4a0424aff3878d918bda9a44197b6e4 | https://github.com/katspaugh/wavesurfer.js/blob/45144cf7d4a0424aff3878d918bda9a44197b6e4/example/timeline-notches/main.js#L52-L72 | train |
katspaugh/wavesurfer.js | example/timeline-notches/main.js | primaryLabelInterval | function primaryLabelInterval(pxPerSec) {
var retval = 1;
if (pxPerSec >= 25 * 100) {
retval = 10;
} else if (pxPerSec >= 25 * 40) {
retval = 4;
} else if (pxPerSec >= 25 * 10) {
retval = 10;
} else if (pxPerSec >= 25 * 4) {
retval = 4;
} else if (pxPerSec >= 25) ... | javascript | function primaryLabelInterval(pxPerSec) {
var retval = 1;
if (pxPerSec >= 25 * 100) {
retval = 10;
} else if (pxPerSec >= 25 * 40) {
retval = 4;
} else if (pxPerSec >= 25 * 10) {
retval = 10;
} else if (pxPerSec >= 25 * 4) {
retval = 4;
} else if (pxPerSec >= 25) ... | [
"function",
"primaryLabelInterval",
"(",
"pxPerSec",
")",
"{",
"var",
"retval",
"=",
"1",
";",
"if",
"(",
"pxPerSec",
">=",
"25",
"*",
"100",
")",
"{",
"retval",
"=",
"10",
";",
"}",
"else",
"if",
"(",
"pxPerSec",
">=",
"25",
"*",
"40",
")",
"{",
... | Return the cadence of notches that get labels in the primary color.
EG, return 2 if every 2nd notch should be labeled,
return 10 if every 10th notch should be labeled, etc.
Note that if you override the default function, you'll almost
certainly want to override formatTimeCallback, primaryLabelInterval
and/or secondary... | [
"Return",
"the",
"cadence",
"of",
"notches",
"that",
"get",
"labels",
"in",
"the",
"primary",
"color",
".",
"EG",
"return",
"2",
"if",
"every",
"2nd",
"notch",
"should",
"be",
"labeled",
"return",
"10",
"if",
"every",
"10th",
"notch",
"should",
"be",
"la... | 45144cf7d4a0424aff3878d918bda9a44197b6e4 | https://github.com/katspaugh/wavesurfer.js/blob/45144cf7d4a0424aff3878d918bda9a44197b6e4/example/timeline-notches/main.js#L85-L105 | train |
katspaugh/wavesurfer.js | example/playlist/app.js | function(index) {
links[currentTrack].classList.remove('active');
currentTrack = index;
links[currentTrack].classList.add('active');
wavesurfer.load(links[currentTrack].href);
} | javascript | function(index) {
links[currentTrack].classList.remove('active');
currentTrack = index;
links[currentTrack].classList.add('active');
wavesurfer.load(links[currentTrack].href);
} | [
"function",
"(",
"index",
")",
"{",
"links",
"[",
"currentTrack",
"]",
".",
"classList",
".",
"remove",
"(",
"'active'",
")",
";",
"currentTrack",
"=",
"index",
";",
"links",
"[",
"currentTrack",
"]",
".",
"classList",
".",
"add",
"(",
"'active'",
")",
... | Load a track by index and highlight the corresponding link | [
"Load",
"a",
"track",
"by",
"index",
"and",
"highlight",
"the",
"corresponding",
"link"
] | 45144cf7d4a0424aff3878d918bda9a44197b6e4 | https://github.com/katspaugh/wavesurfer.js/blob/45144cf7d4a0424aff3878d918bda9a44197b6e4/example/playlist/app.js#L37-L42 | train | |
katspaugh/wavesurfer.js | example/annotation/app.js | saveRegions | function saveRegions() {
localStorage.regions = JSON.stringify(
Object.keys(wavesurfer.regions.list).map(function(id) {
var region = wavesurfer.regions.list[id];
return {
start: region.start,
end: region.end,
attributes: region.attribut... | javascript | function saveRegions() {
localStorage.regions = JSON.stringify(
Object.keys(wavesurfer.regions.list).map(function(id) {
var region = wavesurfer.regions.list[id];
return {
start: region.start,
end: region.end,
attributes: region.attribut... | [
"function",
"saveRegions",
"(",
")",
"{",
"localStorage",
".",
"regions",
"=",
"JSON",
".",
"stringify",
"(",
"Object",
".",
"keys",
"(",
"wavesurfer",
".",
"regions",
".",
"list",
")",
".",
"map",
"(",
"function",
"(",
"id",
")",
"{",
"var",
"region",... | Save annotations to localStorage. | [
"Save",
"annotations",
"to",
"localStorage",
"."
] | 45144cf7d4a0424aff3878d918bda9a44197b6e4 | https://github.com/katspaugh/wavesurfer.js/blob/45144cf7d4a0424aff3878d918bda9a44197b6e4/example/annotation/app.js#L105-L117 | train |
katspaugh/wavesurfer.js | example/annotation/app.js | loadRegions | function loadRegions(regions) {
regions.forEach(function(region) {
region.color = randomColor(0.1);
wavesurfer.addRegion(region);
});
} | javascript | function loadRegions(regions) {
regions.forEach(function(region) {
region.color = randomColor(0.1);
wavesurfer.addRegion(region);
});
} | [
"function",
"loadRegions",
"(",
"regions",
")",
"{",
"regions",
".",
"forEach",
"(",
"function",
"(",
"region",
")",
"{",
"region",
".",
"color",
"=",
"randomColor",
"(",
"0.1",
")",
";",
"wavesurfer",
".",
"addRegion",
"(",
"region",
")",
";",
"}",
")... | Load regions from localStorage. | [
"Load",
"regions",
"from",
"localStorage",
"."
] | 45144cf7d4a0424aff3878d918bda9a44197b6e4 | https://github.com/katspaugh/wavesurfer.js/blob/45144cf7d4a0424aff3878d918bda9a44197b6e4/example/annotation/app.js#L122-L127 | train |
katspaugh/wavesurfer.js | example/annotation/app.js | extractRegions | function extractRegions(peaks, duration) {
// Silence params
var minValue = 0.0015;
var minSeconds = 0.25;
var length = peaks.length;
var coef = duration / length;
var minLen = minSeconds / coef;
// Gather silence indeces
var silences = [];
Array.prototype.forEach.call(peaks, funct... | javascript | function extractRegions(peaks, duration) {
// Silence params
var minValue = 0.0015;
var minSeconds = 0.25;
var length = peaks.length;
var coef = duration / length;
var minLen = minSeconds / coef;
// Gather silence indeces
var silences = [];
Array.prototype.forEach.call(peaks, funct... | [
"function",
"extractRegions",
"(",
"peaks",
",",
"duration",
")",
"{",
"// Silence params",
"var",
"minValue",
"=",
"0.0015",
";",
"var",
"minSeconds",
"=",
"0.25",
";",
"var",
"length",
"=",
"peaks",
".",
"length",
";",
"var",
"coef",
"=",
"duration",
"/"... | Extract regions separated by silence. | [
"Extract",
"regions",
"separated",
"by",
"silence",
"."
] | 45144cf7d4a0424aff3878d918bda9a44197b6e4 | https://github.com/katspaugh/wavesurfer.js/blob/45144cf7d4a0424aff3878d918bda9a44197b6e4/example/annotation/app.js#L132-L194 | train |
katspaugh/wavesurfer.js | example/annotation/app.js | editAnnotation | function editAnnotation(region) {
var form = document.forms.edit;
form.style.opacity = 1;
(form.elements.start.value = Math.round(region.start * 10) / 10),
(form.elements.end.value = Math.round(region.end * 10) / 10);
form.elements.note.value = region.data.note || '';
form.onsubmit = functio... | javascript | function editAnnotation(region) {
var form = document.forms.edit;
form.style.opacity = 1;
(form.elements.start.value = Math.round(region.start * 10) / 10),
(form.elements.end.value = Math.round(region.end * 10) / 10);
form.elements.note.value = region.data.note || '';
form.onsubmit = functio... | [
"function",
"editAnnotation",
"(",
"region",
")",
"{",
"var",
"form",
"=",
"document",
".",
"forms",
".",
"edit",
";",
"form",
".",
"style",
".",
"opacity",
"=",
"1",
";",
"(",
"form",
".",
"elements",
".",
"start",
".",
"value",
"=",
"Math",
".",
... | Edit annotation for a region. | [
"Edit",
"annotation",
"for",
"a",
"region",
"."
] | 45144cf7d4a0424aff3878d918bda9a44197b6e4 | https://github.com/katspaugh/wavesurfer.js/blob/45144cf7d4a0424aff3878d918bda9a44197b6e4/example/annotation/app.js#L215-L237 | train |
katspaugh/wavesurfer.js | spec/plugin-api.spec.js | mockPlugin | function mockPlugin(name, deferInit = false) {
class MockPlugin {
constructor(params, ws) {
this.ws = ws;
// using the instance factory unfortunately makes it
// difficult to use the spyOn function, so we use this
// instead
... | javascript | function mockPlugin(name, deferInit = false) {
class MockPlugin {
constructor(params, ws) {
this.ws = ws;
// using the instance factory unfortunately makes it
// difficult to use the spyOn function, so we use this
// instead
... | [
"function",
"mockPlugin",
"(",
"name",
",",
"deferInit",
"=",
"false",
")",
"{",
"class",
"MockPlugin",
"{",
"constructor",
"(",
"params",
",",
"ws",
")",
"{",
"this",
".",
"ws",
"=",
"ws",
";",
"// using the instance factory unfortunately makes it",
"// difficu... | utility function to generate a mock plugin object | [
"utility",
"function",
"to",
"generate",
"a",
"mock",
"plugin",
"object"
] | 45144cf7d4a0424aff3878d918bda9a44197b6e4 | https://github.com/katspaugh/wavesurfer.js/blob/45144cf7d4a0424aff3878d918bda9a44197b6e4/spec/plugin-api.spec.js#L24-L46 | train |
katspaugh/wavesurfer.js | spec/plugin-api.spec.js | __createWaveform | function __createWaveform(options = {}) {
waveformDiv = document.createElement('div');
document.getElementsByTagName('body')[0].appendChild(waveformDiv);
wavesurfer = WaveSurfer.create(
Object.assign(
{
container: waveformDiv
},
... | javascript | function __createWaveform(options = {}) {
waveformDiv = document.createElement('div');
document.getElementsByTagName('body')[0].appendChild(waveformDiv);
wavesurfer = WaveSurfer.create(
Object.assign(
{
container: waveformDiv
},
... | [
"function",
"__createWaveform",
"(",
"options",
"=",
"{",
"}",
")",
"{",
"waveformDiv",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"document",
".",
"getElementsByTagName",
"(",
"'body'",
")",
"[",
"0",
"]",
".",
"appendChild",
"(",
"wav... | utility function to generate wavesurfer instances for testing | [
"utility",
"function",
"to",
"generate",
"wavesurfer",
"instances",
"for",
"testing"
] | 45144cf7d4a0424aff3878d918bda9a44197b6e4 | https://github.com/katspaugh/wavesurfer.js/blob/45144cf7d4a0424aff3878d918bda9a44197b6e4/spec/plugin-api.spec.js#L49-L62 | train |
jashkenas/coffeescript | lib/coffeescript/cake.js | function(name, description, action) {
if (!action) {
[action, description] = [description, action];
}
return tasks[name] = {name, description, action};
} | javascript | function(name, description, action) {
if (!action) {
[action, description] = [description, action];
}
return tasks[name] = {name, description, action};
} | [
"function",
"(",
"name",
",",
"description",
",",
"action",
")",
"{",
"if",
"(",
"!",
"action",
")",
"{",
"[",
"action",
",",
"description",
"]",
"=",
"[",
"description",
",",
"action",
"]",
";",
"}",
"return",
"tasks",
"[",
"name",
"]",
"=",
"{",
... | Define a Cake task with a short name, an optional sentence description, and the function to run as the action itself. | [
"Define",
"a",
"Cake",
"task",
"with",
"a",
"short",
"name",
"an",
"optional",
"sentence",
"description",
"and",
"the",
"function",
"to",
"run",
"as",
"the",
"action",
"itself",
"."
] | 71750554c3a94d276a5c5344d77292fff5205e49 | https://github.com/jashkenas/coffeescript/blob/71750554c3a94d276a5c5344d77292fff5205e49/lib/coffeescript/cake.js#L40-L45 | train | |
autoNumeric/autoNumeric | src/AutoNumericOptions.js | freezeOptions | function freezeOptions(options) {
// Freeze each property objects
Object.getOwnPropertyNames(options).forEach(optionName => {
if (optionName === 'valuesToStrings') {
const vsProps = Object.getOwnPropertyNames(options.valuesToStrings);
vsProps.forEach(valuesToStringObjectName => {... | javascript | function freezeOptions(options) {
// Freeze each property objects
Object.getOwnPropertyNames(options).forEach(optionName => {
if (optionName === 'valuesToStrings') {
const vsProps = Object.getOwnPropertyNames(options.valuesToStrings);
vsProps.forEach(valuesToStringObjectName => {... | [
"function",
"freezeOptions",
"(",
"options",
")",
"{",
"// Freeze each property objects",
"Object",
".",
"getOwnPropertyNames",
"(",
"options",
")",
".",
"forEach",
"(",
"optionName",
"=>",
"{",
"if",
"(",
"optionName",
"===",
"'valuesToStrings'",
")",
"{",
"const... | Simple function that will semi-deep freeze the `AutoNumeric.options` object.
By 'semi' it means the nested objects in the `styleRules` option are not frozen.
The ones in the `valuesToStrings` are though, since they are much more simple.
@param {object} options
@returns {ReadonlyArray<any>} | [
"Simple",
"function",
"that",
"will",
"semi",
"-",
"deep",
"freeze",
"the",
"AutoNumeric",
".",
"options",
"object",
".",
"By",
"semi",
"it",
"means",
"the",
"nested",
"objects",
"in",
"the",
"styleRules",
"option",
"are",
"not",
"frozen",
".",
"The",
"one... | c54267b08f87ae5727a211e25d0f43259b75e573 | https://github.com/autoNumeric/autoNumeric/blob/c54267b08f87ae5727a211e25d0f43259b75e573/src/AutoNumericOptions.js#L866-L885 | train |
Netflix/falcor | lib/errors/InvalidDerefInputError.js | InvalidDerefInputError | function InvalidDerefInputError() {
var instance = new Error("Deref can only be used with a non-primitive object from get, set, or call.");
instance.name = "InvalidDerefInputError";
if (Object.setPrototypeOf) {
Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
}
if (Error.capt... | javascript | function InvalidDerefInputError() {
var instance = new Error("Deref can only be used with a non-primitive object from get, set, or call.");
instance.name = "InvalidDerefInputError";
if (Object.setPrototypeOf) {
Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
}
if (Error.capt... | [
"function",
"InvalidDerefInputError",
"(",
")",
"{",
"var",
"instance",
"=",
"new",
"Error",
"(",
"\"Deref can only be used with a non-primitive object from get, set, or call.\"",
")",
";",
"instance",
".",
"name",
"=",
"\"InvalidDerefInputError\"",
";",
"if",
"(",
"Objec... | An invalid deref input is when deref is used with input that is not generated
from a get, set, or a call.
@private | [
"An",
"invalid",
"deref",
"input",
"is",
"when",
"deref",
"is",
"used",
"with",
"input",
"that",
"is",
"not",
"generated",
"from",
"a",
"get",
"set",
"or",
"a",
"call",
"."
] | c0cea8518b44b999493da9ccb9c71fc3b2fb313d | https://github.com/Netflix/falcor/blob/c0cea8518b44b999493da9ccb9c71fc3b2fb313d/lib/errors/InvalidDerefInputError.js#L9-L23 | train |
Netflix/falcor | lib/request/GetRequestV2.js | function(scheduler, requestQueue) {
this.sent = false;
this.scheduled = false;
this.requestQueue = requestQueue;
this.id = ++REQUEST_ID;
this.type = GetRequestType;
this._scheduler = scheduler;
this._pathMap = {};
this._optimizedPaths = [];
this._requestedPaths = [];
this._callb... | javascript | function(scheduler, requestQueue) {
this.sent = false;
this.scheduled = false;
this.requestQueue = requestQueue;
this.id = ++REQUEST_ID;
this.type = GetRequestType;
this._scheduler = scheduler;
this._pathMap = {};
this._optimizedPaths = [];
this._requestedPaths = [];
this._callb... | [
"function",
"(",
"scheduler",
",",
"requestQueue",
")",
"{",
"this",
".",
"sent",
"=",
"false",
";",
"this",
".",
"scheduled",
"=",
"false",
";",
"this",
".",
"requestQueue",
"=",
"requestQueue",
";",
"this",
".",
"id",
"=",
"++",
"REQUEST_ID",
";",
"t... | Creates a new GetRequest. This GetRequest takes a scheduler and
the request queue. Once the scheduler fires, all batched requests
will be sent to the server. Upon request completion, the data is
merged back into the cache and all callbacks are notified.
@param {Scheduler} scheduler -
@param {RequestQueueV2} request... | [
"Creates",
"a",
"new",
"GetRequest",
".",
"This",
"GetRequest",
"takes",
"a",
"scheduler",
"and",
"the",
"request",
"queue",
".",
"Once",
"the",
"scheduler",
"fires",
"all",
"batched",
"requests",
"will",
"be",
"sent",
"to",
"the",
"server",
".",
"Upon",
"... | c0cea8518b44b999493da9ccb9c71fc3b2fb313d | https://github.com/Netflix/falcor/blob/c0cea8518b44b999493da9ccb9c71fc3b2fb313d/lib/request/GetRequestV2.js#L23-L39 | train | |
Netflix/falcor | lib/request/GetRequestV2.js | function(requestedPaths, optimizedPaths, callback) {
var self = this;
var oPaths = self._optimizedPaths;
var rPaths = self._requestedPaths;
var callbacks = self._callbacks;
var idx = oPaths.length;
// If its not sent, simply add it to the requested paths
// and c... | javascript | function(requestedPaths, optimizedPaths, callback) {
var self = this;
var oPaths = self._optimizedPaths;
var rPaths = self._requestedPaths;
var callbacks = self._callbacks;
var idx = oPaths.length;
// If its not sent, simply add it to the requested paths
// and c... | [
"function",
"(",
"requestedPaths",
",",
"optimizedPaths",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"oPaths",
"=",
"self",
".",
"_optimizedPaths",
";",
"var",
"rPaths",
"=",
"self",
".",
"_requestedPaths",
";",
"var",
"callbacks",
... | batches the paths that are passed in. Once the request is complete,
all callbacks will be called and the request will be removed from
parent queue.
@param {Array} requestedPaths -
@param {Array} optimizedPaths -
@param {Function} callback - | [
"batches",
"the",
"paths",
"that",
"are",
"passed",
"in",
".",
"Once",
"the",
"request",
"is",
"complete",
"all",
"callbacks",
"will",
"be",
"called",
"and",
"the",
"request",
"will",
"be",
"removed",
"from",
"parent",
"queue",
"."
] | c0cea8518b44b999493da9ccb9c71fc3b2fb313d | https://github.com/Netflix/falcor/blob/c0cea8518b44b999493da9ccb9c71fc3b2fb313d/lib/request/GetRequestV2.js#L50-L145 | train | |
Netflix/falcor | lib/request/GetRequestV2.js | function(requested, optimized, callback) {
// uses the length tree complement calculator.
var self = this;
var complementResult = complement(requested, optimized, self._pathMap);
var inserted = false;
var disposable = false;
// If we found an intersection, then just add... | javascript | function(requested, optimized, callback) {
// uses the length tree complement calculator.
var self = this;
var complementResult = complement(requested, optimized, self._pathMap);
var inserted = false;
var disposable = false;
// If we found an intersection, then just add... | [
"function",
"(",
"requested",
",",
"optimized",
",",
"callback",
")",
"{",
"// uses the length tree complement calculator.",
"var",
"self",
"=",
"this",
";",
"var",
"complementResult",
"=",
"complement",
"(",
"requested",
",",
"optimized",
",",
"self",
".",
"_path... | Attempts to add paths to the outgoing request. If there are added
paths then the request callback will be added to the callback list.
Handles adding partial paths as well
@returns {Array} - whether new requested paths were inserted in this
request, the remaining paths that could not be added,
and disposable for the i... | [
"Attempts",
"to",
"add",
"paths",
"to",
"the",
"outgoing",
"request",
".",
"If",
"there",
"are",
"added",
"paths",
"then",
"the",
"request",
"callback",
"will",
"be",
"added",
"to",
"the",
"callback",
"list",
".",
"Handles",
"adding",
"partial",
"paths",
"... | c0cea8518b44b999493da9ccb9c71fc3b2fb313d | https://github.com/Netflix/falcor/blob/c0cea8518b44b999493da9ccb9c71fc3b2fb313d/lib/request/GetRequestV2.js#L156-L178 | train | |
Netflix/falcor | lib/request/GetRequestV2.js | function(requested, err, data, mergeContext) {
var self = this;
var model = self.requestQueue.model;
var modelRoot = model._root;
var errorSelector = modelRoot.errorSelector;
var comparator = modelRoot.comparator;
var boundPath = model._path;
model._path = emptyA... | javascript | function(requested, err, data, mergeContext) {
var self = this;
var model = self.requestQueue.model;
var modelRoot = model._root;
var errorSelector = modelRoot.errorSelector;
var comparator = modelRoot.comparator;
var boundPath = model._path;
model._path = emptyA... | [
"function",
"(",
"requested",
",",
"err",
",",
"data",
",",
"mergeContext",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"model",
"=",
"self",
".",
"requestQueue",
".",
"model",
";",
"var",
"modelRoot",
"=",
"model",
".",
"_root",
";",
"var",
"e... | merges the response into the model"s cache. | [
"merges",
"the",
"response",
"into",
"the",
"model",
"s",
"cache",
"."
] | c0cea8518b44b999493da9ccb9c71fc3b2fb313d | https://github.com/Netflix/falcor/blob/c0cea8518b44b999493da9ccb9c71fc3b2fb313d/lib/request/GetRequestV2.js#L183-L235 | train | |
Netflix/falcor | lib/request/GetRequestV2.js | createDisposable | function createDisposable(request, idx) {
var disposed = false;
return function() {
if (disposed || request._disposed) {
return;
}
disposed = true;
request._callbacks[idx] = null;
request._optimizedPaths[idx] = [];
request._requestedPaths[idx] = [];
... | javascript | function createDisposable(request, idx) {
var disposed = false;
return function() {
if (disposed || request._disposed) {
return;
}
disposed = true;
request._callbacks[idx] = null;
request._optimizedPaths[idx] = [];
request._requestedPaths[idx] = [];
... | [
"function",
"createDisposable",
"(",
"request",
",",
"idx",
")",
"{",
"var",
"disposed",
"=",
"false",
";",
"return",
"function",
"(",
")",
"{",
"if",
"(",
"disposed",
"||",
"request",
".",
"_disposed",
")",
"{",
"return",
";",
"}",
"disposed",
"=",
"t... | Creates a more efficient closure of the things that are needed. So the request and the idx. Also prevents code duplication. | [
"Creates",
"a",
"more",
"efficient",
"closure",
"of",
"the",
"things",
"that",
"are",
"needed",
".",
"So",
"the",
"request",
"and",
"the",
"idx",
".",
"Also",
"prevents",
"code",
"duplication",
"."
] | c0cea8518b44b999493da9ccb9c71fc3b2fb313d | https://github.com/Netflix/falcor/blob/c0cea8518b44b999493da9ccb9c71fc3b2fb313d/lib/request/GetRequestV2.js#L241-L266 | train |
Netflix/falcor | lib/response/AssignableDisposable.js | dispose | function dispose() {
if (this.disposed || !this.currentDisposable) {
return;
}
this.disposed = true;
// If the current disposable fulfills the disposable interface or just
// a disposable function.
var currentDisposable = this.currentDisposable;
if (c... | javascript | function dispose() {
if (this.disposed || !this.currentDisposable) {
return;
}
this.disposed = true;
// If the current disposable fulfills the disposable interface or just
// a disposable function.
var currentDisposable = this.currentDisposable;
if (c... | [
"function",
"dispose",
"(",
")",
"{",
"if",
"(",
"this",
".",
"disposed",
"||",
"!",
"this",
".",
"currentDisposable",
")",
"{",
"return",
";",
"}",
"this",
".",
"disposed",
"=",
"true",
";",
"// If the current disposable fulfills the disposable interface or just"... | Disposes of the current disposable. This would be the getRequestCycle
disposable. | [
"Disposes",
"of",
"the",
"current",
"disposable",
".",
"This",
"would",
"be",
"the",
"getRequestCycle",
"disposable",
"."
] | c0cea8518b44b999493da9ccb9c71fc3b2fb313d | https://github.com/Netflix/falcor/blob/c0cea8518b44b999493da9ccb9c71fc3b2fb313d/lib/response/AssignableDisposable.js#L18-L34 | train |
Netflix/falcor | lib/response/set/SetResponse.js | SetResponse | function SetResponse(model, args, isJSONGraph,
isProgressive) {
// The response properties.
this._model = model;
this._isJSONGraph = isJSONGraph || false;
this._isProgressive = isProgressive || false;
this._initialArgs = args;
this._value = [{}];
var ... | javascript | function SetResponse(model, args, isJSONGraph,
isProgressive) {
// The response properties.
this._model = model;
this._isJSONGraph = isJSONGraph || false;
this._isProgressive = isProgressive || false;
this._initialArgs = args;
this._value = [{}];
var ... | [
"function",
"SetResponse",
"(",
"model",
",",
"args",
",",
"isJSONGraph",
",",
"isProgressive",
")",
"{",
"// The response properties.",
"this",
".",
"_model",
"=",
"model",
";",
"this",
".",
"_isJSONGraph",
"=",
"isJSONGraph",
"||",
"false",
";",
"this",
".",... | The set response is responsible for doing the request loop for the set
operation and subscribing to the follow up get.
The constructors job is to parse out the arguments and put them in their
groups. The following subscribe will do the actual cache set and dataSource
operation remoting.
@param {Model} model -
@param... | [
"The",
"set",
"response",
"is",
"responsible",
"for",
"doing",
"the",
"request",
"loop",
"for",
"the",
"set",
"operation",
"and",
"subscribing",
"to",
"the",
"follow",
"up",
"get",
"."
] | c0cea8518b44b999493da9ccb9c71fc3b2fb313d | https://github.com/Netflix/falcor/blob/c0cea8518b44b999493da9ccb9c71fc3b2fb313d/lib/response/set/SetResponse.js#L25-L69 | train |
Netflix/falcor | lib/errors/BoundJSONGraphModelError.js | BoundJSONGraphModelError | function BoundJSONGraphModelError() {
var instance = new Error("It is not legal to use the JSON Graph " +
"format from a bound Model. JSON Graph format" +
" can only be used from a root model.");
instance.name = "BoundJSONGraphModelError";
if (Object.setPrototypeOf) {
Object.setPrototypeOf... | javascript | function BoundJSONGraphModelError() {
var instance = new Error("It is not legal to use the JSON Graph " +
"format from a bound Model. JSON Graph format" +
" can only be used from a root model.");
instance.name = "BoundJSONGraphModelError";
if (Object.setPrototypeOf) {
Object.setPrototypeOf... | [
"function",
"BoundJSONGraphModelError",
"(",
")",
"{",
"var",
"instance",
"=",
"new",
"Error",
"(",
"\"It is not legal to use the JSON Graph \"",
"+",
"\"format from a bound Model. JSON Graph format\"",
"+",
"\" can only be used from a root model.\"",
")",
";",
"instance",
".",... | When a bound model attempts to retrieve JSONGraph it should throw an
error.
@private | [
"When",
"a",
"bound",
"model",
"attempts",
"to",
"retrieve",
"JSONGraph",
"it",
"should",
"throw",
"an",
"error",
"."
] | c0cea8518b44b999493da9ccb9c71fc3b2fb313d | https://github.com/Netflix/falcor/blob/c0cea8518b44b999493da9ccb9c71fc3b2fb313d/lib/errors/BoundJSONGraphModelError.js#L9-L25 | train |
Netflix/falcor | lib/errors/InvalidModelError.js | InvalidModelError | function InvalidModelError(boundPath, shortedPath) {
var instance = new Error("The boundPath of the model is not valid since a value or error was found before the path end.");
instance.name = "InvalidModelError";
instance.boundPath = boundPath;
instance.shortedPath = shortedPath;
if (Object.setPro... | javascript | function InvalidModelError(boundPath, shortedPath) {
var instance = new Error("The boundPath of the model is not valid since a value or error was found before the path end.");
instance.name = "InvalidModelError";
instance.boundPath = boundPath;
instance.shortedPath = shortedPath;
if (Object.setPro... | [
"function",
"InvalidModelError",
"(",
"boundPath",
",",
"shortedPath",
")",
"{",
"var",
"instance",
"=",
"new",
"Error",
"(",
"\"The boundPath of the model is not valid since a value or error was found before the path end.\"",
")",
";",
"instance",
".",
"name",
"=",
"\"Inva... | An InvalidModelError can only happen when a user binds, whether sync
or async to shorted value. See the unit tests for examples.
@param {*} boundPath
@param {*} shortedPath
@private | [
"An",
"InvalidModelError",
"can",
"only",
"happen",
"when",
"a",
"user",
"binds",
"whether",
"sync",
"or",
"async",
"to",
"shorted",
"value",
".",
"See",
"the",
"unit",
"tests",
"for",
"examples",
"."
] | c0cea8518b44b999493da9ccb9c71fc3b2fb313d | https://github.com/Netflix/falcor/blob/c0cea8518b44b999493da9ccb9c71fc3b2fb313d/lib/errors/InvalidModelError.js#L12-L28 | train |
Netflix/falcor | examples/datasource/webWorkerSource.js | function(action) {
var self = this;
// The subscribe function runs when the Observable is observed.
return Rx.Observable.create(function subscribe(observer) {
var id = self.id++,
handler = function(e) {
var response = e.data,
... | javascript | function(action) {
var self = this;
// The subscribe function runs when the Observable is observed.
return Rx.Observable.create(function subscribe(observer) {
var id = self.id++,
handler = function(e) {
var response = e.data,
... | [
"function",
"(",
"action",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// The subscribe function runs when the Observable is observed.",
"return",
"Rx",
".",
"Observable",
".",
"create",
"(",
"function",
"subscribe",
"(",
"observer",
")",
"{",
"var",
"id",
"=",
... | Creates an observable stream that will send a request to a Model server, and retrieve the response. The request and response are correlated using a unique identifier which the client sends with the request and the server echoes back along with the response. | [
"Creates",
"an",
"observable",
"stream",
"that",
"will",
"send",
"a",
"request",
"to",
"a",
"Model",
"server",
"and",
"retrieve",
"the",
"response",
".",
"The",
"request",
"and",
"response",
"are",
"correlated",
"using",
"a",
"unique",
"identifier",
"which",
... | c0cea8518b44b999493da9ccb9c71fc3b2fb313d | https://github.com/Netflix/falcor/blob/c0cea8518b44b999493da9ccb9c71fc3b2fb313d/examples/datasource/webWorkerSource.js#L110-L146 | train | |
Netflix/falcor | lib/Model.js | Model | function Model(o) {
var options = o || {};
this._root = options._root || new ModelRoot(options);
this._path = options.path || options._path || [];
this._scheduler = options.scheduler || options._scheduler || new ImmediateScheduler();
this._source = options.source || options._source;
this._reque... | javascript | function Model(o) {
var options = o || {};
this._root = options._root || new ModelRoot(options);
this._path = options.path || options._path || [];
this._scheduler = options.scheduler || options._scheduler || new ImmediateScheduler();
this._source = options.source || options._source;
this._reque... | [
"function",
"Model",
"(",
"o",
")",
"{",
"var",
"options",
"=",
"o",
"||",
"{",
"}",
";",
"this",
".",
"_root",
"=",
"options",
".",
"_root",
"||",
"new",
"ModelRoot",
"(",
"options",
")",
";",
"this",
".",
"_path",
"=",
"options",
".",
"path",
"... | This function is invoked every time a value in the Model cache is about to be replaced with a new value. If the function returns true, the existing value is replaced with a new value and the version flag on all of the value's ancestors in the tree are incremented.
@callback Model~comparator
@param {Object} existingValu... | [
"This",
"function",
"is",
"invoked",
"every",
"time",
"a",
"value",
"in",
"the",
"Model",
"cache",
"is",
"about",
"to",
"be",
"replaced",
"with",
"a",
"new",
"value",
".",
"If",
"the",
"function",
"returns",
"true",
"the",
"existing",
"value",
"is",
"rep... | c0cea8518b44b999493da9ccb9c71fc3b2fb313d | https://github.com/Netflix/falcor/blob/c0cea8518b44b999493da9ccb9c71fc3b2fb313d/lib/Model.js#L74-L126 | train |
Netflix/falcor | performance/models/legacy/macro/_Falcor.js | allUnique | function allUnique(arr) {
var hash = {},
index,
len;
for (index = 0, len = arr.length; index < len; index++) {
if (hash[arr[index]]) {
return false;
}
hash[arr[index]] = true;
}
return true;
} | javascript | function allUnique(arr) {
var hash = {},
index,
len;
for (index = 0, len = arr.length; index < len; index++) {
if (hash[arr[index]]) {
return false;
}
hash[arr[index]] = true;
}
return true;
} | [
"function",
"allUnique",
"(",
"arr",
")",
"{",
"var",
"hash",
"=",
"{",
"}",
",",
"index",
",",
"len",
";",
"for",
"(",
"index",
"=",
"0",
",",
"len",
"=",
"arr",
".",
"length",
";",
"index",
"<",
"len",
";",
"index",
"++",
")",
"{",
"if",
"(... | allUnique
return true if every number in an array is unique | [
"allUnique",
"return",
"true",
"if",
"every",
"number",
"in",
"an",
"array",
"is",
"unique"
] | c0cea8518b44b999493da9ccb9c71fc3b2fb313d | https://github.com/Netflix/falcor/blob/c0cea8518b44b999493da9ccb9c71fc3b2fb313d/performance/models/legacy/macro/_Falcor.js#L535-L547 | train |
Netflix/falcor | lib/errors/MaxRetryExceededError.js | MaxRetryExceededError | function MaxRetryExceededError(missingOptimizedPaths) {
var instance = new Error("The allowed number of retries have been exceeded.");
instance.name = "MaxRetryExceededError";
instance.missingOptimizedPaths = missingOptimizedPaths || [];
if (Object.setPrototypeOf) {
Object.setPrototypeOf(insta... | javascript | function MaxRetryExceededError(missingOptimizedPaths) {
var instance = new Error("The allowed number of retries have been exceeded.");
instance.name = "MaxRetryExceededError";
instance.missingOptimizedPaths = missingOptimizedPaths || [];
if (Object.setPrototypeOf) {
Object.setPrototypeOf(insta... | [
"function",
"MaxRetryExceededError",
"(",
"missingOptimizedPaths",
")",
"{",
"var",
"instance",
"=",
"new",
"Error",
"(",
"\"The allowed number of retries have been exceeded.\"",
")",
";",
"instance",
".",
"name",
"=",
"\"MaxRetryExceededError\"",
";",
"instance",
".",
... | A request can only be retried up to a specified limit. Once that
limit is exceeded, then an error will be thrown.
@param {*} missingOptimizedPaths
@private | [
"A",
"request",
"can",
"only",
"be",
"retried",
"up",
"to",
"a",
"specified",
"limit",
".",
"Once",
"that",
"limit",
"is",
"exceeded",
"then",
"an",
"error",
"will",
"be",
"thrown",
"."
] | c0cea8518b44b999493da9ccb9c71fc3b2fb313d | https://github.com/Netflix/falcor/blob/c0cea8518b44b999493da9ccb9c71fc3b2fb313d/lib/errors/MaxRetryExceededError.js#L11-L26 | train |
Netflix/falcor | lib/errors/NullInPathError.js | NullInPathError | function NullInPathError() {
var instance = new Error("`null` and `undefined` are not allowed in branch key positions");
instance.name = "NullInPathError";
if (Object.setPrototypeOf) {
Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
}
if (Error.captureStackTrace) {
E... | javascript | function NullInPathError() {
var instance = new Error("`null` and `undefined` are not allowed in branch key positions");
instance.name = "NullInPathError";
if (Object.setPrototypeOf) {
Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
}
if (Error.captureStackTrace) {
E... | [
"function",
"NullInPathError",
"(",
")",
"{",
"var",
"instance",
"=",
"new",
"Error",
"(",
"\"`null` and `undefined` are not allowed in branch key positions\"",
")",
";",
"instance",
".",
"name",
"=",
"\"NullInPathError\"",
";",
"if",
"(",
"Object",
".",
"setPrototype... | Does not allow null in path
@private | [
"Does",
"not",
"allow",
"null",
"in",
"path"
] | c0cea8518b44b999493da9ccb9c71fc3b2fb313d | https://github.com/Netflix/falcor/blob/c0cea8518b44b999493da9ccb9c71fc3b2fb313d/lib/errors/NullInPathError.js#L8-L22 | train |
Netflix/falcor | lib/response/get/GetResponse.js | GetResponse | function GetResponse(model, paths, isJSONGraph,
isProgressive, forceCollect) {
this.model = model;
this.currentRemainingPaths = paths;
this.isJSONGraph = isJSONGraph || false;
this.isProgressive = isProgressive || false;
this.forceCollect = forceCollect || fals... | javascript | function GetResponse(model, paths, isJSONGraph,
isProgressive, forceCollect) {
this.model = model;
this.currentRemainingPaths = paths;
this.isJSONGraph = isJSONGraph || false;
this.isProgressive = isProgressive || false;
this.forceCollect = forceCollect || fals... | [
"function",
"GetResponse",
"(",
"model",
",",
"paths",
",",
"isJSONGraph",
",",
"isProgressive",
",",
"forceCollect",
")",
"{",
"this",
".",
"model",
"=",
"model",
";",
"this",
".",
"currentRemainingPaths",
"=",
"paths",
";",
"this",
".",
"isJSONGraph",
"=",... | The get response. It takes in a model and paths and starts
the request cycle. It has been optimized for cache first requests
and closures.
@param {Model} model -
@param {Array} paths -
@augments ModelResponse
@private | [
"The",
"get",
"response",
".",
"It",
"takes",
"in",
"a",
"model",
"and",
"paths",
"and",
"starts",
"the",
"request",
"cycle",
".",
"It",
"has",
"been",
"optimized",
"for",
"cache",
"first",
"requests",
"and",
"closures",
"."
] | c0cea8518b44b999493da9ccb9c71fc3b2fb313d | https://github.com/Netflix/falcor/blob/c0cea8518b44b999493da9ccb9c71fc3b2fb313d/lib/response/get/GetResponse.js#L17-L24 | train |
Netflix/falcor | build/falcor-jsdoc-template/publish.js | linkToWithTarget | function linkToWithTarget(doc, linkText) {
var linkTag = linkto(doc.longname, linkText || doc.name);
return linkTag.slice(0, linkTag.indexOf('>')) + ' data-target="#' +
escapeDocId(doc.id) + '"' + linkTag.slice(linkTag.indexOf('>'));
} | javascript | function linkToWithTarget(doc, linkText) {
var linkTag = linkto(doc.longname, linkText || doc.name);
return linkTag.slice(0, linkTag.indexOf('>')) + ' data-target="#' +
escapeDocId(doc.id) + '"' + linkTag.slice(linkTag.indexOf('>'));
} | [
"function",
"linkToWithTarget",
"(",
"doc",
",",
"linkText",
")",
"{",
"var",
"linkTag",
"=",
"linkto",
"(",
"doc",
".",
"longname",
",",
"linkText",
"||",
"doc",
".",
"name",
")",
";",
"return",
"linkTag",
".",
"slice",
"(",
"0",
",",
"linkTag",
".",
... | Returns a link just like linkto, but with an id to its target header on the page added so bootstrap scrollspy can pick it up use it to work. Also sanitizes the input because jsdoc uses all sorts of weird characters in their ids. Optionally, link text can be passed in to use instead of the doc's name inside the link. | [
"Returns",
"a",
"link",
"just",
"like",
"linkto",
"but",
"with",
"an",
"id",
"to",
"its",
"target",
"header",
"on",
"the",
"page",
"added",
"so",
"bootstrap",
"scrollspy",
"can",
"pick",
"it",
"up",
"use",
"it",
"to",
"work",
".",
"Also",
"sanitizes",
... | c0cea8518b44b999493da9ccb9c71fc3b2fb313d | https://github.com/Netflix/falcor/blob/c0cea8518b44b999493da9ccb9c71fc3b2fb313d/build/falcor-jsdoc-template/publish.js#L333-L337 | train |
janl/mustache.js | mustache.js | primitiveHasOwnProperty | function primitiveHasOwnProperty (primitive, propName) {
return (
primitive != null
&& typeof primitive !== 'object'
&& primitive.hasOwnProperty
&& primitive.hasOwnProperty(propName)
);
} | javascript | function primitiveHasOwnProperty (primitive, propName) {
return (
primitive != null
&& typeof primitive !== 'object'
&& primitive.hasOwnProperty
&& primitive.hasOwnProperty(propName)
);
} | [
"function",
"primitiveHasOwnProperty",
"(",
"primitive",
",",
"propName",
")",
"{",
"return",
"(",
"primitive",
"!=",
"null",
"&&",
"typeof",
"primitive",
"!==",
"'object'",
"&&",
"primitive",
".",
"hasOwnProperty",
"&&",
"primitive",
".",
"hasOwnProperty",
"(",
... | Safe way of detecting whether or not the given thing is a primitive and
whether it has the given property | [
"Safe",
"way",
"of",
"detecting",
"whether",
"or",
"not",
"the",
"given",
"thing",
"is",
"a",
"primitive",
"and",
"whether",
"it",
"has",
"the",
"given",
"property"
] | 38b1448e65f1d4716c3e3ad792ae6ab3aaf487ab | https://github.com/janl/mustache.js/blob/38b1448e65f1d4716c3e3ad792ae6ab3aaf487ab/mustache.js#L52-L59 | train |
oliver-moran/jimp | packages/core/src/index.js | bufferFromArrayBuffer | function bufferFromArrayBuffer(arrayBuffer) {
const buffer = Buffer.alloc(arrayBuffer.byteLength);
const view = new Uint8Array(arrayBuffer);
for (let i = 0; i < buffer.length; ++i) {
buffer[i] = view[i];
}
return buffer;
} | javascript | function bufferFromArrayBuffer(arrayBuffer) {
const buffer = Buffer.alloc(arrayBuffer.byteLength);
const view = new Uint8Array(arrayBuffer);
for (let i = 0; i < buffer.length; ++i) {
buffer[i] = view[i];
}
return buffer;
} | [
"function",
"bufferFromArrayBuffer",
"(",
"arrayBuffer",
")",
"{",
"const",
"buffer",
"=",
"Buffer",
".",
"alloc",
"(",
"arrayBuffer",
".",
"byteLength",
")",
";",
"const",
"view",
"=",
"new",
"Uint8Array",
"(",
"arrayBuffer",
")",
";",
"for",
"(",
"let",
... | Prepare a Buffer object from the arrayBuffer. Necessary in the browser > node conversion, But this function is not useful when running in node directly | [
"Prepare",
"a",
"Buffer",
"object",
"from",
"the",
"arrayBuffer",
".",
"Necessary",
"in",
"the",
"browser",
">",
"node",
"conversion",
"But",
"this",
"function",
"is",
"not",
"useful",
"when",
"running",
"in",
"node",
"directly"
] | 736054ef1bea6b6fb03db3e75f05cd922a9c104f | https://github.com/oliver-moran/jimp/blob/736054ef1bea6b6fb03db3e75f05cd922a9c104f/packages/core/src/index.js#L50-L59 | train |
oliver-moran/jimp | packages/jimp/tools/browser-build.js | minify | function minify(code) {
console.error('Compressing...');
return UglifyJS.minify(code, { warnings: false }).code;
} | javascript | function minify(code) {
console.error('Compressing...');
return UglifyJS.minify(code, { warnings: false }).code;
} | [
"function",
"minify",
"(",
"code",
")",
"{",
"console",
".",
"error",
"(",
"'Compressing...'",
")",
";",
"return",
"UglifyJS",
".",
"minify",
"(",
"code",
",",
"{",
"warnings",
":",
"false",
"}",
")",
".",
"code",
";",
"}"
] | Browserify and Babelize. | [
"Browserify",
"and",
"Babelize",
"."
] | 736054ef1bea6b6fb03db3e75f05cd922a9c104f | https://github.com/oliver-moran/jimp/blob/736054ef1bea6b6fb03db3e75f05cd922a9c104f/packages/jimp/tools/browser-build.js#L34-L38 | train |
oliver-moran/jimp | packages/plugin-dither/src/index.js | dither | function dither(cb) {
const rgb565Matrix = [1, 9, 3, 11, 13, 5, 15, 7, 4, 12, 2, 10, 16, 8, 14, 6];
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function(
x,
y,
idx
) {
const thresholdId = ((y & 3) << 2) + (x % 4);
const dither = rgb565Matrix[thresholdId];
this.bitmap.data[i... | javascript | function dither(cb) {
const rgb565Matrix = [1, 9, 3, 11, 13, 5, 15, 7, 4, 12, 2, 10, 16, 8, 14, 6];
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function(
x,
y,
idx
) {
const thresholdId = ((y & 3) << 2) + (x % 4);
const dither = rgb565Matrix[thresholdId];
this.bitmap.data[i... | [
"function",
"dither",
"(",
"cb",
")",
"{",
"const",
"rgb565Matrix",
"=",
"[",
"1",
",",
"9",
",",
"3",
",",
"11",
",",
"13",
",",
"5",
",",
"15",
",",
"7",
",",
"4",
",",
"12",
",",
"2",
",",
"10",
",",
"16",
",",
"8",
",",
"14",
",",
"... | Apply a ordered dithering effect
@param {function(Error, Jimp)} cb (optional) a callback for when complete
@returns {Jimp} this for chaining of methods | [
"Apply",
"a",
"ordered",
"dithering",
"effect"
] | 736054ef1bea6b6fb03db3e75f05cd922a9c104f | https://github.com/oliver-moran/jimp/blob/736054ef1bea6b6fb03db3e75f05cd922a9c104f/packages/plugin-dither/src/index.js#L8-L33 | train |
oliver-moran/jimp | packages/plugin-flip/src/index.js | flipFn | function flipFn(horizontal, vertical, cb) {
if (typeof horizontal !== 'boolean' || typeof vertical !== 'boolean')
return throwError.call(
this,
'horizontal and vertical must be Booleans',
cb
);
if (horizontal && vertical) {
// shortcut
return this.rotate(180, true, cb);
}
con... | javascript | function flipFn(horizontal, vertical, cb) {
if (typeof horizontal !== 'boolean' || typeof vertical !== 'boolean')
return throwError.call(
this,
'horizontal and vertical must be Booleans',
cb
);
if (horizontal && vertical) {
// shortcut
return this.rotate(180, true, cb);
}
con... | [
"function",
"flipFn",
"(",
"horizontal",
",",
"vertical",
",",
"cb",
")",
"{",
"if",
"(",
"typeof",
"horizontal",
"!==",
"'boolean'",
"||",
"typeof",
"vertical",
"!==",
"'boolean'",
")",
"return",
"throwError",
".",
"call",
"(",
"this",
",",
"'horizontal and... | Flip the image horizontally
@param {boolean} horizontal a Boolean, if true the image will be flipped horizontally
@param {boolean} vertical a Boolean, if true the image will be flipped vertically
@param {function(Error, Jimp)} cb (optional) a callback for when complete
@returns {Jimp} this for chaining of methods | [
"Flip",
"the",
"image",
"horizontally"
] | 736054ef1bea6b6fb03db3e75f05cd922a9c104f | https://github.com/oliver-moran/jimp/blob/736054ef1bea6b6fb03db3e75f05cd922a9c104f/packages/plugin-flip/src/index.js#L10-L44 | train |
oliver-moran/jimp | packages/plugin-normalize/src/index.js | histogram | function histogram() {
const histogram = {
r: new Array(256).fill(0),
g: new Array(256).fill(0),
b: new Array(256).fill(0)
};
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function(
x,
y,
index
) {
histogram.r[this.bitmap.data[index + 0]]++;
histogram.g[this.bitmap... | javascript | function histogram() {
const histogram = {
r: new Array(256).fill(0),
g: new Array(256).fill(0),
b: new Array(256).fill(0)
};
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function(
x,
y,
index
) {
histogram.r[this.bitmap.data[index + 0]]++;
histogram.g[this.bitmap... | [
"function",
"histogram",
"(",
")",
"{",
"const",
"histogram",
"=",
"{",
"r",
":",
"new",
"Array",
"(",
"256",
")",
".",
"fill",
"(",
"0",
")",
",",
"g",
":",
"new",
"Array",
"(",
"256",
")",
".",
"fill",
"(",
"0",
")",
",",
"b",
":",
"new",
... | Get an image's histogram
@return {object} An object with an array of color occurrence counts for each channel (r,g,b) | [
"Get",
"an",
"image",
"s",
"histogram"
] | 736054ef1bea6b6fb03db3e75f05cd922a9c104f | https://github.com/oliver-moran/jimp/blob/736054ef1bea6b6fb03db3e75f05cd922a9c104f/packages/plugin-normalize/src/index.js#L9-L27 | train |
Alex-D/Trumbowyg | plugins/mention/trumbowyg.mention.js | buildDropdown | function buildDropdown(items, trumbowyg) {
var dropdown = [];
$.each(items, function (i, item) {
var btn = 'mention-' + i,
btnDef = {
hasIcon: false,
text: trumbowyg.o.plugins.mention.formatDropdownItem(item),
fn: f... | javascript | function buildDropdown(items, trumbowyg) {
var dropdown = [];
$.each(items, function (i, item) {
var btn = 'mention-' + i,
btnDef = {
hasIcon: false,
text: trumbowyg.o.plugins.mention.formatDropdownItem(item),
fn: f... | [
"function",
"buildDropdown",
"(",
"items",
",",
"trumbowyg",
")",
"{",
"var",
"dropdown",
"=",
"[",
"]",
";",
"$",
".",
"each",
"(",
"items",
",",
"function",
"(",
"i",
",",
"item",
")",
"{",
"var",
"btn",
"=",
"'mention-'",
"+",
"i",
",",
"btnDef"... | Build dropdown list
@param {Array} items Items
@param {object} trumbowyg Editor
@return {Array} | [
"Build",
"dropdown",
"list"
] | 98995a217241bf76f0c07eff1398f5592c061309 | https://github.com/Alex-D/Trumbowyg/blob/98995a217241bf76f0c07eff1398f5592c061309/plugins/mention/trumbowyg.mention.js#L70-L90 | train |
Alex-D/Trumbowyg | plugins/template/trumbowyg.template.js | templateSelector | function templateSelector(trumbowyg) {
var available = trumbowyg.o.plugins.templates;
var templates = [];
$.each(available, function (index, template) {
trumbowyg.addBtnDef('template_' + index, {
fn: function () {
trumbowyg.html(template.html);
... | javascript | function templateSelector(trumbowyg) {
var available = trumbowyg.o.plugins.templates;
var templates = [];
$.each(available, function (index, template) {
trumbowyg.addBtnDef('template_' + index, {
fn: function () {
trumbowyg.html(template.html);
... | [
"function",
"templateSelector",
"(",
"trumbowyg",
")",
"{",
"var",
"available",
"=",
"trumbowyg",
".",
"o",
".",
"plugins",
".",
"templates",
";",
"var",
"templates",
"=",
"[",
"]",
";",
"$",
".",
"each",
"(",
"available",
",",
"function",
"(",
"index",
... | Creates the template-selector dropdown. | [
"Creates",
"the",
"template",
"-",
"selector",
"dropdown",
"."
] | 98995a217241bf76f0c07eff1398f5592c061309 | https://github.com/Alex-D/Trumbowyg/blob/98995a217241bf76f0c07eff1398f5592c061309/plugins/template/trumbowyg.template.js#L56-L72 | train |
Alex-D/Trumbowyg | plugins/lineheight/trumbowyg.lineheight.js | buildDropdown | function buildDropdown(trumbowyg) {
var dropdown = [];
$.each(trumbowyg.o.plugins.lineheight.sizeList, function(index, size) {
trumbowyg.addBtnDef('lineheight_' + size, {
text: trumbowyg.lang.lineheights[size] || size,
hasIcon: false,
fn: func... | javascript | function buildDropdown(trumbowyg) {
var dropdown = [];
$.each(trumbowyg.o.plugins.lineheight.sizeList, function(index, size) {
trumbowyg.addBtnDef('lineheight_' + size, {
text: trumbowyg.lang.lineheights[size] || size,
hasIcon: false,
fn: func... | [
"function",
"buildDropdown",
"(",
"trumbowyg",
")",
"{",
"var",
"dropdown",
"=",
"[",
"]",
";",
"$",
".",
"each",
"(",
"trumbowyg",
".",
"o",
".",
"plugins",
".",
"lineheight",
".",
"sizeList",
",",
"function",
"(",
"index",
",",
"size",
")",
"{",
"t... | Build the dropdown | [
"Build",
"the",
"dropdown"
] | 98995a217241bf76f0c07eff1398f5592c061309 | https://github.com/Alex-D/Trumbowyg/blob/98995a217241bf76f0c07eff1398f5592c061309/plugins/lineheight/trumbowyg.lineheight.js#L111-L134 | train |
Alex-D/Trumbowyg | src/trumbowyg.js | function () {
var t = this;
t.$ed.removeClass('autogrow-on-enter');
var oldHeight = t.$ed[0].clientHeight;
t.$ed.height('auto');
var totalHeight = t.$ed[0].scrollHeight;
t.$ed.addClass('autogrow-on-enter');
if (oldHeight !== totalHeight... | javascript | function () {
var t = this;
t.$ed.removeClass('autogrow-on-enter');
var oldHeight = t.$ed[0].clientHeight;
t.$ed.height('auto');
var totalHeight = t.$ed[0].scrollHeight;
t.$ed.addClass('autogrow-on-enter');
if (oldHeight !== totalHeight... | [
"function",
"(",
")",
"{",
"var",
"t",
"=",
"this",
";",
"t",
".",
"$ed",
".",
"removeClass",
"(",
"'autogrow-on-enter'",
")",
";",
"var",
"oldHeight",
"=",
"t",
".",
"$ed",
"[",
"0",
"]",
".",
"clientHeight",
";",
"t",
".",
"$ed",
".",
"height",
... | autogrow when entering logic | [
"autogrow",
"when",
"entering",
"logic"
] | 98995a217241bf76f0c07eff1398f5592c061309 | https://github.com/Alex-D/Trumbowyg/blob/98995a217241bf76f0c07eff1398f5592c061309/src/trumbowyg.js#L725-L739 | train | |
Alex-D/Trumbowyg | src/trumbowyg.js | function () {
var t = this,
prefix = t.o.prefix;
var $btnPane = t.$btnPane = $('<div/>', {
class: prefix + 'button-pane'
});
$.each(t.o.btns, function (i, btnGrp) {
if (!$.isArray(btnGrp)) {
btnGrp = [b... | javascript | function () {
var t = this,
prefix = t.o.prefix;
var $btnPane = t.$btnPane = $('<div/>', {
class: prefix + 'button-pane'
});
$.each(t.o.btns, function (i, btnGrp) {
if (!$.isArray(btnGrp)) {
btnGrp = [b... | [
"function",
"(",
")",
"{",
"var",
"t",
"=",
"this",
",",
"prefix",
"=",
"t",
".",
"o",
".",
"prefix",
";",
"var",
"$btnPane",
"=",
"t",
".",
"$btnPane",
"=",
"$",
"(",
"'<div/>'",
",",
"{",
"class",
":",
"prefix",
"+",
"'button-pane'",
"}",
")",
... | Build button pane, use o.btns option | [
"Build",
"button",
"pane",
"use",
"o",
".",
"btns",
"option"
] | 98995a217241bf76f0c07eff1398f5592c061309 | https://github.com/Alex-D/Trumbowyg/blob/98995a217241bf76f0c07eff1398f5592c061309/src/trumbowyg.js#L743-L774 | train | |
Alex-D/Trumbowyg | src/trumbowyg.js | function (btnName) {
var t = this,
prefix = t.o.prefix,
btn = t.btnsDef[btnName],
hasIcon = btn.hasIcon != null ? btn.hasIcon : true;
if (btn.key) {
t.keys[btn.key] = {
fn: btn.fn || btnName,
... | javascript | function (btnName) {
var t = this,
prefix = t.o.prefix,
btn = t.btnsDef[btnName],
hasIcon = btn.hasIcon != null ? btn.hasIcon : true;
if (btn.key) {
t.keys[btn.key] = {
fn: btn.fn || btnName,
... | [
"function",
"(",
"btnName",
")",
"{",
"var",
"t",
"=",
"this",
",",
"prefix",
"=",
"t",
".",
"o",
".",
"prefix",
",",
"btn",
"=",
"t",
".",
"btnsDef",
"[",
"btnName",
"]",
",",
"hasIcon",
"=",
"btn",
".",
"hasIcon",
"!=",
"null",
"?",
"btn",
".... | Build a button for dropdown menu @param n : name of the subbutton | [
"Build",
"a",
"button",
"for",
"dropdown",
"menu"
] | 98995a217241bf76f0c07eff1398f5592c061309 | https://github.com/Alex-D/Trumbowyg/blob/98995a217241bf76f0c07eff1398f5592c061309/src/trumbowyg.js#L840-L871 | train | |
Alex-D/Trumbowyg | src/trumbowyg.js | function () {
var t = this,
fixedFullWidth = t.o.fixedFullWidth,
$box = t.$box;
if (!t.o.fixedBtnPane) {
return;
}
t.isFixed = false;
$(window)
.on('scroll.' + t.eventNamespace + ' resize.' + t... | javascript | function () {
var t = this,
fixedFullWidth = t.o.fixedFullWidth,
$box = t.$box;
if (!t.o.fixedBtnPane) {
return;
}
t.isFixed = false;
$(window)
.on('scroll.' + t.eventNamespace + ' resize.' + t... | [
"function",
"(",
")",
"{",
"var",
"t",
"=",
"this",
",",
"fixedFullWidth",
"=",
"t",
".",
"o",
".",
"fixedFullWidth",
",",
"$box",
"=",
"t",
".",
"$box",
";",
"if",
"(",
"!",
"t",
".",
"o",
".",
"fixedBtnPane",
")",
"{",
"return",
";",
"}",
"t"... | Management of fixed button pane | [
"Management",
"of",
"fixed",
"button",
"pane"
] | 98995a217241bf76f0c07eff1398f5592c061309 | https://github.com/Alex-D/Trumbowyg/blob/98995a217241bf76f0c07eff1398f5592c061309/src/trumbowyg.js#L902-L956 | train | |
Alex-D/Trumbowyg | src/trumbowyg.js | function () {
var t = this,
prefix = t.o.prefix;
if (t.isTextarea) {
t.$box.after(
t.$ta
.css({height: ''})
.val(t.html())
.removeClass(prefix + 'textarea')
... | javascript | function () {
var t = this,
prefix = t.o.prefix;
if (t.isTextarea) {
t.$box.after(
t.$ta
.css({height: ''})
.val(t.html())
.removeClass(prefix + 'textarea')
... | [
"function",
"(",
")",
"{",
"var",
"t",
"=",
"this",
",",
"prefix",
"=",
"t",
".",
"o",
".",
"prefix",
";",
"if",
"(",
"t",
".",
"isTextarea",
")",
"{",
"t",
".",
"$box",
".",
"after",
"(",
"t",
".",
"$ta",
".",
"css",
"(",
"{",
"height",
":... | Destroy the editor | [
"Destroy",
"the",
"editor"
] | 98995a217241bf76f0c07eff1398f5592c061309 | https://github.com/Alex-D/Trumbowyg/blob/98995a217241bf76f0c07eff1398f5592c061309/src/trumbowyg.js#L975-L1008 | train | |
Alex-D/Trumbowyg | src/trumbowyg.js | function () {
var t = this,
prefix = t.o.prefix;
if (t.o.autogrowOnEnter) {
t.autogrowOnEnterDontClose = !t.$box.hasClass(prefix + 'editor-hidden');
}
t.semanticCode(false, true);
setTimeout(function () {
t.do... | javascript | function () {
var t = this,
prefix = t.o.prefix;
if (t.o.autogrowOnEnter) {
t.autogrowOnEnterDontClose = !t.$box.hasClass(prefix + 'editor-hidden');
}
t.semanticCode(false, true);
setTimeout(function () {
t.do... | [
"function",
"(",
")",
"{",
"var",
"t",
"=",
"this",
",",
"prefix",
"=",
"t",
".",
"o",
".",
"prefix",
";",
"if",
"(",
"t",
".",
"o",
".",
"autogrowOnEnter",
")",
"{",
"t",
".",
"autogrowOnEnterDontClose",
"=",
"!",
"t",
".",
"$box",
".",
"hasClas... | Function call when click on viewHTML button | [
"Function",
"call",
"when",
"click",
"on",
"viewHTML",
"button"
] | 98995a217241bf76f0c07eff1398f5592c061309 | https://github.com/Alex-D/Trumbowyg/blob/98995a217241bf76f0c07eff1398f5592c061309/src/trumbowyg.js#L1019-L1044 | train | |
Alex-D/Trumbowyg | src/trumbowyg.js | function (name) {
var t = this,
d = t.doc,
prefix = t.o.prefix,
$dropdown = $('[data-' + prefix + 'dropdown=' + name + ']', t.$box),
$btn = $('.' + prefix + name + '-button', t.$btnPane),
show = $dropdown.is(':hidden');
... | javascript | function (name) {
var t = this,
d = t.doc,
prefix = t.o.prefix,
$dropdown = $('[data-' + prefix + 'dropdown=' + name + ']', t.$box),
$btn = $('.' + prefix + name + '-button', t.$btnPane),
show = $dropdown.is(':hidden');
... | [
"function",
"(",
"name",
")",
"{",
"var",
"t",
"=",
"this",
",",
"d",
"=",
"t",
".",
"doc",
",",
"prefix",
"=",
"t",
".",
"o",
".",
"prefix",
",",
"$dropdown",
"=",
"$",
"(",
"'[data-'",
"+",
"prefix",
"+",
"'dropdown='",
"+",
"name",
"+",
"']'... | Open dropdown when click on a button which open that | [
"Open",
"dropdown",
"when",
"click",
"on",
"a",
"button",
"which",
"open",
"that"
] | 98995a217241bf76f0c07eff1398f5592c061309 | https://github.com/Alex-D/Trumbowyg/blob/98995a217241bf76f0c07eff1398f5592c061309/src/trumbowyg.js#L1047-L1077 | train | |
Alex-D/Trumbowyg | src/trumbowyg.js | function (html) {
var t = this;
if (html != null) {
t.$ta.val(html);
t.syncCode(true);
t.$c.trigger('tbwchange');
return t;
}
return t.$ta.val();
} | javascript | function (html) {
var t = this;
if (html != null) {
t.$ta.val(html);
t.syncCode(true);
t.$c.trigger('tbwchange');
return t;
}
return t.$ta.val();
} | [
"function",
"(",
"html",
")",
"{",
"var",
"t",
"=",
"this",
";",
"if",
"(",
"html",
"!=",
"null",
")",
"{",
"t",
".",
"$ta",
".",
"val",
"(",
"html",
")",
";",
"t",
".",
"syncCode",
"(",
"true",
")",
";",
"t",
".",
"$c",
".",
"trigger",
"("... | HTML Code management | [
"HTML",
"Code",
"management"
] | 98995a217241bf76f0c07eff1398f5592c061309 | https://github.com/Alex-D/Trumbowyg/blob/98995a217241bf76f0c07eff1398f5592c061309/src/trumbowyg.js#L1081-L1092 | train | |
Alex-D/Trumbowyg | src/trumbowyg.js | function (force, full, keepRange) {
var t = this;
t.saveRange();
t.syncCode(force);
if (t.o.semantic) {
t.semanticTag('b', t.o.semanticKeepAttributes);
t.semanticTag('i', t.o.semanticKeepAttributes);
t.semanticTag('s', t.o.... | javascript | function (force, full, keepRange) {
var t = this;
t.saveRange();
t.syncCode(force);
if (t.o.semantic) {
t.semanticTag('b', t.o.semanticKeepAttributes);
t.semanticTag('i', t.o.semanticKeepAttributes);
t.semanticTag('s', t.o.... | [
"function",
"(",
"force",
",",
"full",
",",
"keepRange",
")",
"{",
"var",
"t",
"=",
"this",
";",
"t",
".",
"saveRange",
"(",
")",
";",
"t",
".",
"syncCode",
"(",
"force",
")",
";",
"if",
"(",
"t",
".",
"o",
".",
"semantic",
")",
"{",
"t",
"."... | Analyse and update to semantic code @param force : force to sync code from textarea @param full : wrap text nodes in <p> @param keepRange : leave selection range as it is | [
"Analyse",
"and",
"update",
"to",
"semantic",
"code"
] | 98995a217241bf76f0c07eff1398f5592c061309 | https://github.com/Alex-D/Trumbowyg/blob/98995a217241bf76f0c07eff1398f5592c061309/src/trumbowyg.js#L1132-L1187 | train | |
Alex-D/Trumbowyg | src/trumbowyg.js | function () {
var t = this,
documentSelection = t.doc.getSelection(),
node = documentSelection.focusNode,
text = new XMLSerializer().serializeToString(documentSelection.getRangeAt(0).cloneContents()),
url,
title,
... | javascript | function () {
var t = this,
documentSelection = t.doc.getSelection(),
node = documentSelection.focusNode,
text = new XMLSerializer().serializeToString(documentSelection.getRangeAt(0).cloneContents()),
url,
title,
... | [
"function",
"(",
")",
"{",
"var",
"t",
"=",
"this",
",",
"documentSelection",
"=",
"t",
".",
"doc",
".",
"getSelection",
"(",
")",
",",
"node",
"=",
"documentSelection",
".",
"focusNode",
",",
"text",
"=",
"new",
"XMLSerializer",
"(",
")",
".",
"serial... | Function call when user click on "Insert Link" | [
"Function",
"call",
"when",
"user",
"click",
"on",
"Insert",
"Link"
] | 98995a217241bf76f0c07eff1398f5592c061309 | https://github.com/Alex-D/Trumbowyg/blob/98995a217241bf76f0c07eff1398f5592c061309/src/trumbowyg.js#L1217-L1292 | train | |
Alex-D/Trumbowyg | src/trumbowyg.js | function (title, content) {
var t = this,
prefix = t.o.prefix;
// No open a modal box when exist other modal box
if ($('.' + prefix + 'modal-box', t.$box).length > 0) {
return false;
}
if (t.o.autogrowOnEnter) {
... | javascript | function (title, content) {
var t = this,
prefix = t.o.prefix;
// No open a modal box when exist other modal box
if ($('.' + prefix + 'modal-box', t.$box).length > 0) {
return false;
}
if (t.o.autogrowOnEnter) {
... | [
"function",
"(",
"title",
",",
"content",
")",
"{",
"var",
"t",
"=",
"this",
",",
"prefix",
"=",
"t",
".",
"o",
".",
"prefix",
";",
"// No open a modal box when exist other modal box",
"if",
"(",
"$",
"(",
"'.'",
"+",
"prefix",
"+",
"'modal-box'",
",",
"... | Open a modal box | [
"Open",
"a",
"modal",
"box"
] | 98995a217241bf76f0c07eff1398f5592c061309 | https://github.com/Alex-D/Trumbowyg/blob/98995a217241bf76f0c07eff1398f5592c061309/src/trumbowyg.js#L1425-L1514 | train | |
Alex-D/Trumbowyg | src/trumbowyg.js | function () {
var t = this,
prefix = t.o.prefix;
t.$btnPane.removeClass(prefix + 'disable');
t.$overlay.off();
// Find the modal box
var $modalBox = $('.' + prefix + 'modal-box', $(t.doc.body));
$modalBox.animate({
... | javascript | function () {
var t = this,
prefix = t.o.prefix;
t.$btnPane.removeClass(prefix + 'disable');
t.$overlay.off();
// Find the modal box
var $modalBox = $('.' + prefix + 'modal-box', $(t.doc.body));
$modalBox.animate({
... | [
"function",
"(",
")",
"{",
"var",
"t",
"=",
"this",
",",
"prefix",
"=",
"t",
".",
"o",
".",
"prefix",
";",
"t",
".",
"$btnPane",
".",
"removeClass",
"(",
"prefix",
"+",
"'disable'",
")",
";",
"t",
".",
"$overlay",
".",
"off",
"(",
")",
";",
"//... | close current modal box | [
"close",
"current",
"modal",
"box"
] | 98995a217241bf76f0c07eff1398f5592c061309 | https://github.com/Alex-D/Trumbowyg/blob/98995a217241bf76f0c07eff1398f5592c061309/src/trumbowyg.js#L1527-L1545 | train | |
Alex-D/Trumbowyg | src/trumbowyg.js | function (title, fields, cmd) {
var t = this,
prefix = t.o.prefix,
lg = t.lang,
html = '';
$.each(fields, function (fieldName, field) {
var l = field.label || fieldName,
n = field.name || fieldName,
... | javascript | function (title, fields, cmd) {
var t = this,
prefix = t.o.prefix,
lg = t.lang,
html = '';
$.each(fields, function (fieldName, field) {
var l = field.label || fieldName,
n = field.name || fieldName,
... | [
"function",
"(",
"title",
",",
"fields",
",",
"cmd",
")",
"{",
"var",
"t",
"=",
"this",
",",
"prefix",
"=",
"t",
".",
"o",
".",
"prefix",
",",
"lg",
"=",
"t",
".",
"lang",
",",
"html",
"=",
"''",
";",
"$",
".",
"each",
"(",
"fields",
",",
"... | Preformatted build and management modal | [
"Preformatted",
"build",
"and",
"management",
"modal"
] | 98995a217241bf76f0c07eff1398f5592c061309 | https://github.com/Alex-D/Trumbowyg/blob/98995a217241bf76f0c07eff1398f5592c061309/src/trumbowyg.js#L1547-L1617 | train | |
Alex-D/Trumbowyg | plugins/highlight/trumbowyg.highlight.js | buildButtonDef | function buildButtonDef(trumbowyg) {
return {
fn: function () {
var $modal = trumbowyg.openModal('Code', [
'<div class="' + trumbowyg.o.prefix + 'highlight-form-group">',
' <select class="' + trumbowyg.o.prefix + 'highlight-form-control langu... | javascript | function buildButtonDef(trumbowyg) {
return {
fn: function () {
var $modal = trumbowyg.openModal('Code', [
'<div class="' + trumbowyg.o.prefix + 'highlight-form-group">',
' <select class="' + trumbowyg.o.prefix + 'highlight-form-control langu... | [
"function",
"buildButtonDef",
"(",
"trumbowyg",
")",
"{",
"return",
"{",
"fn",
":",
"function",
"(",
")",
"{",
"var",
"$modal",
"=",
"trumbowyg",
".",
"openModal",
"(",
"'Code'",
",",
"[",
"'<div class=\"'",
"+",
"trumbowyg",
".",
"o",
".",
"prefix",
"+"... | If my plugin is a button | [
"If",
"my",
"plugin",
"is",
"a",
"button"
] | 98995a217241bf76f0c07eff1398f5592c061309 | https://github.com/Alex-D/Trumbowyg/blob/98995a217241bf76f0c07eff1398f5592c061309/plugins/highlight/trumbowyg.highlight.js#L17-L57 | train |
Netflix/vizceral | src/dns/dnsConnectionView.js | CalculateCircleCenter | function CalculateCircleCenter (A, B, C) {
const aSlope = (B.y - A.y) / (B.x - A.x);
const bSlope = (C.y - B.y) / (C.x - B.x);
if (aSlope === 0 || bSlope === 0) {
// rotate the points about origin to retry and then rotate the answer back.
// this should avoid div by zero.
// we could pick any acute a... | javascript | function CalculateCircleCenter (A, B, C) {
const aSlope = (B.y - A.y) / (B.x - A.x);
const bSlope = (C.y - B.y) / (C.x - B.x);
if (aSlope === 0 || bSlope === 0) {
// rotate the points about origin to retry and then rotate the answer back.
// this should avoid div by zero.
// we could pick any acute a... | [
"function",
"CalculateCircleCenter",
"(",
"A",
",",
"B",
",",
"C",
")",
"{",
"const",
"aSlope",
"=",
"(",
"B",
".",
"y",
"-",
"A",
".",
"y",
")",
"/",
"(",
"B",
".",
"x",
"-",
"A",
".",
"x",
")",
";",
"const",
"bSlope",
"=",
"(",
"C",
".",
... | Given three points, A B C, find the center of a circle that goes through all three. | [
"Given",
"three",
"points",
"A",
"B",
"C",
"find",
"the",
"center",
"of",
"a",
"circle",
"that",
"goes",
"through",
"all",
"three",
"."
] | 848db649b3baea5fd761d79b0f15154a205fb9f4 | https://github.com/Netflix/vizceral/blob/848db649b3baea5fd761d79b0f15154a205fb9f4/src/dns/dnsConnectionView.js#L44-L63 | train |
louischatriot/nedb | lib/model.js | checkObject | function checkObject (obj) {
if (util.isArray(obj)) {
obj.forEach(function (o) {
checkObject(o);
});
}
if (typeof obj === 'object' && obj !== null) {
Object.keys(obj).forEach(function (k) {
checkKey(k, obj[k]);
checkObject(obj[k]);
});
}
} | javascript | function checkObject (obj) {
if (util.isArray(obj)) {
obj.forEach(function (o) {
checkObject(o);
});
}
if (typeof obj === 'object' && obj !== null) {
Object.keys(obj).forEach(function (k) {
checkKey(k, obj[k]);
checkObject(obj[k]);
});
}
} | [
"function",
"checkObject",
"(",
"obj",
")",
"{",
"if",
"(",
"util",
".",
"isArray",
"(",
"obj",
")",
")",
"{",
"obj",
".",
"forEach",
"(",
"function",
"(",
"o",
")",
"{",
"checkObject",
"(",
"o",
")",
";",
"}",
")",
";",
"}",
"if",
"(",
"typeof... | Check a DB object and throw an error if it's not valid
Works by applying the above checkKey function to all fields recursively | [
"Check",
"a",
"DB",
"object",
"and",
"throw",
"an",
"error",
"if",
"it",
"s",
"not",
"valid",
"Works",
"by",
"applying",
"the",
"above",
"checkKey",
"function",
"to",
"all",
"fields",
"recursively"
] | aa3302e5dcefa471431901a8f3fe63e532a5a7b2 | https://github.com/louischatriot/nedb/blob/aa3302e5dcefa471431901a8f3fe63e532a5a7b2/lib/model.js#L45-L58 | train |
louischatriot/nedb | lib/model.js | isPrimitiveType | function isPrimitiveType (obj) {
return ( typeof obj === 'boolean' ||
typeof obj === 'number' ||
typeof obj === 'string' ||
obj === null ||
util.isDate(obj) ||
util.isArray(obj));
} | javascript | function isPrimitiveType (obj) {
return ( typeof obj === 'boolean' ||
typeof obj === 'number' ||
typeof obj === 'string' ||
obj === null ||
util.isDate(obj) ||
util.isArray(obj));
} | [
"function",
"isPrimitiveType",
"(",
"obj",
")",
"{",
"return",
"(",
"typeof",
"obj",
"===",
"'boolean'",
"||",
"typeof",
"obj",
"===",
"'number'",
"||",
"typeof",
"obj",
"===",
"'string'",
"||",
"obj",
"===",
"null",
"||",
"util",
".",
"isDate",
"(",
"ob... | Tells if an object is a primitive type or a "real" object
Arrays are considered primitive | [
"Tells",
"if",
"an",
"object",
"is",
"a",
"primitive",
"type",
"or",
"a",
"real",
"object",
"Arrays",
"are",
"considered",
"primitive"
] | aa3302e5dcefa471431901a8f3fe63e532a5a7b2 | https://github.com/louischatriot/nedb/blob/aa3302e5dcefa471431901a8f3fe63e532a5a7b2/lib/model.js#L144-L151 | train |
louischatriot/nedb | lib/model.js | createModifierFunction | function createModifierFunction (modifier) {
return function (obj, field, value) {
var fieldParts = typeof field === 'string' ? field.split('.') : field;
if (fieldParts.length === 1) {
lastStepModifierFunctions[modifier](obj, field, value);
} else {
if (obj[fieldParts[0]] === undefined) {
... | javascript | function createModifierFunction (modifier) {
return function (obj, field, value) {
var fieldParts = typeof field === 'string' ? field.split('.') : field;
if (fieldParts.length === 1) {
lastStepModifierFunctions[modifier](obj, field, value);
} else {
if (obj[fieldParts[0]] === undefined) {
... | [
"function",
"createModifierFunction",
"(",
"modifier",
")",
"{",
"return",
"function",
"(",
"obj",
",",
"field",
",",
"value",
")",
"{",
"var",
"fieldParts",
"=",
"typeof",
"field",
"===",
"'string'",
"?",
"field",
".",
"split",
"(",
"'.'",
")",
":",
"fi... | Given its name, create the complete modifier function | [
"Given",
"its",
"name",
"create",
"the",
"complete",
"modifier",
"function"
] | aa3302e5dcefa471431901a8f3fe63e532a5a7b2 | https://github.com/louischatriot/nedb/blob/aa3302e5dcefa471431901a8f3fe63e532a5a7b2/lib/model.js#L412-L426 | train |
louischatriot/nedb | lib/model.js | areComparable | function areComparable (a, b) {
if (typeof a !== 'string' && typeof a !== 'number' && !util.isDate(a) &&
typeof b !== 'string' && typeof b !== 'number' && !util.isDate(b)) {
return false;
}
if (typeof a !== typeof b) { return false; }
return true;
} | javascript | function areComparable (a, b) {
if (typeof a !== 'string' && typeof a !== 'number' && !util.isDate(a) &&
typeof b !== 'string' && typeof b !== 'number' && !util.isDate(b)) {
return false;
}
if (typeof a !== typeof b) { return false; }
return true;
} | [
"function",
"areComparable",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"typeof",
"a",
"!==",
"'string'",
"&&",
"typeof",
"a",
"!==",
"'number'",
"&&",
"!",
"util",
".",
"isDate",
"(",
"a",
")",
"&&",
"typeof",
"b",
"!==",
"'string'",
"&&",
"typeof",
... | Check that two values are comparable | [
"Check",
"that",
"two",
"values",
"are",
"comparable"
] | aa3302e5dcefa471431901a8f3fe63e532a5a7b2 | https://github.com/louischatriot/nedb/blob/aa3302e5dcefa471431901a8f3fe63e532a5a7b2/lib/model.js#L563-L572 | train |
louischatriot/nedb | benchmarks/commonUtilities.js | getRandomArray | function getRandomArray (n) {
var res = []
, i, j, temp
;
for (i = 0; i < n; i += 1) { res[i] = i; }
for (i = n - 1; i >= 1; i -= 1) {
j = Math.floor((i + 1) * Math.random());
temp = res[i];
res[i] = res[j];
res[j] = temp;
}
return res;
} | javascript | function getRandomArray (n) {
var res = []
, i, j, temp
;
for (i = 0; i < n; i += 1) { res[i] = i; }
for (i = n - 1; i >= 1; i -= 1) {
j = Math.floor((i + 1) * Math.random());
temp = res[i];
res[i] = res[j];
res[j] = temp;
}
return res;
} | [
"function",
"getRandomArray",
"(",
"n",
")",
"{",
"var",
"res",
"=",
"[",
"]",
",",
"i",
",",
"j",
",",
"temp",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"+=",
"1",
")",
"{",
"res",
"[",
"i",
"]",
"=",
"i",
";",
"}",... | Return an array with the numbers from 0 to n-1, in a random order
Uses Fisher Yates algorithm
Useful to get fair tests | [
"Return",
"an",
"array",
"with",
"the",
"numbers",
"from",
"0",
"to",
"n",
"-",
"1",
"in",
"a",
"random",
"order",
"Uses",
"Fisher",
"Yates",
"algorithm",
"Useful",
"to",
"get",
"fair",
"tests"
] | aa3302e5dcefa471431901a8f3fe63e532a5a7b2 | https://github.com/louischatriot/nedb/blob/aa3302e5dcefa471431901a8f3fe63e532a5a7b2/benchmarks/commonUtilities.js#L69-L84 | train |
louischatriot/nedb | browser-version/out/nedb.js | Cursor | function Cursor (db, query, execFn) {
this.db = db;
this.query = query || {};
if (execFn) { this.execFn = execFn; }
} | javascript | function Cursor (db, query, execFn) {
this.db = db;
this.query = query || {};
if (execFn) { this.execFn = execFn; }
} | [
"function",
"Cursor",
"(",
"db",
",",
"query",
",",
"execFn",
")",
"{",
"this",
".",
"db",
"=",
"db",
";",
"this",
".",
"query",
"=",
"query",
"||",
"{",
"}",
";",
"if",
"(",
"execFn",
")",
"{",
"this",
".",
"execFn",
"=",
"execFn",
";",
"}",
... | Create a new cursor for this collection
@param {Datastore} db - The datastore this cursor is bound to
@param {Query} query - The query this cursor will operate on
@param {Function} execFn - Handler to be executed after cursor has found the results and before the callback passed to find/findOne/update/remove | [
"Create",
"a",
"new",
"cursor",
"for",
"this",
"collection"
] | aa3302e5dcefa471431901a8f3fe63e532a5a7b2 | https://github.com/louischatriot/nedb/blob/aa3302e5dcefa471431901a8f3fe63e532a5a7b2/browser-version/out/nedb.js#L795-L799 | train |
louischatriot/nedb | browser-version/out/nedb.js | _AVLTree | function _AVLTree (options) {
options = options || {};
this.left = null;
this.right = null;
this.parent = options.parent !== undefined ? options.parent : null;
if (options.hasOwnProperty('key')) { this.key = options.key; }
this.data = options.hasOwnProperty('value') ? [options.value] : [];
this.unique = ... | javascript | function _AVLTree (options) {
options = options || {};
this.left = null;
this.right = null;
this.parent = options.parent !== undefined ? options.parent : null;
if (options.hasOwnProperty('key')) { this.key = options.key; }
this.data = options.hasOwnProperty('value') ? [options.value] : [];
this.unique = ... | [
"function",
"_AVLTree",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"left",
"=",
"null",
";",
"this",
".",
"right",
"=",
"null",
";",
"this",
".",
"parent",
"=",
"options",
".",
"parent",
"!==",
"undefined",... | Constructor of the internal AVLTree
@param {Object} options Optional
@param {Boolean} options.unique Whether to enforce a 'unique' constraint on the key or not
@param {Key} options.key Initialize this BST's key with key
@param {Value} options.value Initialize this BST's data with [value]
@param {Function} opti... | [
"Constructor",
"of",
"the",
"internal",
"AVLTree"
] | aa3302e5dcefa471431901a8f3fe63e532a5a7b2 | https://github.com/louischatriot/nedb/blob/aa3302e5dcefa471431901a8f3fe63e532a5a7b2/browser-version/out/nedb.js#L4393-L4405 | train |
louischatriot/nedb | browser-version/out/nedb.js | append | function append (array, toAppend) {
var i;
for (i = 0; i < toAppend.length; i += 1) {
array.push(toAppend[i]);
}
} | javascript | function append (array, toAppend) {
var i;
for (i = 0; i < toAppend.length; i += 1) {
array.push(toAppend[i]);
}
} | [
"function",
"append",
"(",
"array",
",",
"toAppend",
")",
"{",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"toAppend",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"array",
".",
"push",
"(",
"toAppend",
"[",
"i",
"]",
")",
";"... | Append all elements in toAppend to array | [
"Append",
"all",
"elements",
"in",
"toAppend",
"to",
"array"
] | aa3302e5dcefa471431901a8f3fe63e532a5a7b2 | https://github.com/louischatriot/nedb/blob/aa3302e5dcefa471431901a8f3fe63e532a5a7b2/browser-version/out/nedb.js#L5151-L5157 | train |
louischatriot/nedb | browser-version/out/nedb.js | getRandomArray | function getRandomArray (n) {
var res, next;
if (n === 0) { return []; }
if (n === 1) { return [0]; }
res = getRandomArray(n - 1);
next = Math.floor(Math.random() * n);
res.splice(next, 0, n - 1); // Add n-1 at a random position in the array
return res;
} | javascript | function getRandomArray (n) {
var res, next;
if (n === 0) { return []; }
if (n === 1) { return [0]; }
res = getRandomArray(n - 1);
next = Math.floor(Math.random() * n);
res.splice(next, 0, n - 1); // Add n-1 at a random position in the array
return res;
} | [
"function",
"getRandomArray",
"(",
"n",
")",
"{",
"var",
"res",
",",
"next",
";",
"if",
"(",
"n",
"===",
"0",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"n",
"===",
"1",
")",
"{",
"return",
"[",
"0",
"]",
";",
"}",
"res",
"=",
"getR... | Return an array with the numbers from 0 to n-1, in a random order | [
"Return",
"an",
"array",
"with",
"the",
"numbers",
"from",
"0",
"to",
"n",
"-",
"1",
"in",
"a",
"random",
"order"
] | aa3302e5dcefa471431901a8f3fe63e532a5a7b2 | https://github.com/louischatriot/nedb/blob/aa3302e5dcefa471431901a8f3fe63e532a5a7b2/browser-version/out/nedb.js#L5368-L5379 | train |
louischatriot/nedb | browser-version/out/nedb.js | Promise | function Promise(resolver) {
if (!isFunction(resolver)) {
throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
}
if (!(this instanceof Promise)) {
throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, t... | javascript | function Promise(resolver) {
if (!isFunction(resolver)) {
throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
}
if (!(this instanceof Promise)) {
throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, t... | [
"function",
"Promise",
"(",
"resolver",
")",
"{",
"if",
"(",
"!",
"isFunction",
"(",
"resolver",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'You must pass a resolver function as the first argument to the promise constructor'",
")",
";",
"}",
"if",
"(",
"!",
... | default async is asap; | [
"default",
"async",
"is",
"asap",
";"
] | aa3302e5dcefa471431901a8f3fe63e532a5a7b2 | https://github.com/louischatriot/nedb/blob/aa3302e5dcefa471431901a8f3fe63e532a5a7b2/browser-version/out/nedb.js#L5711-L5723 | train |
Blizzard/node-rdkafka | lib/kafka-consumer-stream.js | KafkaConsumerStream | function KafkaConsumerStream(consumer, options) {
if (!(this instanceof KafkaConsumerStream)) {
return new KafkaConsumerStream(consumer, options);
}
if (options === undefined) {
options = { waitInterval: 1000 };
} else if (typeof options === 'number') {
options = { waitInterval: options };
} else... | javascript | function KafkaConsumerStream(consumer, options) {
if (!(this instanceof KafkaConsumerStream)) {
return new KafkaConsumerStream(consumer, options);
}
if (options === undefined) {
options = { waitInterval: 1000 };
} else if (typeof options === 'number') {
options = { waitInterval: options };
} else... | [
"function",
"KafkaConsumerStream",
"(",
"consumer",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"KafkaConsumerStream",
")",
")",
"{",
"return",
"new",
"KafkaConsumerStream",
"(",
"consumer",
",",
"options",
")",
";",
"}",
"if",
"(",
... | ReadableStream integrating with the Kafka Consumer.
This class is used to read data off of Kafka in a streaming way. It is
useful if you'd like to have a way to pipe Kafka into other systems. You
should generally not make this class yourself, as it is not even exposed
as part of module.exports. Instead, you should Kaf... | [
"ReadableStream",
"integrating",
"with",
"the",
"Kafka",
"Consumer",
"."
] | 50f99ab46c4a475678b94af07c2ea02e1ba353ff | https://github.com/Blizzard/node-rdkafka/blob/50f99ab46c4a475678b94af07c2ea02e1ba353ff/lib/kafka-consumer-stream.js#L47-L124 | train |
Blizzard/node-rdkafka | lib/kafka-consumer-stream.js | retry | function retry() {
if (!self.waitInterval) {
setImmediate(function() {
self._read(size);
});
} else {
setTimeout(function() {
self._read(size);
}, self.waitInterval * Math.random()).unref();
}
} | javascript | function retry() {
if (!self.waitInterval) {
setImmediate(function() {
self._read(size);
});
} else {
setTimeout(function() {
self._read(size);
}, self.waitInterval * Math.random()).unref();
}
} | [
"function",
"retry",
"(",
")",
"{",
"if",
"(",
"!",
"self",
".",
"waitInterval",
")",
"{",
"setImmediate",
"(",
"function",
"(",
")",
"{",
"self",
".",
"_read",
"(",
"size",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"setTimeout",
"(",
"function",
... | Retry function. Will wait up to the wait interval, with some random noise if one is provided. Otherwise, will go immediately. | [
"Retry",
"function",
".",
"Will",
"wait",
"up",
"to",
"the",
"wait",
"interval",
"with",
"some",
"random",
"noise",
"if",
"one",
"is",
"provided",
".",
"Otherwise",
"will",
"go",
"immediately",
"."
] | 50f99ab46c4a475678b94af07c2ea02e1ba353ff | https://github.com/Blizzard/node-rdkafka/blob/50f99ab46c4a475678b94af07c2ea02e1ba353ff/lib/kafka-consumer-stream.js#L166-L176 | train |
Blizzard/node-rdkafka | lib/tools/ref-counter.js | RefCounter | function RefCounter(onActive, onPassive) {
this.context = {};
this.onActive = onActive;
this.onPassive = onPassive;
this.currentValue = 0;
this.isRunning = false;
} | javascript | function RefCounter(onActive, onPassive) {
this.context = {};
this.onActive = onActive;
this.onPassive = onPassive;
this.currentValue = 0;
this.isRunning = false;
} | [
"function",
"RefCounter",
"(",
"onActive",
",",
"onPassive",
")",
"{",
"this",
".",
"context",
"=",
"{",
"}",
";",
"this",
".",
"onActive",
"=",
"onActive",
";",
"this",
".",
"onPassive",
"=",
"onPassive",
";",
"this",
".",
"currentValue",
"=",
"0",
";... | Ref counter class.
Is used to basically determine active/inactive and allow callbacks that
hook into each.
For the producer, it is used to begin rapid polling after a produce until
the delivery report is dispatched. | [
"Ref",
"counter",
"class",
"."
] | 50f99ab46c4a475678b94af07c2ea02e1ba353ff | https://github.com/Blizzard/node-rdkafka/blob/50f99ab46c4a475678b94af07c2ea02e1ba353ff/lib/tools/ref-counter.js#L21-L27 | train |
Blizzard/node-rdkafka | lib/client.js | Client | function Client(globalConf, SubClientType, topicConf) {
if (!(this instanceof Client)) {
return new Client(globalConf, SubClientType, topicConf);
}
Emitter.call(this);
// This superclass must be initialized with the Kafka.{Producer,Consumer}
// @example var client = new Client({}, Kafka.Producer);
// ... | javascript | function Client(globalConf, SubClientType, topicConf) {
if (!(this instanceof Client)) {
return new Client(globalConf, SubClientType, topicConf);
}
Emitter.call(this);
// This superclass must be initialized with the Kafka.{Producer,Consumer}
// @example var client = new Client({}, Kafka.Producer);
// ... | [
"function",
"Client",
"(",
"globalConf",
",",
"SubClientType",
",",
"topicConf",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Client",
")",
")",
"{",
"return",
"new",
"Client",
"(",
"globalConf",
",",
"SubClientType",
",",
"topicConf",
")",
";",
... | Base class for Consumer and Producer
This should not be created independently, but rather is
the base class on which both producer and consumer
get their common functionality.
@param {object} globalConf - Global configuration in key value pairs.
@param {function} SubClientType - The function representing the subclien... | [
"Base",
"class",
"for",
"Consumer",
"and",
"Producer"
] | 50f99ab46c4a475678b94af07c2ea02e1ba353ff | https://github.com/Blizzard/node-rdkafka/blob/50f99ab46c4a475678b94af07c2ea02e1ba353ff/lib/client.js#L35-L113 | train |
Blizzard/node-rdkafka | lib/topic-partition.js | TopicPartition | function TopicPartition(topic, partition, offset) {
if (!(this instanceof TopicPartition)) {
return new TopicPartition(topic, partition, offset);
}
// Validate that the elements we are iterating over are actual topic partition
// js objects. They do not need an offset, but they do need partition
if (!top... | javascript | function TopicPartition(topic, partition, offset) {
if (!(this instanceof TopicPartition)) {
return new TopicPartition(topic, partition, offset);
}
// Validate that the elements we are iterating over are actual topic partition
// js objects. They do not need an offset, but they do need partition
if (!top... | [
"function",
"TopicPartition",
"(",
"topic",
",",
"partition",
",",
"offset",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"TopicPartition",
")",
")",
"{",
"return",
"new",
"TopicPartition",
"(",
"topic",
",",
"partition",
",",
"offset",
")",
";",
... | Create a topic partition. Just does some validation and decoration
on topic partitions provided.
Goal is still to behave like a plain javascript object but with validation
and potentially some extra methods | [
"Create",
"a",
"topic",
"partition",
".",
"Just",
"does",
"some",
"validation",
"and",
"decoration",
"on",
"topic",
"partitions",
"provided",
"."
] | 50f99ab46c4a475678b94af07c2ea02e1ba353ff | https://github.com/Blizzard/node-rdkafka/blob/50f99ab46c4a475678b94af07c2ea02e1ba353ff/lib/topic-partition.js#L46-L88 | train |
Blizzard/node-rdkafka | lib/kafka-consumer.js | KafkaConsumer | function KafkaConsumer(conf, topicConf) {
if (!(this instanceof KafkaConsumer)) {
return new KafkaConsumer(conf, topicConf);
}
conf = shallowCopy(conf);
topicConf = shallowCopy(topicConf);
var onRebalance = conf.rebalance_cb;
var self = this;
// If rebalance is undefined we don't want any part of ... | javascript | function KafkaConsumer(conf, topicConf) {
if (!(this instanceof KafkaConsumer)) {
return new KafkaConsumer(conf, topicConf);
}
conf = shallowCopy(conf);
topicConf = shallowCopy(topicConf);
var onRebalance = conf.rebalance_cb;
var self = this;
// If rebalance is undefined we don't want any part of ... | [
"function",
"KafkaConsumer",
"(",
"conf",
",",
"topicConf",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"KafkaConsumer",
")",
")",
"{",
"return",
"new",
"KafkaConsumer",
"(",
"conf",
",",
"topicConf",
")",
";",
"}",
"conf",
"=",
"shallowCopy",
"... | KafkaConsumer class for reading messages from Kafka
This is the main entry point for reading data from Kafka. You
configure this like you do any other client, with a global
configuration and default topic configuration.
Once you instantiate this object, connecting will open a socket.
Data will not be read until you t... | [
"KafkaConsumer",
"class",
"for",
"reading",
"messages",
"from",
"Kafka"
] | 50f99ab46c4a475678b94af07c2ea02e1ba353ff | https://github.com/Blizzard/node-rdkafka/blob/50f99ab46c4a475678b94af07c2ea02e1ba353ff/lib/kafka-consumer.js#L40-L128 | train |
Blizzard/node-rdkafka | lib/producer/high-level-producer.js | createSerializer | function createSerializer(serializer) {
var applyFn = function serializationWrapper(v, cb) {
try {
return cb ? serializer(v, cb) : serializer(v);
} catch (e) {
var modifiedError = new Error('Could not serialize value: ' + e.message);
modifiedError.value = v;
modifiedError.serializer = ... | javascript | function createSerializer(serializer) {
var applyFn = function serializationWrapper(v, cb) {
try {
return cb ? serializer(v, cb) : serializer(v);
} catch (e) {
var modifiedError = new Error('Could not serialize value: ' + e.message);
modifiedError.value = v;
modifiedError.serializer = ... | [
"function",
"createSerializer",
"(",
"serializer",
")",
"{",
"var",
"applyFn",
"=",
"function",
"serializationWrapper",
"(",
"v",
",",
"cb",
")",
"{",
"try",
"{",
"return",
"cb",
"?",
"serializer",
"(",
"v",
",",
"cb",
")",
":",
"serializer",
"(",
"v",
... | Create a serializer
Method simply wraps a serializer provided by a user
so it adds context to the error
@returns {function} Serialization function | [
"Create",
"a",
"serializer"
] | 50f99ab46c4a475678b94af07c2ea02e1ba353ff | https://github.com/Blizzard/node-rdkafka/blob/50f99ab46c4a475678b94af07c2ea02e1ba353ff/lib/producer/high-level-producer.js#L34-L52 | train |
Blizzard/node-rdkafka | lib/producer/high-level-producer.js | HighLevelProducer | function HighLevelProducer(conf, topicConf) {
if (!(this instanceof HighLevelProducer)) {
return new HighLevelProducer(conf, topicConf);
}
// Force this to be true for the high level producer
conf = shallowCopy(conf);
conf.dr_cb = true;
// producer is an initialized consumer object
// @see NodeKafka... | javascript | function HighLevelProducer(conf, topicConf) {
if (!(this instanceof HighLevelProducer)) {
return new HighLevelProducer(conf, topicConf);
}
// Force this to be true for the high level producer
conf = shallowCopy(conf);
conf.dr_cb = true;
// producer is an initialized consumer object
// @see NodeKafka... | [
"function",
"HighLevelProducer",
"(",
"conf",
",",
"topicConf",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"HighLevelProducer",
")",
")",
"{",
"return",
"new",
"HighLevelProducer",
"(",
"conf",
",",
"topicConf",
")",
";",
"}",
"// Force this to be tr... | Producer class for sending messages to Kafka in a higher level fashion
This is the main entry point for writing data to Kafka if you want more
functionality than librdkafka supports out of the box. You
configure this like you do any other client, with a global
configuration and default topic configuration.
Once you i... | [
"Producer",
"class",
"for",
"sending",
"messages",
"to",
"Kafka",
"in",
"a",
"higher",
"level",
"fashion"
] | 50f99ab46c4a475678b94af07c2ea02e1ba353ff | https://github.com/Blizzard/node-rdkafka/blob/50f99ab46c4a475678b94af07c2ea02e1ba353ff/lib/producer/high-level-producer.js#L84-L143 | train |
Blizzard/node-rdkafka | lib/producer/high-level-producer.js | doProduce | function doProduce(v, k) {
try {
var r = self._oldProduce(topic, partition,
v, k,
timestamp, opaque);
self._hl.deliveryEmitter.once(opaque.__message_id, function(err, offset) {
self._hl.pollingRef.decrement();
setImmediate(function() {
// Offset must be greater... | javascript | function doProduce(v, k) {
try {
var r = self._oldProduce(topic, partition,
v, k,
timestamp, opaque);
self._hl.deliveryEmitter.once(opaque.__message_id, function(err, offset) {
self._hl.pollingRef.decrement();
setImmediate(function() {
// Offset must be greater... | [
"function",
"doProduce",
"(",
"v",
",",
"k",
")",
"{",
"try",
"{",
"var",
"r",
"=",
"self",
".",
"_oldProduce",
"(",
"topic",
",",
"partition",
",",
"v",
",",
"k",
",",
"timestamp",
",",
"opaque",
")",
";",
"self",
".",
"_hl",
".",
"deliveryEmitter... | Actually do the produce with new key and value based on deserialized results | [
"Actually",
"do",
"the",
"produce",
"with",
"new",
"key",
"and",
"value",
"based",
"on",
"deserialized",
"results"
] | 50f99ab46c4a475678b94af07c2ea02e1ba353ff | https://github.com/Blizzard/node-rdkafka/blob/50f99ab46c4a475678b94af07c2ea02e1ba353ff/lib/producer/high-level-producer.js#L180-L199 | train |
Blizzard/node-rdkafka | lib/error.js | LibrdKafkaError | function LibrdKafkaError(e) {
if (!(this instanceof LibrdKafkaError)) {
return new LibrdKafkaError(e);
}
if (typeof e === 'number') {
this.message = librdkafka.err2str(e);
this.code = e;
this.errno = e;
if (e >= LibrdKafkaError.codes.ERR__END) {
this.origin = 'local';
} else {
... | javascript | function LibrdKafkaError(e) {
if (!(this instanceof LibrdKafkaError)) {
return new LibrdKafkaError(e);
}
if (typeof e === 'number') {
this.message = librdkafka.err2str(e);
this.code = e;
this.errno = e;
if (e >= LibrdKafkaError.codes.ERR__END) {
this.origin = 'local';
} else {
... | [
"function",
"LibrdKafkaError",
"(",
"e",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"LibrdKafkaError",
")",
")",
"{",
"return",
"new",
"LibrdKafkaError",
"(",
"e",
")",
";",
"}",
"if",
"(",
"typeof",
"e",
"===",
"'number'",
")",
"{",
"this",
... | Representation of a librdkafka error
This can be created by giving either another error
to piggy-back on. In this situation it tries to parse
the error string to figure out the intent. However, more usually,
it is constructed by an error object created by a C++ Baton.
@param {object|error} e - An object or error to w... | [
"Representation",
"of",
"a",
"librdkafka",
"error"
] | 50f99ab46c4a475678b94af07c2ea02e1ba353ff | https://github.com/Blizzard/node-rdkafka/blob/50f99ab46c4a475678b94af07c2ea02e1ba353ff/lib/error.js#L275-L331 | train |
Blizzard/node-rdkafka | lib/producer.js | Producer | function Producer(conf, topicConf) {
if (!(this instanceof Producer)) {
return new Producer(conf, topicConf);
}
conf = shallowCopy(conf);
topicConf = shallowCopy(topicConf);
/**
* Producer message. This is sent to the wrapper, not received from it
*
* @typedef {object} Producer~Message
* @pr... | javascript | function Producer(conf, topicConf) {
if (!(this instanceof Producer)) {
return new Producer(conf, topicConf);
}
conf = shallowCopy(conf);
topicConf = shallowCopy(topicConf);
/**
* Producer message. This is sent to the wrapper, not received from it
*
* @typedef {object} Producer~Message
* @pr... | [
"function",
"Producer",
"(",
"conf",
",",
"topicConf",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Producer",
")",
")",
"{",
"return",
"new",
"Producer",
"(",
"conf",
",",
"topicConf",
")",
";",
"}",
"conf",
"=",
"shallowCopy",
"(",
"conf",
... | Producer class for sending messages to Kafka
This is the main entry point for writing data to Kafka. You
configure this like you do any other client, with a global
configuration and default topic configuration.
Once you instantiate this object, you need to connect to it first.
This allows you to get the metadata and ... | [
"Producer",
"class",
"for",
"sending",
"messages",
"to",
"Kafka"
] | 50f99ab46c4a475678b94af07c2ea02e1ba353ff | https://github.com/Blizzard/node-rdkafka/blob/50f99ab46c4a475678b94af07c2ea02e1ba353ff/lib/producer.js#L41-L101 | train |
Blizzard/node-rdkafka | lib/producer-stream.js | ProducerStream | function ProducerStream(producer, options) {
if (!(this instanceof ProducerStream)) {
return new ProducerStream(producer, options);
}
if (options === undefined) {
options = {};
} else if (typeof options === 'string') {
options = { encoding: options };
} else if (options === null || typeof options... | javascript | function ProducerStream(producer, options) {
if (!(this instanceof ProducerStream)) {
return new ProducerStream(producer, options);
}
if (options === undefined) {
options = {};
} else if (typeof options === 'string') {
options = { encoding: options };
} else if (options === null || typeof options... | [
"function",
"ProducerStream",
"(",
"producer",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"ProducerStream",
")",
")",
"{",
"return",
"new",
"ProducerStream",
"(",
"producer",
",",
"options",
")",
";",
"}",
"if",
"(",
"options",
... | Writable stream integrating with the Kafka Producer.
This class is used to write data to Kafka in a streaming way. It takes
buffers of data and puts them into the appropriate Kafka topic. If you need
finer control over partitions or keys, this is probably not the class for
you. In that situation just use the Producer ... | [
"Writable",
"stream",
"integrating",
"with",
"the",
"Kafka",
"Producer",
"."
] | 50f99ab46c4a475678b94af07c2ea02e1ba353ff | https://github.com/Blizzard/node-rdkafka/blob/50f99ab46c4a475678b94af07c2ea02e1ba353ff/lib/producer-stream.js#L39-L89 | train |
Blizzard/node-rdkafka | lib/admin.js | createAdminClient | function createAdminClient(conf) {
var client = new AdminClient(conf);
// Wrap the error so we throw if it failed with some context
LibrdKafkaError.wrap(client.connect(), true);
// Return the client if we succeeded
return client;
} | javascript | function createAdminClient(conf) {
var client = new AdminClient(conf);
// Wrap the error so we throw if it failed with some context
LibrdKafkaError.wrap(client.connect(), true);
// Return the client if we succeeded
return client;
} | [
"function",
"createAdminClient",
"(",
"conf",
")",
"{",
"var",
"client",
"=",
"new",
"AdminClient",
"(",
"conf",
")",
";",
"// Wrap the error so we throw if it failed with some context",
"LibrdKafkaError",
".",
"wrap",
"(",
"client",
".",
"connect",
"(",
")",
",",
... | Create a new AdminClient for making topics, partitions, and more.
This is a factory method because it immediately starts an
active handle with the brokers. | [
"Create",
"a",
"new",
"AdminClient",
"for",
"making",
"topics",
"partitions",
"and",
"more",
"."
] | 50f99ab46c4a475678b94af07c2ea02e1ba353ff | https://github.com/Blizzard/node-rdkafka/blob/50f99ab46c4a475678b94af07c2ea02e1ba353ff/lib/admin.js#L28-L36 | train |
Blizzard/node-rdkafka | lib/admin.js | AdminClient | function AdminClient(conf) {
if (!(this instanceof AdminClient)) {
return new AdminClient(conf);
}
conf = shallowCopy(conf);
/**
* NewTopic model.
*
* This is the representation of a new message that is requested to be made
* using the Admin client.
*
* @typedef {object} AdminClient~NewT... | javascript | function AdminClient(conf) {
if (!(this instanceof AdminClient)) {
return new AdminClient(conf);
}
conf = shallowCopy(conf);
/**
* NewTopic model.
*
* This is the representation of a new message that is requested to be made
* using the Admin client.
*
* @typedef {object} AdminClient~NewT... | [
"function",
"AdminClient",
"(",
"conf",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"AdminClient",
")",
")",
"{",
"return",
"new",
"AdminClient",
"(",
"conf",
")",
";",
"}",
"conf",
"=",
"shallowCopy",
"(",
"conf",
")",
";",
"/**\n * NewTopic ... | AdminClient class for administering Kafka
This client is the way you can interface with the Kafka Admin APIs.
This class should not be made using the constructor, but instead
should be made using the factory method.
<code>
var client = AdminClient.create({ ... });
</code>
Once you instantiate this object, it will ha... | [
"AdminClient",
"class",
"for",
"administering",
"Kafka"
] | 50f99ab46c4a475678b94af07c2ea02e1ba353ff | https://github.com/Blizzard/node-rdkafka/blob/50f99ab46c4a475678b94af07c2ea02e1ba353ff/lib/admin.js#L58-L82 | train |
nhn/tui.grid | src/js/view/clipboard.js | function(ev) {
var gridEvent;
if (this.isLocked) {
ev.preventDefault();
return;
}
gridEvent = keyEvent.generate(ev);
if (!gridEvent) {
return;
}
this._lock();
if (shouldPreventDefault(gridEvent)) {
ev.p... | javascript | function(ev) {
var gridEvent;
if (this.isLocked) {
ev.preventDefault();
return;
}
gridEvent = keyEvent.generate(ev);
if (!gridEvent) {
return;
}
this._lock();
if (shouldPreventDefault(gridEvent)) {
ev.p... | [
"function",
"(",
"ev",
")",
"{",
"var",
"gridEvent",
";",
"if",
"(",
"this",
".",
"isLocked",
")",
"{",
"ev",
".",
"preventDefault",
"(",
")",
";",
"return",
";",
"}",
"gridEvent",
"=",
"keyEvent",
".",
"generate",
"(",
"ev",
")",
";",
"if",
"(",
... | Event handler for the keydown event
@param {Event} ev - Event
@private | [
"Event",
"handler",
"for",
"the",
"keydown",
"event"
] | 9f66e339485e505bb85490c03a6a2db8dd599e0a | https://github.com/nhn/tui.grid/blob/9f66e339485e505bb85490c03a6a2db8dd599e0a/src/js/view/clipboard.js#L104-L128 | train | |
nhn/tui.grid | src/js/view/clipboard.js | function(ev) {
var clipboardData = (ev.originalEvent || ev).clipboardData || window.clipboardData;
if (!isEdge && !supportWindowClipboardData) {
ev.preventDefault();
this._pasteInOtherBrowsers(clipboardData);
} else {
this._pasteInMSBrowsers(clipboardData);
... | javascript | function(ev) {
var clipboardData = (ev.originalEvent || ev).clipboardData || window.clipboardData;
if (!isEdge && !supportWindowClipboardData) {
ev.preventDefault();
this._pasteInOtherBrowsers(clipboardData);
} else {
this._pasteInMSBrowsers(clipboardData);
... | [
"function",
"(",
"ev",
")",
"{",
"var",
"clipboardData",
"=",
"(",
"ev",
".",
"originalEvent",
"||",
"ev",
")",
".",
"clipboardData",
"||",
"window",
".",
"clipboardData",
";",
"if",
"(",
"!",
"isEdge",
"&&",
"!",
"supportWindowClipboardData",
")",
"{",
... | onpaste event handler
The original 'paste' event should be prevented on browsers except MS
to block that copied data is appending on contenteditable element.
@param {jQueryEvent} ev - Event object
@private | [
"onpaste",
"event",
"handler",
"The",
"original",
"paste",
"event",
"should",
"be",
"prevented",
"on",
"browsers",
"except",
"MS",
"to",
"block",
"that",
"copied",
"data",
"is",
"appending",
"on",
"contenteditable",
"element",
"."
] | 9f66e339485e505bb85490c03a6a2db8dd599e0a | https://github.com/nhn/tui.grid/blob/9f66e339485e505bb85490c03a6a2db8dd599e0a/src/js/view/clipboard.js#L159-L168 | train | |
nhn/tui.grid | src/js/common/i18n.js | flattenMessageMap | function flattenMessageMap(data) {
var obj = {};
var newKey;
_.each(data, function(groupMessages, key) {
_.each(groupMessages, function(message, subKey) {
newKey = [key, subKey].join('.');
obj[newKey] = message;
});
}, this);
return obj;
} | javascript | function flattenMessageMap(data) {
var obj = {};
var newKey;
_.each(data, function(groupMessages, key) {
_.each(groupMessages, function(message, subKey) {
newKey = [key, subKey].join('.');
obj[newKey] = message;
});
}, this);
return obj;
} | [
"function",
"flattenMessageMap",
"(",
"data",
")",
"{",
"var",
"obj",
"=",
"{",
"}",
";",
"var",
"newKey",
";",
"_",
".",
"each",
"(",
"data",
",",
"function",
"(",
"groupMessages",
",",
"key",
")",
"{",
"_",
".",
"each",
"(",
"groupMessages",
",",
... | Flatten message map
@param {object} data - Messages
@returns {object} Flatten message object (key foramt is 'key.subKey')
@ignore | [
"Flatten",
"message",
"map"
] | 9f66e339485e505bb85490c03a6a2db8dd599e0a | https://github.com/nhn/tui.grid/blob/9f66e339485e505bb85490c03a6a2db8dd599e0a/src/js/common/i18n.js#L60-L72 | 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.