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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
josdejong/mathjs | src/utils/array.js | _unsqueeze | function _unsqueeze (array, dims, dim) {
let i, ii
if (Array.isArray(array)) {
const next = dim + 1
for (i = 0, ii = array.length; i < ii; i++) {
array[i] = _unsqueeze(array[i], dims, next)
}
} else {
for (let d = dim; d < dims; d++) {
array = [array]
}
}
return array
} | javascript | function _unsqueeze (array, dims, dim) {
let i, ii
if (Array.isArray(array)) {
const next = dim + 1
for (i = 0, ii = array.length; i < ii; i++) {
array[i] = _unsqueeze(array[i], dims, next)
}
} else {
for (let d = dim; d < dims; d++) {
array = [array]
}
}
return array
} | [
"function",
"_unsqueeze",
"(",
"array",
",",
"dims",
",",
"dim",
")",
"{",
"let",
"i",
",",
"ii",
"if",
"(",
"Array",
".",
"isArray",
"(",
"array",
")",
")",
"{",
"const",
"next",
"=",
"dim",
"+",
"1",
"for",
"(",
"i",
"=",
"0",
",",
"ii",
"=... | Recursively unsqueeze a multi dimensional array
@param {Array} array
@param {number} dims Required number of dimensions
@param {number} dim Current dimension
@returns {Array | *} Returns the squeezed array
@private | [
"Recursively",
"unsqueeze",
"a",
"multi",
"dimensional",
"array"
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/src/utils/array.js#L374-L389 | train |
josdejong/mathjs | src/utils/customs.js | getSafeProperty | function getSafeProperty (object, prop) {
// only allow getting safe properties of a plain object
if (isPlainObject(object) && isSafeProperty(object, prop)) {
return object[prop]
}
if (typeof object[prop] === 'function' && isSafeMethod(object, prop)) {
throw new Error('Cannot access method "' + prop + ... | javascript | function getSafeProperty (object, prop) {
// only allow getting safe properties of a plain object
if (isPlainObject(object) && isSafeProperty(object, prop)) {
return object[prop]
}
if (typeof object[prop] === 'function' && isSafeMethod(object, prop)) {
throw new Error('Cannot access method "' + prop + ... | [
"function",
"getSafeProperty",
"(",
"object",
",",
"prop",
")",
"{",
"// only allow getting safe properties of a plain object",
"if",
"(",
"isPlainObject",
"(",
"object",
")",
"&&",
"isSafeProperty",
"(",
"object",
",",
"prop",
")",
")",
"{",
"return",
"object",
"... | Get a property of a plain object
Throws an error in case the object is not a plain object or the
property is not defined on the object itself
@param {Object} object
@param {string} prop
@return {*} Returns the property value when safe | [
"Get",
"a",
"property",
"of",
"a",
"plain",
"object",
"Throws",
"an",
"error",
"in",
"case",
"the",
"object",
"is",
"not",
"a",
"plain",
"object",
"or",
"the",
"property",
"is",
"not",
"defined",
"on",
"the",
"object",
"itself"
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/src/utils/customs.js#L13-L24 | train |
josdejong/mathjs | src/utils/customs.js | setSafeProperty | function setSafeProperty (object, prop, value) {
// only allow setting safe properties of a plain object
if (isPlainObject(object) && isSafeProperty(object, prop)) {
object[prop] = value
return value
}
throw new Error('No access to property "' + prop + '"')
} | javascript | function setSafeProperty (object, prop, value) {
// only allow setting safe properties of a plain object
if (isPlainObject(object) && isSafeProperty(object, prop)) {
object[prop] = value
return value
}
throw new Error('No access to property "' + prop + '"')
} | [
"function",
"setSafeProperty",
"(",
"object",
",",
"prop",
",",
"value",
")",
"{",
"// only allow setting safe properties of a plain object",
"if",
"(",
"isPlainObject",
"(",
"object",
")",
"&&",
"isSafeProperty",
"(",
"object",
",",
"prop",
")",
")",
"{",
"object... | Set a property on a plain object.
Throws an error in case the object is not a plain object or the
property would override an inherited property like .constructor or .toString
@param {Object} object
@param {string} prop
@param {*} value
@return {*} Returns the value
TODO: merge this function into access.js? | [
"Set",
"a",
"property",
"on",
"a",
"plain",
"object",
".",
"Throws",
"an",
"error",
"in",
"case",
"the",
"object",
"is",
"not",
"a",
"plain",
"object",
"or",
"the",
"property",
"would",
"override",
"an",
"inherited",
"property",
"like",
".",
"constructor",... | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/src/utils/customs.js#L36-L44 | train |
josdejong/mathjs | src/utils/customs.js | isSafeProperty | function isSafeProperty (object, prop) {
if (!object || typeof object !== 'object') {
return false
}
// SAFE: whitelisted
// e.g length
if (hasOwnProperty(safeNativeProperties, prop)) {
return true
}
// UNSAFE: inherited from Object prototype
// e.g constructor
if (prop in Object.prototype) {
... | javascript | function isSafeProperty (object, prop) {
if (!object || typeof object !== 'object') {
return false
}
// SAFE: whitelisted
// e.g length
if (hasOwnProperty(safeNativeProperties, prop)) {
return true
}
// UNSAFE: inherited from Object prototype
// e.g constructor
if (prop in Object.prototype) {
... | [
"function",
"isSafeProperty",
"(",
"object",
",",
"prop",
")",
"{",
"if",
"(",
"!",
"object",
"||",
"typeof",
"object",
"!==",
"'object'",
")",
"{",
"return",
"false",
"}",
"// SAFE: whitelisted",
"// e.g length",
"if",
"(",
"hasOwnProperty",
"(",
"safeNativeP... | Test whether a property is safe to use for an object.
For example .toString and .constructor are not safe
@param {string} prop
@return {boolean} Returns true when safe | [
"Test",
"whether",
"a",
"property",
"is",
"safe",
"to",
"use",
"for",
"an",
"object",
".",
"For",
"example",
".",
"toString",
"and",
".",
"constructor",
"are",
"not",
"safe"
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/src/utils/customs.js#L52-L78 | train |
josdejong/mathjs | src/function/string/print.js | _print | function _print (template, values, options) {
return template.replace(/\$([\w.]+)/g, function (original, key) {
const keys = key.split('.')
let value = values[keys.shift()]
while (keys.length && value !== undefined) {
const k = keys.shift()
value = k ? value[k] : value + '.'
}
if (val... | javascript | function _print (template, values, options) {
return template.replace(/\$([\w.]+)/g, function (original, key) {
const keys = key.split('.')
let value = values[keys.shift()]
while (keys.length && value !== undefined) {
const k = keys.shift()
value = k ? value[k] : value + '.'
}
if (val... | [
"function",
"_print",
"(",
"template",
",",
"values",
",",
"options",
")",
"{",
"return",
"template",
".",
"replace",
"(",
"/",
"\\$([\\w.]+)",
"/",
"g",
",",
"function",
"(",
"original",
",",
"key",
")",
"{",
"const",
"keys",
"=",
"key",
".",
"split",... | Interpolate values into a string template.
@param {string} template
@param {Object} values
@param {number | Object} [options]
@returns {string} Interpolated string
@private | [
"Interpolate",
"values",
"into",
"a",
"string",
"template",
"."
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/src/function/string/print.js#L70-L90 | train |
josdejong/mathjs | bin/cli.js | format | function format (value) {
const math = getMath()
return math.format(value, {
fn: function (value) {
if (typeof value === 'number') {
// round numbers
return math.format(value, PRECISION)
} else {
return math.format(value)
}
}
})
} | javascript | function format (value) {
const math = getMath()
return math.format(value, {
fn: function (value) {
if (typeof value === 'number') {
// round numbers
return math.format(value, PRECISION)
} else {
return math.format(value)
}
}
})
} | [
"function",
"format",
"(",
"value",
")",
"{",
"const",
"math",
"=",
"getMath",
"(",
")",
"return",
"math",
".",
"format",
"(",
"value",
",",
"{",
"fn",
":",
"function",
"(",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"===",
"'number'",
")",
"... | Helper function to format a value. Regular numbers will be rounded
to 14 digits to prevent round-off errors from showing up.
@param {*} value | [
"Helper",
"function",
"to",
"format",
"a",
"value",
".",
"Regular",
"numbers",
"will",
"be",
"rounded",
"to",
"14",
"digits",
"to",
"prevent",
"round",
"-",
"off",
"errors",
"from",
"showing",
"up",
"."
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/bin/cli.js#L69-L82 | train |
josdejong/mathjs | bin/cli.js | completer | function completer (text) {
const math = getMath()
let matches = []
let keyword
const m = /[a-zA-Z_0-9]+$/.exec(text)
if (m) {
keyword = m[0]
// scope variables
for (const def in scope) {
if (scope.hasOwnProperty(def)) {
if (def.indexOf(keyword) === 0) {
matches.push(def)
... | javascript | function completer (text) {
const math = getMath()
let matches = []
let keyword
const m = /[a-zA-Z_0-9]+$/.exec(text)
if (m) {
keyword = m[0]
// scope variables
for (const def in scope) {
if (scope.hasOwnProperty(def)) {
if (def.indexOf(keyword) === 0) {
matches.push(def)
... | [
"function",
"completer",
"(",
"text",
")",
"{",
"const",
"math",
"=",
"getMath",
"(",
")",
"let",
"matches",
"=",
"[",
"]",
"let",
"keyword",
"const",
"m",
"=",
"/",
"[a-zA-Z_0-9]+$",
"/",
".",
"exec",
"(",
"text",
")",
"if",
"(",
"m",
")",
"{",
... | auto complete a text
@param {String} text
@return {[Array, String]} completions | [
"auto",
"complete",
"a",
"text"
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/bin/cli.js#L89-L162 | train |
josdejong/mathjs | bin/cli.js | runStream | function runStream (input, output, mode, parenthesis) {
const readline = require('readline')
const rl = readline.createInterface({
input: input || process.stdin,
output: output || process.stdout,
completer: completer
})
if (rl.output.isTTY) {
rl.setPrompt('> ')
rl.prompt()
}
// load ma... | javascript | function runStream (input, output, mode, parenthesis) {
const readline = require('readline')
const rl = readline.createInterface({
input: input || process.stdin,
output: output || process.stdout,
completer: completer
})
if (rl.output.isTTY) {
rl.setPrompt('> ')
rl.prompt()
}
// load ma... | [
"function",
"runStream",
"(",
"input",
",",
"output",
",",
"mode",
",",
"parenthesis",
")",
"{",
"const",
"readline",
"=",
"require",
"(",
"'readline'",
")",
"const",
"rl",
"=",
"readline",
".",
"createInterface",
"(",
"{",
"input",
":",
"input",
"||",
"... | Run stream, read and evaluate input and stream that to output.
Text lines read from the input are evaluated, and the results are send to
the output.
@param input Input stream
@param output Output stream
@param mode Output mode
@param parenthesis Parenthesis option | [
"Run",
"stream",
"read",
"and",
"evaluate",
"input",
"and",
"stream",
"that",
"to",
"output",
".",
"Text",
"lines",
"read",
"from",
"the",
"input",
"are",
"evaluated",
"and",
"the",
"results",
"are",
"send",
"to",
"the",
"output",
"."
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/bin/cli.js#L173-L282 | train |
josdejong/mathjs | bin/cli.js | findSymbolName | function findSymbolName (node) {
const math = getMath()
let n = node
while (n) {
if (math.isSymbolNode(n)) {
return n.name
}
n = n.object
}
return null
} | javascript | function findSymbolName (node) {
const math = getMath()
let n = node
while (n) {
if (math.isSymbolNode(n)) {
return n.name
}
n = n.object
}
return null
} | [
"function",
"findSymbolName",
"(",
"node",
")",
"{",
"const",
"math",
"=",
"getMath",
"(",
")",
"let",
"n",
"=",
"node",
"while",
"(",
"n",
")",
"{",
"if",
"(",
"math",
".",
"isSymbolNode",
"(",
"n",
")",
")",
"{",
"return",
"n",
".",
"name",
"}"... | Find the symbol name of an AssignmentNode. Recurses into the chain of
objects to the root object.
@param {AssignmentNode} node
@return {string | null} Returns the name when found, else returns null. | [
"Find",
"the",
"symbol",
"name",
"of",
"an",
"AssignmentNode",
".",
"Recurses",
"into",
"the",
"chain",
"of",
"objects",
"to",
"the",
"root",
"object",
"."
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/bin/cli.js#L290-L302 | train |
josdejong/mathjs | bin/cli.js | outputVersion | function outputVersion () {
fs.readFile(path.join(__dirname, '/../package.json'), function (err, data) {
if (err) {
console.log(err.toString())
} else {
const pkg = JSON.parse(data)
const version = pkg && pkg.version ? pkg.version : 'unknown'
console.log(version)
}
process.exit... | javascript | function outputVersion () {
fs.readFile(path.join(__dirname, '/../package.json'), function (err, data) {
if (err) {
console.log(err.toString())
} else {
const pkg = JSON.parse(data)
const version = pkg && pkg.version ? pkg.version : 'unknown'
console.log(version)
}
process.exit... | [
"function",
"outputVersion",
"(",
")",
"{",
"fs",
".",
"readFile",
"(",
"path",
".",
"join",
"(",
"__dirname",
",",
"'/../package.json'",
")",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",... | Output application version number.
Version number is read version from package.json. | [
"Output",
"application",
"version",
"number",
".",
"Version",
"number",
"is",
"read",
"version",
"from",
"package",
".",
"json",
"."
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/bin/cli.js#L308-L319 | train |
josdejong/mathjs | bin/cli.js | outputHelp | function outputHelp () {
console.log('math.js')
console.log('https://mathjs.org')
console.log()
console.log('Math.js is an extensive math library for JavaScript and Node.js. It features ')
console.log('real and complex numbers, units, matrices, a large set of mathematical')
console.log('functions, and a fle... | javascript | function outputHelp () {
console.log('math.js')
console.log('https://mathjs.org')
console.log()
console.log('Math.js is an extensive math library for JavaScript and Node.js. It features ')
console.log('real and complex numbers, units, matrices, a large set of mathematical')
console.log('functions, and a fle... | [
"function",
"outputHelp",
"(",
")",
"{",
"console",
".",
"log",
"(",
"'math.js'",
")",
"console",
".",
"log",
"(",
"'https://mathjs.org'",
")",
"console",
".",
"log",
"(",
")",
"console",
".",
"log",
"(",
"'Math.js is an extensive math library for JavaScript and N... | Output a help message | [
"Output",
"a",
"help",
"message"
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/bin/cli.js#L324-L353 | train |
josdejong/mathjs | src/function/relational/compareNatural.js | compareArrays | function compareArrays (x, y) {
// compare each value
for (let i = 0, ii = Math.min(x.length, y.length); i < ii; i++) {
const v = compareNatural(x[i], y[i])
if (v !== 0) {
return v
}
}
// compare the size of the arrays
if (x.length > y.length) { return 1 }
if (x.length... | javascript | function compareArrays (x, y) {
// compare each value
for (let i = 0, ii = Math.min(x.length, y.length); i < ii; i++) {
const v = compareNatural(x[i], y[i])
if (v !== 0) {
return v
}
}
// compare the size of the arrays
if (x.length > y.length) { return 1 }
if (x.length... | [
"function",
"compareArrays",
"(",
"x",
",",
"y",
")",
"{",
"// compare each value",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"ii",
"=",
"Math",
".",
"min",
"(",
"x",
".",
"length",
",",
"y",
".",
"length",
")",
";",
"i",
"<",
"ii",
";",
"i",
"++"... | Compare two Arrays
- First, compares value by value
- Next, if all corresponding values are equal,
look at the length: longest array will be considered largest
@param {Array} x
@param {Array} y
@returns {number} Returns the comparison result: -1, 0, or 1 | [
"Compare",
"two",
"Arrays"
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/src/function/relational/compareNatural.js#L206-L221 | train |
josdejong/mathjs | src/function/relational/compareNatural.js | compareObjects | function compareObjects (x, y) {
const keysX = Object.keys(x)
const keysY = Object.keys(y)
// compare keys
keysX.sort(naturalSort)
keysY.sort(naturalSort)
const c = compareArrays(keysX, keysY)
if (c !== 0) {
return c
}
// compare values
for (let i = 0; i < keysX.length; i... | javascript | function compareObjects (x, y) {
const keysX = Object.keys(x)
const keysY = Object.keys(y)
// compare keys
keysX.sort(naturalSort)
keysY.sort(naturalSort)
const c = compareArrays(keysX, keysY)
if (c !== 0) {
return c
}
// compare values
for (let i = 0; i < keysX.length; i... | [
"function",
"compareObjects",
"(",
"x",
",",
"y",
")",
"{",
"const",
"keysX",
"=",
"Object",
".",
"keys",
"(",
"x",
")",
"const",
"keysY",
"=",
"Object",
".",
"keys",
"(",
"y",
")",
"// compare keys",
"keysX",
".",
"sort",
"(",
"naturalSort",
")",
"k... | Compare two objects
- First, compare sorted property names
- Next, compare the property values
@param {Object} x
@param {Object} y
@returns {number} Returns the comparison result: -1, 0, or 1 | [
"Compare",
"two",
"objects"
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/src/function/relational/compareNatural.js#L233-L254 | train |
josdejong/mathjs | tools/docgenerator.js | validateDoc | function validateDoc (doc) {
let issues = []
function ignore (field) {
return IGNORE_WARNINGS[field].indexOf(doc.name) !== -1
}
if (!doc.name) {
issues.push('name missing in document')
}
if (!doc.description) {
issues.push('function "' + doc.name + '": description missing')
}
if (!doc.sy... | javascript | function validateDoc (doc) {
let issues = []
function ignore (field) {
return IGNORE_WARNINGS[field].indexOf(doc.name) !== -1
}
if (!doc.name) {
issues.push('name missing in document')
}
if (!doc.description) {
issues.push('function "' + doc.name + '": description missing')
}
if (!doc.sy... | [
"function",
"validateDoc",
"(",
"doc",
")",
"{",
"let",
"issues",
"=",
"[",
"]",
"function",
"ignore",
"(",
"field",
")",
"{",
"return",
"IGNORE_WARNINGS",
"[",
"field",
"]",
".",
"indexOf",
"(",
"doc",
".",
"name",
")",
"!==",
"-",
"1",
"}",
"if",
... | Validate whether all required fields are available in given doc
@param {Object} doc
@return {String[]} issues | [
"Validate",
"whether",
"all",
"required",
"fields",
"are",
"available",
"in",
"given",
"doc"
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/tools/docgenerator.js#L333-L394 | train |
josdejong/mathjs | tools/docgenerator.js | functionEntry | function functionEntry (name) {
const fn = functions[name]
let syntax = SYNTAX[name] || (fn.doc && fn.doc.syntax && fn.doc.syntax[0]) || name
syntax = syntax
// .replace(/^math\./, '')
.replace(/\s+\/\/.*$/, '')
.replace(/;$/, '')
if (syntax.length < 40) {
syntax ... | javascript | function functionEntry (name) {
const fn = functions[name]
let syntax = SYNTAX[name] || (fn.doc && fn.doc.syntax && fn.doc.syntax[0]) || name
syntax = syntax
// .replace(/^math\./, '')
.replace(/\s+\/\/.*$/, '')
.replace(/;$/, '')
if (syntax.length < 40) {
syntax ... | [
"function",
"functionEntry",
"(",
"name",
")",
"{",
"const",
"fn",
"=",
"functions",
"[",
"name",
"]",
"let",
"syntax",
"=",
"SYNTAX",
"[",
"name",
"]",
"||",
"(",
"fn",
".",
"doc",
"&&",
"fn",
".",
"doc",
".",
"syntax",
"&&",
"fn",
".",
"doc",
"... | Helper function to generate a markdown list entry for a function.
Used to generate both alphabetical and categorical index pages.
@param {string} name Function name
@returns {string} Returns a markdown list entry | [
"Helper",
"function",
"to",
"generate",
"a",
"markdown",
"list",
"entry",
"for",
"a",
"function",
".",
"Used",
"to",
"generate",
"both",
"alphabetical",
"and",
"categorical",
"index",
"pages",
"."
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/tools/docgenerator.js#L548-L565 | train |
josdejong/mathjs | examples/advanced/custom_argument_parsing.js | integrate | function integrate (f, start, end, step) {
let total = 0
step = step || 0.01
for (let x = start; x < end; x += step) {
total += f(x + step / 2) * step
}
return total
} | javascript | function integrate (f, start, end, step) {
let total = 0
step = step || 0.01
for (let x = start; x < end; x += step) {
total += f(x + step / 2) * step
}
return total
} | [
"function",
"integrate",
"(",
"f",
",",
"start",
",",
"end",
",",
"step",
")",
"{",
"let",
"total",
"=",
"0",
"step",
"=",
"step",
"||",
"0.01",
"for",
"(",
"let",
"x",
"=",
"start",
";",
"x",
"<",
"end",
";",
"x",
"+=",
"step",
")",
"{",
"to... | Calculate the numeric integration of a function
@param {Function} f
@param {number} start
@param {number} end
@param {number} [step=0.01] | [
"Calculate",
"the",
"numeric",
"integration",
"of",
"a",
"function"
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/examples/advanced/custom_argument_parsing.js#L20-L27 | train |
josdejong/mathjs | src/expression/transform/map.transform.js | mapTransform | function mapTransform (args, math, scope) {
let x, callback
if (args[0]) {
x = args[0].compile().evaluate(scope)
}
if (args[1]) {
if (isSymbolNode(args[1]) || isFunctionAssignmentNode(args[1])) {
// a function pointer, like filter([3, -2, 5], myTestFunction)
callback = args... | javascript | function mapTransform (args, math, scope) {
let x, callback
if (args[0]) {
x = args[0].compile().evaluate(scope)
}
if (args[1]) {
if (isSymbolNode(args[1]) || isFunctionAssignmentNode(args[1])) {
// a function pointer, like filter([3, -2, 5], myTestFunction)
callback = args... | [
"function",
"mapTransform",
"(",
"args",
",",
"math",
",",
"scope",
")",
"{",
"let",
"x",
",",
"callback",
"if",
"(",
"args",
"[",
"0",
"]",
")",
"{",
"x",
"=",
"args",
"[",
"0",
"]",
".",
"compile",
"(",
")",
".",
"evaluate",
"(",
"scope",
")"... | Attach a transform function to math.map
Adds a property transform containing the transform function.
This transform creates a one-based index instead of a zero-based index | [
"Attach",
"a",
"transform",
"function",
"to",
"math",
".",
"map",
"Adds",
"a",
"property",
"transform",
"containing",
"the",
"transform",
"function",
"."
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/src/expression/transform/map.transform.js#L19-L37 | train |
josdejong/mathjs | src/utils/snapshot.js | exclude | function exclude (object, excludedProperties) {
const strippedObject = Object.assign({}, object)
excludedProperties.forEach(excludedProperty => {
delete strippedObject[excludedProperty]
})
return strippedObject
} | javascript | function exclude (object, excludedProperties) {
const strippedObject = Object.assign({}, object)
excludedProperties.forEach(excludedProperty => {
delete strippedObject[excludedProperty]
})
return strippedObject
} | [
"function",
"exclude",
"(",
"object",
",",
"excludedProperties",
")",
"{",
"const",
"strippedObject",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"object",
")",
"excludedProperties",
".",
"forEach",
"(",
"excludedProperty",
"=>",
"{",
"delete",
"stripped... | Create a copy of the provided `object` and delete
all properties listed in `excludedProperties`
@param {Object} object
@param {string[]} excludedProperties
@return {Object} | [
"Create",
"a",
"copy",
"of",
"the",
"provided",
"object",
"and",
"delete",
"all",
"properties",
"listed",
"in",
"excludedProperties"
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/src/utils/snapshot.js#L352-L360 | train |
josdejong/mathjs | src/function/matrix/subset.js | _getSubstring | function _getSubstring (str, index) {
if (!isIndex(index)) {
// TODO: better error message
throw new TypeError('Index expected')
}
if (index.size().length !== 1) {
throw new DimensionError(index.size().length, 1)
}
// validate whether the range is out of range
const strLen = str.length
valida... | javascript | function _getSubstring (str, index) {
if (!isIndex(index)) {
// TODO: better error message
throw new TypeError('Index expected')
}
if (index.size().length !== 1) {
throw new DimensionError(index.size().length, 1)
}
// validate whether the range is out of range
const strLen = str.length
valida... | [
"function",
"_getSubstring",
"(",
"str",
",",
"index",
")",
"{",
"if",
"(",
"!",
"isIndex",
"(",
"index",
")",
")",
"{",
"// TODO: better error message",
"throw",
"new",
"TypeError",
"(",
"'Index expected'",
")",
"}",
"if",
"(",
"index",
".",
"size",
"(",
... | Retrieve a subset of a string
@param {string} str string from which to get a substring
@param {Index} index An index containing ranges for each dimension
@returns {string} substring
@private | [
"Retrieve",
"a",
"subset",
"of",
"a",
"string"
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/src/function/matrix/subset.js#L100-L122 | train |
josdejong/mathjs | src/function/matrix/subset.js | _setSubstring | function _setSubstring (str, index, replacement, defaultValue) {
if (!index || index.isIndex !== true) {
// TODO: better error message
throw new TypeError('Index expected')
}
if (index.size().length !== 1) {
throw new DimensionError(index.size().length, 1)
}
if (defaultValue !== undefined) {
i... | javascript | function _setSubstring (str, index, replacement, defaultValue) {
if (!index || index.isIndex !== true) {
// TODO: better error message
throw new TypeError('Index expected')
}
if (index.size().length !== 1) {
throw new DimensionError(index.size().length, 1)
}
if (defaultValue !== undefined) {
i... | [
"function",
"_setSubstring",
"(",
"str",
",",
"index",
",",
"replacement",
",",
"defaultValue",
")",
"{",
"if",
"(",
"!",
"index",
"||",
"index",
".",
"isIndex",
"!==",
"true",
")",
"{",
"// TODO: better error message",
"throw",
"new",
"TypeError",
"(",
"'In... | Replace a substring in a string
@param {string} str string to be replaced
@param {Index} index An index containing ranges for each dimension
@param {string} replacement Replacement string
@param {string} [defaultValue] Default value to be uses when resizing
the string. is ' ' by default
@returns... | [
"Replace",
"a",
"substring",
"in",
"a",
"string"
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/src/function/matrix/subset.js#L134-L182 | train |
josdejong/mathjs | src/function/matrix/subset.js | _getObjectProperty | function _getObjectProperty (object, index) {
if (index.size().length !== 1) {
throw new DimensionError(index.size(), 1)
}
const key = index.dimension(0)
if (typeof key !== 'string') {
throw new TypeError('String expected as index to retrieve an object property')
}
return getSafeProperty(object, k... | javascript | function _getObjectProperty (object, index) {
if (index.size().length !== 1) {
throw new DimensionError(index.size(), 1)
}
const key = index.dimension(0)
if (typeof key !== 'string') {
throw new TypeError('String expected as index to retrieve an object property')
}
return getSafeProperty(object, k... | [
"function",
"_getObjectProperty",
"(",
"object",
",",
"index",
")",
"{",
"if",
"(",
"index",
".",
"size",
"(",
")",
".",
"length",
"!==",
"1",
")",
"{",
"throw",
"new",
"DimensionError",
"(",
"index",
".",
"size",
"(",
")",
",",
"1",
")",
"}",
"con... | Retrieve a property from an object
@param {Object} object
@param {Index} index
@return {*} Returns the value of the property
@private | [
"Retrieve",
"a",
"property",
"from",
"an",
"object"
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/src/function/matrix/subset.js#L191-L202 | train |
josdejong/mathjs | src/function/matrix/subset.js | _setObjectProperty | function _setObjectProperty (object, index, replacement) {
if (index.size().length !== 1) {
throw new DimensionError(index.size(), 1)
}
const key = index.dimension(0)
if (typeof key !== 'string') {
throw new TypeError('String expected as index to retrieve an object property')
}
// clone the object... | javascript | function _setObjectProperty (object, index, replacement) {
if (index.size().length !== 1) {
throw new DimensionError(index.size(), 1)
}
const key = index.dimension(0)
if (typeof key !== 'string') {
throw new TypeError('String expected as index to retrieve an object property')
}
// clone the object... | [
"function",
"_setObjectProperty",
"(",
"object",
",",
"index",
",",
"replacement",
")",
"{",
"if",
"(",
"index",
".",
"size",
"(",
")",
".",
"length",
"!==",
"1",
")",
"{",
"throw",
"new",
"DimensionError",
"(",
"index",
".",
"size",
"(",
")",
",",
"... | Set a property on an object
@param {Object} object
@param {Index} index
@param {*} replacement
@return {*} Returns the updated object
@private | [
"Set",
"a",
"property",
"on",
"an",
"object"
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/src/function/matrix/subset.js#L212-L227 | train |
josdejong/mathjs | src/function/matrix/apply.js | _switch | function _switch (mat) {
const I = mat.length
const J = mat[0].length
let i, j
const ret = []
for (j = 0; j < J; j++) {
const tmp = []
for (i = 0; i < I; i++) {
tmp.push(mat[i][j])
}
ret.push(tmp)
}
return ret
} | javascript | function _switch (mat) {
const I = mat.length
const J = mat[0].length
let i, j
const ret = []
for (j = 0; j < J; j++) {
const tmp = []
for (i = 0; i < I; i++) {
tmp.push(mat[i][j])
}
ret.push(tmp)
}
return ret
} | [
"function",
"_switch",
"(",
"mat",
")",
"{",
"const",
"I",
"=",
"mat",
".",
"length",
"const",
"J",
"=",
"mat",
"[",
"0",
"]",
".",
"length",
"let",
"i",
",",
"j",
"const",
"ret",
"=",
"[",
"]",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"J"... | Transpose a matrix
@param {Array} mat
@returns {Array} ret
@private | [
"Transpose",
"a",
"matrix"
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/src/function/matrix/apply.js#L105-L118 | train |
josdejong/mathjs | src/function/matrix/concat.js | _concat | function _concat (a, b, concatDim, dim) {
if (dim < concatDim) {
// recurse into next dimension
if (a.length !== b.length) {
throw new DimensionError(a.length, b.length)
}
const c = []
for (let i = 0; i < a.length; i++) {
c[i] = _concat(a[i], b[i], concatDim, dim + 1)
}
return... | javascript | function _concat (a, b, concatDim, dim) {
if (dim < concatDim) {
// recurse into next dimension
if (a.length !== b.length) {
throw new DimensionError(a.length, b.length)
}
const c = []
for (let i = 0; i < a.length; i++) {
c[i] = _concat(a[i], b[i], concatDim, dim + 1)
}
return... | [
"function",
"_concat",
"(",
"a",
",",
"b",
",",
"concatDim",
",",
"dim",
")",
"{",
"if",
"(",
"dim",
"<",
"concatDim",
")",
"{",
"// recurse into next dimension",
"if",
"(",
"a",
".",
"length",
"!==",
"b",
".",
"length",
")",
"{",
"throw",
"new",
"Di... | Recursively concatenate two matrices.
The contents of the matrices is not cloned.
@param {Array} a Multi dimensional array
@param {Array} b Multi dimensional array
@param {number} concatDim The dimension on which to concatenate (zero-based)
@param {number} dim The current dim (zero-b... | [
"Recursively",
"concatenate",
"two",
"matrices",
".",
"The",
"contents",
"of",
"the",
"matrices",
"is",
"not",
"cloned",
"."
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/src/function/matrix/concat.js#L121-L137 | train |
josdejong/mathjs | src/expression/transform/filter.transform.js | filterTransform | function filterTransform (args, math, scope) {
let x, callback
if (args[0]) {
x = args[0].compile().evaluate(scope)
}
if (args[1]) {
if (isSymbolNode(args[1]) || isFunctionAssignmentNode(args[1])) {
// a function pointer, like filter([3, -2, 5], myTestFunction)
callback = a... | javascript | function filterTransform (args, math, scope) {
let x, callback
if (args[0]) {
x = args[0].compile().evaluate(scope)
}
if (args[1]) {
if (isSymbolNode(args[1]) || isFunctionAssignmentNode(args[1])) {
// a function pointer, like filter([3, -2, 5], myTestFunction)
callback = a... | [
"function",
"filterTransform",
"(",
"args",
",",
"math",
",",
"scope",
")",
"{",
"let",
"x",
",",
"callback",
"if",
"(",
"args",
"[",
"0",
"]",
")",
"{",
"x",
"=",
"args",
"[",
"0",
"]",
".",
"compile",
"(",
")",
".",
"evaluate",
"(",
"scope",
... | Attach a transform function to math.filter
Adds a property transform containing the transform function.
This transform adds support for equations as test function for math.filter,
so you can do something like 'filter([3, -2, 5], x > 0)'. | [
"Attach",
"a",
"transform",
"function",
"to",
"math",
".",
"filter",
"Adds",
"a",
"property",
"transform",
"containing",
"the",
"transform",
"function",
"."
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/src/expression/transform/filter.transform.js#L20-L38 | train |
josdejong/mathjs | src/expression/transform/filter.transform.js | _filter | function _filter (x, callback) {
// figure out what number of arguments the callback function expects
const args = maxArgumentCount(callback)
return filter(x, function (value, index, array) {
// invoke the callback function with the right number of arguments
if (args === 1) {
return callback(value)... | javascript | function _filter (x, callback) {
// figure out what number of arguments the callback function expects
const args = maxArgumentCount(callback)
return filter(x, function (value, index, array) {
// invoke the callback function with the right number of arguments
if (args === 1) {
return callback(value)... | [
"function",
"_filter",
"(",
"x",
",",
"callback",
")",
"{",
"// figure out what number of arguments the callback function expects",
"const",
"args",
"=",
"maxArgumentCount",
"(",
"callback",
")",
"return",
"filter",
"(",
"x",
",",
"function",
"(",
"value",
",",
"ind... | Filter values in a callback given a callback function
!!! Passes a one-based index !!!
@param {Array} x
@param {Function} callback
@return {Array} Returns the filtered array
@private | [
"Filter",
"values",
"in",
"a",
"callback",
"given",
"a",
"callback",
"function"
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/src/expression/transform/filter.transform.js#L69-L83 | train |
josdejong/mathjs | src/function/arithmetic/subtract.js | checkEqualDimensions | function checkEqualDimensions (x, y) {
const xsize = x.size()
const ysize = y.size()
if (xsize.length !== ysize.length) {
throw new DimensionError(xsize.length, ysize.length)
}
} | javascript | function checkEqualDimensions (x, y) {
const xsize = x.size()
const ysize = y.size()
if (xsize.length !== ysize.length) {
throw new DimensionError(xsize.length, ysize.length)
}
} | [
"function",
"checkEqualDimensions",
"(",
"x",
",",
"y",
")",
"{",
"const",
"xsize",
"=",
"x",
".",
"size",
"(",
")",
"const",
"ysize",
"=",
"y",
".",
"size",
"(",
")",
"if",
"(",
"xsize",
".",
"length",
"!==",
"ysize",
".",
"length",
")",
"{",
"t... | Check whether matrix x and y have the same number of dimensions.
Throws a DimensionError when dimensions are not equal
@param {Matrix} x
@param {Matrix} y | [
"Check",
"whether",
"matrix",
"x",
"and",
"y",
"have",
"the",
"same",
"number",
"of",
"dimensions",
".",
"Throws",
"a",
"DimensionError",
"when",
"dimensions",
"are",
"not",
"equal"
] | dd830a8892a5c78907a0f2a616df46c90ddd693e | https://github.com/josdejong/mathjs/blob/dd830a8892a5c78907a0f2a616df46c90ddd693e/src/function/arithmetic/subtract.js#L174-L181 | train |
datorama/akita | schematics/src/ng-g/utils/string.js | camelize | function camelize(str) {
return str
.replace(STRING_CAMELIZE_REGEXP, (_match, _separator, chr) => {
return chr ? chr.toUpperCase() : '';
})
.replace(/^([A-Z])/, (match) => match.toLowerCase());
} | javascript | function camelize(str) {
return str
.replace(STRING_CAMELIZE_REGEXP, (_match, _separator, chr) => {
return chr ? chr.toUpperCase() : '';
})
.replace(/^([A-Z])/, (match) => match.toLowerCase());
} | [
"function",
"camelize",
"(",
"str",
")",
"{",
"return",
"str",
".",
"replace",
"(",
"STRING_CAMELIZE_REGEXP",
",",
"(",
"_match",
",",
"_separator",
",",
"chr",
")",
"=>",
"{",
"return",
"chr",
"?",
"chr",
".",
"toUpperCase",
"(",
")",
":",
"''",
";",
... | Returns the lowerCamelCase form of a string.
```javascript
camelize('innerHTML'); // 'innerHTML'
camelize('action_name'); // 'actionName'
camelize('css-class-name'); // 'cssClassName'
camelize('my favorite items'); // 'myFavoriteItems'
camelize('My Favorite Items'); // 'myFavoriteItems'
``` | [
"Returns",
"the",
"lowerCamelCase",
"form",
"of",
"a",
"string",
"."
] | fe86f506402b6c511f91245e6b4076c368f653f1 | https://github.com/datorama/akita/blob/fe86f506402b6c511f91245e6b4076c368f653f1/schematics/src/ng-g/utils/string.js#L55-L61 | train |
datorama/akita | schematics/src/ng-g/utils/pluralize.js | interpolate | function interpolate(str, args) {
return str.replace(/\$(\d{1,2})/g, function (match, index) {
return args[index] || '';
});
} | javascript | function interpolate(str, args) {
return str.replace(/\$(\d{1,2})/g, function (match, index) {
return args[index] || '';
});
} | [
"function",
"interpolate",
"(",
"str",
",",
"args",
")",
"{",
"return",
"str",
".",
"replace",
"(",
"/",
"\\$(\\d{1,2})",
"/",
"g",
",",
"function",
"(",
"match",
",",
"index",
")",
"{",
"return",
"args",
"[",
"index",
"]",
"||",
"''",
";",
"}",
")... | Interpolate a regexp string.
@param {string} str
@param {Array} args
@return {string} | [
"Interpolate",
"a",
"regexp",
"string",
"."
] | fe86f506402b6c511f91245e6b4076c368f653f1 | https://github.com/datorama/akita/blob/fe86f506402b6c511f91245e6b4076c368f653f1/schematics/src/ng-g/utils/pluralize.js#L66-L70 | train |
datorama/akita | schematics/src/ng-g/utils/pluralize.js | replaceWord | function replaceWord(replaceMap, keepMap, rules) {
return function (word) {
// Get the correct token and case restoration functions.
var token = word.toLowerCase();
// Check against the keep object map.
if (keepMap.hasOwnProperty(token)) {
return r... | javascript | function replaceWord(replaceMap, keepMap, rules) {
return function (word) {
// Get the correct token and case restoration functions.
var token = word.toLowerCase();
// Check against the keep object map.
if (keepMap.hasOwnProperty(token)) {
return r... | [
"function",
"replaceWord",
"(",
"replaceMap",
",",
"keepMap",
",",
"rules",
")",
"{",
"return",
"function",
"(",
"word",
")",
"{",
"// Get the correct token and case restoration functions.",
"var",
"token",
"=",
"word",
".",
"toLowerCase",
"(",
")",
";",
"// Check... | Replace a word with the updated word.
@param {Object} replaceMap
@param {Object} keepMap
@param {Array} rules
@return {Function} | [
"Replace",
"a",
"word",
"with",
"the",
"updated",
"word",
"."
] | fe86f506402b6c511f91245e6b4076c368f653f1 | https://github.com/datorama/akita/blob/fe86f506402b6c511f91245e6b4076c368f653f1/schematics/src/ng-g/utils/pluralize.js#L117-L132 | train |
datorama/akita | schematics/src/ng-g/utils/pluralize.js | pluralize | function pluralize(word, count, inclusive) {
var pluralized = count === 1
? pluralize.singular(word) : pluralize.plural(word);
return (inclusive ? count + ' ' : '') + pluralized;
} | javascript | function pluralize(word, count, inclusive) {
var pluralized = count === 1
? pluralize.singular(word) : pluralize.plural(word);
return (inclusive ? count + ' ' : '') + pluralized;
} | [
"function",
"pluralize",
"(",
"word",
",",
"count",
",",
"inclusive",
")",
"{",
"var",
"pluralized",
"=",
"count",
"===",
"1",
"?",
"pluralize",
".",
"singular",
"(",
"word",
")",
":",
"pluralize",
".",
"plural",
"(",
"word",
")",
";",
"return",
"(",
... | Pluralize or singularize a word based on the passed in count.
@param {string} word
@param {number} count
@param {boolean} inclusive
@return {string} | [
"Pluralize",
"or",
"singularize",
"a",
"word",
"based",
"on",
"the",
"passed",
"in",
"count",
"."
] | fe86f506402b6c511f91245e6b4076c368f653f1 | https://github.com/datorama/akita/blob/fe86f506402b6c511f91245e6b4076c368f653f1/schematics/src/ng-g/utils/pluralize.js#L154-L158 | train |
datorama/akita | schematics/src/ng-add/utils.js | findNodes | function findNodes(node, kind, max = Infinity) {
if (!node || max == 0) {
return [];
}
const arr = [];
if (node.kind === kind) {
arr.push(node);
max--;
}
if (max > 0) {
for (const child of node.getChildren()) {
findNodes(child, kind, max).forEach(node ... | javascript | function findNodes(node, kind, max = Infinity) {
if (!node || max == 0) {
return [];
}
const arr = [];
if (node.kind === kind) {
arr.push(node);
max--;
}
if (max > 0) {
for (const child of node.getChildren()) {
findNodes(child, kind, max).forEach(node ... | [
"function",
"findNodes",
"(",
"node",
",",
"kind",
",",
"max",
"=",
"Infinity",
")",
"{",
"if",
"(",
"!",
"node",
"||",
"max",
"==",
"0",
")",
"{",
"return",
"[",
"]",
";",
"}",
"const",
"arr",
"=",
"[",
"]",
";",
"if",
"(",
"node",
".",
"kin... | Find all nodes from the AST in the subtree of node of SyntaxKind kind.
@param node
@param kind
@param max The maximum number of items to return.
@return all nodes of kind, or [] if none is found | [
"Find",
"all",
"nodes",
"from",
"the",
"AST",
"in",
"the",
"subtree",
"of",
"node",
"of",
"SyntaxKind",
"kind",
"."
] | fe86f506402b6c511f91245e6b4076c368f653f1 | https://github.com/datorama/akita/blob/fe86f506402b6c511f91245e6b4076c368f653f1/schematics/src/ng-add/utils.js#L153-L176 | train |
datorama/akita | schematics/src/ng-add/utils.js | getSourceNodes | function getSourceNodes(sourceFile) {
const nodes = [sourceFile];
const result = [];
while (nodes.length > 0) {
const node = nodes.shift();
if (node) {
result.push(node);
if (node.getChildCount(sourceFile) >= 0) {
nodes.unshift(...node.getChildren());
... | javascript | function getSourceNodes(sourceFile) {
const nodes = [sourceFile];
const result = [];
while (nodes.length > 0) {
const node = nodes.shift();
if (node) {
result.push(node);
if (node.getChildCount(sourceFile) >= 0) {
nodes.unshift(...node.getChildren());
... | [
"function",
"getSourceNodes",
"(",
"sourceFile",
")",
"{",
"const",
"nodes",
"=",
"[",
"sourceFile",
"]",
";",
"const",
"result",
"=",
"[",
"]",
";",
"while",
"(",
"nodes",
".",
"length",
">",
"0",
")",
"{",
"const",
"node",
"=",
"nodes",
".",
"shift... | Get all the nodes from a source.
@param sourceFile The source file object.
@returns {Observable<ts.Node>} An observable of all the nodes in the source. | [
"Get",
"all",
"the",
"nodes",
"from",
"a",
"source",
"."
] | fe86f506402b6c511f91245e6b4076c368f653f1 | https://github.com/datorama/akita/blob/fe86f506402b6c511f91245e6b4076c368f653f1/schematics/src/ng-add/utils.js#L183-L196 | train |
datorama/akita | schematics/src/ng-add/utils.js | addImportToModule | function addImportToModule(source, modulePath, classifiedName, importPath) {
return addSymbolToNgModuleMetadata(source, modulePath, 'imports', classifiedName, importPath);
} | javascript | function addImportToModule(source, modulePath, classifiedName, importPath) {
return addSymbolToNgModuleMetadata(source, modulePath, 'imports', classifiedName, importPath);
} | [
"function",
"addImportToModule",
"(",
"source",
",",
"modulePath",
",",
"classifiedName",
",",
"importPath",
")",
"{",
"return",
"addSymbolToNgModuleMetadata",
"(",
"source",
",",
"modulePath",
",",
"'imports'",
",",
"classifiedName",
",",
"importPath",
")",
";",
... | Custom function to insert an NgModule into NgModule imports. It also imports the module. | [
"Custom",
"function",
"to",
"insert",
"an",
"NgModule",
"into",
"NgModule",
"imports",
".",
"It",
"also",
"imports",
"the",
"module",
"."
] | fe86f506402b6c511f91245e6b4076c368f653f1 | https://github.com/datorama/akita/blob/fe86f506402b6c511f91245e6b4076c368f653f1/schematics/src/ng-add/utils.js#L501-L503 | train |
datorama/akita | schematics/src/ng-add/utils.js | addProviderToModule | function addProviderToModule(source, modulePath, classifiedName, importPath) {
return addSymbolToNgModuleMetadata(source, modulePath, 'providers', classifiedName, importPath);
} | javascript | function addProviderToModule(source, modulePath, classifiedName, importPath) {
return addSymbolToNgModuleMetadata(source, modulePath, 'providers', classifiedName, importPath);
} | [
"function",
"addProviderToModule",
"(",
"source",
",",
"modulePath",
",",
"classifiedName",
",",
"importPath",
")",
"{",
"return",
"addSymbolToNgModuleMetadata",
"(",
"source",
",",
"modulePath",
",",
"'providers'",
",",
"classifiedName",
",",
"importPath",
")",
";"... | Custom function to insert a provider into NgModule. It also imports it. | [
"Custom",
"function",
"to",
"insert",
"a",
"provider",
"into",
"NgModule",
".",
"It",
"also",
"imports",
"it",
"."
] | fe86f506402b6c511f91245e6b4076c368f653f1 | https://github.com/datorama/akita/blob/fe86f506402b6c511f91245e6b4076c368f653f1/schematics/src/ng-add/utils.js#L508-L510 | train |
datorama/akita | schematics/src/ng-add/utils.js | addEntryComponentToModule | function addEntryComponentToModule(source, modulePath, classifiedName, importPath) {
return addSymbolToNgModuleMetadata(source, modulePath, 'entryComponents', classifiedName, importPath);
} | javascript | function addEntryComponentToModule(source, modulePath, classifiedName, importPath) {
return addSymbolToNgModuleMetadata(source, modulePath, 'entryComponents', classifiedName, importPath);
} | [
"function",
"addEntryComponentToModule",
"(",
"source",
",",
"modulePath",
",",
"classifiedName",
",",
"importPath",
")",
"{",
"return",
"addSymbolToNgModuleMetadata",
"(",
"source",
",",
"modulePath",
",",
"'entryComponents'",
",",
"classifiedName",
",",
"importPath",
... | Custom function to insert an entryComponent into NgModule. It also imports it. | [
"Custom",
"function",
"to",
"insert",
"an",
"entryComponent",
"into",
"NgModule",
".",
"It",
"also",
"imports",
"it",
"."
] | fe86f506402b6c511f91245e6b4076c368f653f1 | https://github.com/datorama/akita/blob/fe86f506402b6c511f91245e6b4076c368f653f1/schematics/src/ng-add/utils.js#L529-L531 | train |
datorama/akita | schematics/src/ng-add/utils.js | isImported | function isImported(source, classifiedName, importPath) {
const allNodes = getSourceNodes(source);
const matchingNodes = allNodes
.filter(node => node.kind === ts.SyntaxKind.ImportDeclaration)
.filter((imp) => imp.moduleSpecifier.kind === ts.SyntaxKind.StringLiteral)
.filter((imp) => {
... | javascript | function isImported(source, classifiedName, importPath) {
const allNodes = getSourceNodes(source);
const matchingNodes = allNodes
.filter(node => node.kind === ts.SyntaxKind.ImportDeclaration)
.filter((imp) => imp.moduleSpecifier.kind === ts.SyntaxKind.StringLiteral)
.filter((imp) => {
... | [
"function",
"isImported",
"(",
"source",
",",
"classifiedName",
",",
"importPath",
")",
"{",
"const",
"allNodes",
"=",
"getSourceNodes",
"(",
"source",
")",
";",
"const",
"matchingNodes",
"=",
"allNodes",
".",
"filter",
"(",
"node",
"=>",
"node",
".",
"kind"... | Determine if an import already exists. | [
"Determine",
"if",
"an",
"import",
"already",
"exists",
"."
] | fe86f506402b6c511f91245e6b4076c368f653f1 | https://github.com/datorama/akita/blob/fe86f506402b6c511f91245e6b4076c368f653f1/schematics/src/ng-add/utils.js#L536-L552 | train |
fluent-ffmpeg/node-fluent-ffmpeg | lib/fluent-ffmpeg.js | FfmpegCommand | function FfmpegCommand(input, options) {
// Make 'new' optional
if (!(this instanceof FfmpegCommand)) {
return new FfmpegCommand(input, options);
}
EventEmitter.call(this);
if (typeof input === 'object' && !('readable' in input)) {
// Options object passed directly
options = input;
} else {
... | javascript | function FfmpegCommand(input, options) {
// Make 'new' optional
if (!(this instanceof FfmpegCommand)) {
return new FfmpegCommand(input, options);
}
EventEmitter.call(this);
if (typeof input === 'object' && !('readable' in input)) {
// Options object passed directly
options = input;
} else {
... | [
"function",
"FfmpegCommand",
"(",
"input",
",",
"options",
")",
"{",
"// Make 'new' optional",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"FfmpegCommand",
")",
")",
"{",
"return",
"new",
"FfmpegCommand",
"(",
"input",
",",
"options",
")",
";",
"}",
"EventEmi... | Create an ffmpeg command
Can be called with or without the 'new' operator, and the 'input' parameter
may be specified as 'options.source' instead (or passed later with the
addInput method).
@constructor
@param {String|ReadableStream} [input] input file path or readable stream
@param {Object} [options] command options... | [
"Create",
"an",
"ffmpeg",
"command"
] | bee107787dcdccd7e4749e062c2601c47870d776 | https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/bee107787dcdccd7e4749e062c2601c47870d776/lib/fluent-ffmpeg.js#L31-L79 | train |
fluent-ffmpeg/node-fluent-ffmpeg | lib/recipes.js | normalizeTimemarks | function normalizeTimemarks(next) {
config.timemarks = config.timemarks.map(function(mark) {
return utils.timemarkToSeconds(mark);
}).sort(function(a, b) { return a - b; });
next();
} | javascript | function normalizeTimemarks(next) {
config.timemarks = config.timemarks.map(function(mark) {
return utils.timemarkToSeconds(mark);
}).sort(function(a, b) { return a - b; });
next();
} | [
"function",
"normalizeTimemarks",
"(",
"next",
")",
"{",
"config",
".",
"timemarks",
"=",
"config",
".",
"timemarks",
".",
"map",
"(",
"function",
"(",
"mark",
")",
"{",
"return",
"utils",
".",
"timemarkToSeconds",
"(",
"mark",
")",
";",
"}",
")",
".",
... | Turn all timemarks into numbers and sort them | [
"Turn",
"all",
"timemarks",
"into",
"numbers",
"and",
"sort",
"them"
] | bee107787dcdccd7e4749e062c2601c47870d776 | https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/bee107787dcdccd7e4749e062c2601c47870d776/lib/recipes.js#L218-L224 | train |
fluent-ffmpeg/node-fluent-ffmpeg | lib/recipes.js | fixPattern | function fixPattern(next) {
var pattern = config.filename || 'tn.png';
if (pattern.indexOf('.') === -1) {
pattern += '.png';
}
if (config.timemarks.length > 1 && !pattern.match(/%(s|0*i)/)) {
var ext = path.extname(pattern);
pattern = path.join(path.dirnam... | javascript | function fixPattern(next) {
var pattern = config.filename || 'tn.png';
if (pattern.indexOf('.') === -1) {
pattern += '.png';
}
if (config.timemarks.length > 1 && !pattern.match(/%(s|0*i)/)) {
var ext = path.extname(pattern);
pattern = path.join(path.dirnam... | [
"function",
"fixPattern",
"(",
"next",
")",
"{",
"var",
"pattern",
"=",
"config",
".",
"filename",
"||",
"'tn.png'",
";",
"if",
"(",
"pattern",
".",
"indexOf",
"(",
"'.'",
")",
"===",
"-",
"1",
")",
"{",
"pattern",
"+=",
"'.png'",
";",
"}",
"if",
"... | Add '_%i' to pattern when requesting multiple screenshots and no variable token is present | [
"Add",
"_%i",
"to",
"pattern",
"when",
"requesting",
"multiple",
"screenshots",
"and",
"no",
"variable",
"token",
"is",
"present"
] | bee107787dcdccd7e4749e062c2601c47870d776 | https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/bee107787dcdccd7e4749e062c2601c47870d776/lib/recipes.js#L227-L240 | train |
fluent-ffmpeg/node-fluent-ffmpeg | lib/capabilities.js | function(ffprobe, cb) {
if (ffprobe.length) {
return cb(null, ffprobe);
}
self._getFfmpegPath(function(err, ffmpeg) {
if (err) {
cb(err);
} else if (ffmpeg.length) {
var name = utils.isWindows ? 'ffprobe.exe' : 'ffprobe';
var ffp... | javascript | function(ffprobe, cb) {
if (ffprobe.length) {
return cb(null, ffprobe);
}
self._getFfmpegPath(function(err, ffmpeg) {
if (err) {
cb(err);
} else if (ffmpeg.length) {
var name = utils.isWindows ? 'ffprobe.exe' : 'ffprobe';
var ffp... | [
"function",
"(",
"ffprobe",
",",
"cb",
")",
"{",
"if",
"(",
"ffprobe",
".",
"length",
")",
"{",
"return",
"cb",
"(",
"null",
",",
"ffprobe",
")",
";",
"}",
"self",
".",
"_getFfmpegPath",
"(",
"function",
"(",
"err",
",",
"ffmpeg",
")",
"{",
"if",
... | Search in the same directory as ffmpeg | [
"Search",
"in",
"the",
"same",
"directory",
"as",
"ffmpeg"
] | bee107787dcdccd7e4749e062c2601c47870d776 | https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/bee107787dcdccd7e4749e062c2601c47870d776/lib/capabilities.js#L171-L189 | train | |
fluent-ffmpeg/node-fluent-ffmpeg | lib/capabilities.js | function(flvtool, cb) {
if (flvtool.length) {
return cb(null, flvtool);
}
utils.which('flvmeta', function(err, flvmeta) {
cb(err, flvmeta);
});
} | javascript | function(flvtool, cb) {
if (flvtool.length) {
return cb(null, flvtool);
}
utils.which('flvmeta', function(err, flvmeta) {
cb(err, flvmeta);
});
} | [
"function",
"(",
"flvtool",
",",
"cb",
")",
"{",
"if",
"(",
"flvtool",
".",
"length",
")",
"{",
"return",
"cb",
"(",
"null",
",",
"flvtool",
")",
";",
"}",
"utils",
".",
"which",
"(",
"'flvmeta'",
",",
"function",
"(",
"err",
",",
"flvmeta",
")",
... | Search for flvmeta in the PATH | [
"Search",
"for",
"flvmeta",
"in",
"the",
"PATH"
] | bee107787dcdccd7e4749e062c2601c47870d776 | https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/bee107787dcdccd7e4749e062c2601c47870d776/lib/capabilities.js#L243-L251 | train | |
fluent-ffmpeg/node-fluent-ffmpeg | lib/capabilities.js | function(flvtool, cb) {
if (flvtool.length) {
return cb(null, flvtool);
}
utils.which('flvtool2', function(err, flvtool2) {
cb(err, flvtool2);
});
} | javascript | function(flvtool, cb) {
if (flvtool.length) {
return cb(null, flvtool);
}
utils.which('flvtool2', function(err, flvtool2) {
cb(err, flvtool2);
});
} | [
"function",
"(",
"flvtool",
",",
"cb",
")",
"{",
"if",
"(",
"flvtool",
".",
"length",
")",
"{",
"return",
"cb",
"(",
"null",
",",
"flvtool",
")",
";",
"}",
"utils",
".",
"which",
"(",
"'flvtool2'",
",",
"function",
"(",
"err",
",",
"flvtool2",
")",... | Search for flvtool2 in the PATH | [
"Search",
"for",
"flvtool2",
"in",
"the",
"PATH"
] | bee107787dcdccd7e4749e062c2601c47870d776 | https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/bee107787dcdccd7e4749e062c2601c47870d776/lib/capabilities.js#L254-L262 | train | |
fluent-ffmpeg/node-fluent-ffmpeg | lib/capabilities.js | function(formats, cb) {
var unavailable;
// Output format(s)
unavailable = self._outputs
.reduce(function(fmts, output) {
var format = output.options.find('-f', 1);
if (format) {
if (!(format[0] in formats) || !(formats[format[0]].canMux)) {
... | javascript | function(formats, cb) {
var unavailable;
// Output format(s)
unavailable = self._outputs
.reduce(function(fmts, output) {
var format = output.options.find('-f', 1);
if (format) {
if (!(format[0] in formats) || !(formats[format[0]].canMux)) {
... | [
"function",
"(",
"formats",
",",
"cb",
")",
"{",
"var",
"unavailable",
";",
"// Output format(s)",
"unavailable",
"=",
"self",
".",
"_outputs",
".",
"reduce",
"(",
"function",
"(",
"fmts",
",",
"output",
")",
"{",
"var",
"format",
"=",
"output",
".",
"op... | Check whether specified formats are available | [
"Check",
"whether",
"specified",
"formats",
"are",
"available"
] | bee107787dcdccd7e4749e062c2601c47870d776 | https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/bee107787dcdccd7e4749e062c2601c47870d776/lib/capabilities.js#L572-L614 | train | |
fluent-ffmpeg/node-fluent-ffmpeg | lib/capabilities.js | function(encoders, cb) {
var unavailable;
// Audio codec(s)
unavailable = self._outputs.reduce(function(cdcs, output) {
var acodec = output.audio.find('-acodec', 1);
if (acodec && acodec[0] !== 'copy') {
if (!(acodec[0] in encoders) || encoders[acodec[0]].type !=... | javascript | function(encoders, cb) {
var unavailable;
// Audio codec(s)
unavailable = self._outputs.reduce(function(cdcs, output) {
var acodec = output.audio.find('-acodec', 1);
if (acodec && acodec[0] !== 'copy') {
if (!(acodec[0] in encoders) || encoders[acodec[0]].type !=... | [
"function",
"(",
"encoders",
",",
"cb",
")",
"{",
"var",
"unavailable",
";",
"// Audio codec(s)",
"unavailable",
"=",
"self",
".",
"_outputs",
".",
"reduce",
"(",
"function",
"(",
"cdcs",
",",
"output",
")",
"{",
"var",
"acodec",
"=",
"output",
".",
"aud... | Check whether specified codecs are available and add strict experimental options if needed | [
"Check",
"whether",
"specified",
"codecs",
"are",
"available",
"and",
"add",
"strict",
"experimental",
"options",
"if",
"needed"
] | bee107787dcdccd7e4749e062c2601c47870d776 | https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/bee107787dcdccd7e4749e062c2601c47870d776/lib/capabilities.js#L622-L662 | train | |
fluent-ffmpeg/node-fluent-ffmpeg | lib/utils.js | parseProgressLine | function parseProgressLine(line) {
var progress = {};
// Remove all spaces after = and trim
line = line.replace(/=\s+/g, '=').trim();
var progressParts = line.split(' ');
// Split every progress part by "=" to get key and value
for(var i = 0; i < progressParts.length; i++) {
var progressSplit = progr... | javascript | function parseProgressLine(line) {
var progress = {};
// Remove all spaces after = and trim
line = line.replace(/=\s+/g, '=').trim();
var progressParts = line.split(' ');
// Split every progress part by "=" to get key and value
for(var i = 0; i < progressParts.length; i++) {
var progressSplit = progr... | [
"function",
"parseProgressLine",
"(",
"line",
")",
"{",
"var",
"progress",
"=",
"{",
"}",
";",
"// Remove all spaces after = and trim",
"line",
"=",
"line",
".",
"replace",
"(",
"/",
"=\\s+",
"/",
"g",
",",
"'='",
")",
".",
"trim",
"(",
")",
";",
"var",
... | Parse progress line from ffmpeg stderr
@param {String} line progress line
@return progress object
@private | [
"Parse",
"progress",
"line",
"from",
"ffmpeg",
"stderr"
] | bee107787dcdccd7e4749e062c2601c47870d776 | https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/bee107787dcdccd7e4749e062c2601c47870d776/lib/utils.js#L20-L41 | train |
fluent-ffmpeg/node-fluent-ffmpeg | lib/utils.js | function() {
var list = [];
// Append argument(s) to the list
var argfunc = function() {
if (arguments.length === 1 && Array.isArray(arguments[0])) {
list = list.concat(arguments[0]);
} else {
list = list.concat([].slice.call(arguments));
}
};
// Clear argument li... | javascript | function() {
var list = [];
// Append argument(s) to the list
var argfunc = function() {
if (arguments.length === 1 && Array.isArray(arguments[0])) {
list = list.concat(arguments[0]);
} else {
list = list.concat([].slice.call(arguments));
}
};
// Clear argument li... | [
"function",
"(",
")",
"{",
"var",
"list",
"=",
"[",
"]",
";",
"// Append argument(s) to the list",
"var",
"argfunc",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"===",
"1",
"&&",
"Array",
".",
"isArray",
"(",
"arguments",
"[",
... | Create an argument list
Returns a function that adds new arguments to the list.
It also has the following methods:
- clear() empties the argument list
- get() returns the argument list
- find(arg, count) finds 'arg' in the list and return the following 'count' items, or undefined if not found
- remove(arg, count) remo... | [
"Create",
"an",
"argument",
"list"
] | bee107787dcdccd7e4749e062c2601c47870d776 | https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/bee107787dcdccd7e4749e062c2601c47870d776/lib/utils.js#L75-L121 | train | |
fluent-ffmpeg/node-fluent-ffmpeg | lib/utils.js | function(filters) {
return filters.map(function(filterSpec) {
if (typeof filterSpec === 'string') {
return filterSpec;
}
var filterString = '';
// Filter string format is:
// [input1][input2]...filter[output1][output2]...
// The 'filter' part can optionaly have argument... | javascript | function(filters) {
return filters.map(function(filterSpec) {
if (typeof filterSpec === 'string') {
return filterSpec;
}
var filterString = '';
// Filter string format is:
// [input1][input2]...filter[output1][output2]...
// The 'filter' part can optionaly have argument... | [
"function",
"(",
"filters",
")",
"{",
"return",
"filters",
".",
"map",
"(",
"function",
"(",
"filterSpec",
")",
"{",
"if",
"(",
"typeof",
"filterSpec",
"===",
"'string'",
")",
"{",
"return",
"filterSpec",
";",
"}",
"var",
"filterString",
"=",
"''",
";",
... | Generate filter strings
@param {String[]|Object[]} filters filter specifications. When using objects,
each must have the following properties:
@param {String} filters.filter filter name
@param {String|Array} [filters.inputs] (array of) input stream specifier(s) for the filter,
defaults to ffmpeg automatically choosing... | [
"Generate",
"filter",
"strings"
] | bee107787dcdccd7e4749e062c2601c47870d776 | https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/bee107787dcdccd7e4749e062c2601c47870d776/lib/utils.js#L138-L203 | train | |
fluent-ffmpeg/node-fluent-ffmpeg | lib/utils.js | function(name, callback) {
if (name in whichCache) {
return callback(null, whichCache[name]);
}
which(name, function(err, result){
if (err) {
// Treat errors as not found
return callback(null, whichCache[name] = '');
}
callback(null, whichCache[name] = result);
}... | javascript | function(name, callback) {
if (name in whichCache) {
return callback(null, whichCache[name]);
}
which(name, function(err, result){
if (err) {
// Treat errors as not found
return callback(null, whichCache[name] = '');
}
callback(null, whichCache[name] = result);
}... | [
"function",
"(",
"name",
",",
"callback",
")",
"{",
"if",
"(",
"name",
"in",
"whichCache",
")",
"{",
"return",
"callback",
"(",
"null",
",",
"whichCache",
"[",
"name",
"]",
")",
";",
"}",
"which",
"(",
"name",
",",
"function",
"(",
"err",
",",
"res... | Search for an executable
Uses 'which' or 'where' depending on platform
@param {String} name executable name
@param {Function} callback callback with signature (err, path)
@private | [
"Search",
"for",
"an",
"executable"
] | bee107787dcdccd7e4749e062c2601c47870d776 | https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/bee107787dcdccd7e4749e062c2601c47870d776/lib/utils.js#L215-L227 | train | |
fluent-ffmpeg/node-fluent-ffmpeg | lib/utils.js | function(command, stderrLine, codecsObject) {
var inputPattern = /Input #[0-9]+, ([^ ]+),/;
var durPattern = /Duration\: ([^,]+)/;
var audioPattern = /Audio\: (.*)/;
var videoPattern = /Video\: (.*)/;
if (!('inputStack' in codecsObject)) {
codecsObject.inputStack = [];
codecsObject.inpu... | javascript | function(command, stderrLine, codecsObject) {
var inputPattern = /Input #[0-9]+, ([^ ]+),/;
var durPattern = /Duration\: ([^,]+)/;
var audioPattern = /Audio\: (.*)/;
var videoPattern = /Video\: (.*)/;
if (!('inputStack' in codecsObject)) {
codecsObject.inputStack = [];
codecsObject.inpu... | [
"function",
"(",
"command",
",",
"stderrLine",
",",
"codecsObject",
")",
"{",
"var",
"inputPattern",
"=",
"/",
"Input #[0-9]+, ([^ ]+),",
"/",
";",
"var",
"durPattern",
"=",
"/",
"Duration\\: ([^,]+)",
"/",
";",
"var",
"audioPattern",
"=",
"/",
"Audio\\: (.*)",
... | Extract codec data from ffmpeg stderr and emit 'codecData' event if appropriate
Call it with an initially empty codec object once with each line of stderr output until it returns true
@param {FfmpegCommand} command event emitter
@param {String} stderrLine ffmpeg stderr output line
@param {Object} codecObject object us... | [
"Extract",
"codec",
"data",
"from",
"ffmpeg",
"stderr",
"and",
"emit",
"codecData",
"event",
"if",
"appropriate",
"Call",
"it",
"with",
"an",
"initially",
"empty",
"codec",
"object",
"once",
"with",
"each",
"line",
"of",
"stderr",
"output",
"until",
"it",
"r... | bee107787dcdccd7e4749e062c2601c47870d776 | https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/bee107787dcdccd7e4749e062c2601c47870d776/lib/utils.js#L275-L316 | train | |
fluent-ffmpeg/node-fluent-ffmpeg | lib/utils.js | function(command, stderrLine) {
var progress = parseProgressLine(stderrLine);
if (progress) {
// build progress report object
var ret = {
frames: parseInt(progress.frame, 10),
currentFps: parseInt(progress.fps, 10),
currentKbps: progress.bitrate ? parseFloat(progress.bitrate... | javascript | function(command, stderrLine) {
var progress = parseProgressLine(stderrLine);
if (progress) {
// build progress report object
var ret = {
frames: parseInt(progress.frame, 10),
currentFps: parseInt(progress.fps, 10),
currentKbps: progress.bitrate ? parseFloat(progress.bitrate... | [
"function",
"(",
"command",
",",
"stderrLine",
")",
"{",
"var",
"progress",
"=",
"parseProgressLine",
"(",
"stderrLine",
")",
";",
"if",
"(",
"progress",
")",
"{",
"// build progress report object",
"var",
"ret",
"=",
"{",
"frames",
":",
"parseInt",
"(",
"pr... | Extract progress data from ffmpeg stderr and emit 'progress' event if appropriate
@param {FfmpegCommand} command event emitter
@param {String} stderrLine ffmpeg stderr data
@private | [
"Extract",
"progress",
"data",
"from",
"ffmpeg",
"stderr",
"and",
"emit",
"progress",
"event",
"if",
"appropriate"
] | bee107787dcdccd7e4749e062c2601c47870d776 | https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/bee107787dcdccd7e4749e062c2601c47870d776/lib/utils.js#L326-L347 | train | |
fluent-ffmpeg/node-fluent-ffmpeg | lib/options/videosize.js | createSizeFilters | function createSizeFilters(output, key, value) {
// Store parameters
var data = output.sizeData = output.sizeData || {};
data[key] = value;
if (!('size' in data)) {
// No size requested, keep original size
return [];
}
// Try to match the different size string formats
var fixedSize = data.size.m... | javascript | function createSizeFilters(output, key, value) {
// Store parameters
var data = output.sizeData = output.sizeData || {};
data[key] = value;
if (!('size' in data)) {
// No size requested, keep original size
return [];
}
// Try to match the different size string formats
var fixedSize = data.size.m... | [
"function",
"createSizeFilters",
"(",
"output",
",",
"key",
",",
"value",
")",
"{",
"// Store parameters",
"var",
"data",
"=",
"output",
".",
"sizeData",
"=",
"output",
".",
"sizeData",
"||",
"{",
"}",
";",
"data",
"[",
"key",
"]",
"=",
"value",
";",
"... | Recompute size filters
@param {Object} output
@param {String} key newly-added parameter name ('size', 'aspect' or 'pad')
@param {String} value newly-added parameter value
@return filter string array
@private | [
"Recompute",
"size",
"filters"
] | bee107787dcdccd7e4749e062c2601c47870d776 | https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/bee107787dcdccd7e4749e062c2601c47870d776/lib/options/videosize.js#L68-L147 | train |
fluent-ffmpeg/node-fluent-ffmpeg | lib/processor.js | function(cb) {
if (!readMetadata) {
return cb();
}
self.ffprobe(0, function(err, data) {
if (!err) {
self._ffprobeData = data;
}
cb();
});
} | javascript | function(cb) {
if (!readMetadata) {
return cb();
}
self.ffprobe(0, function(err, data) {
if (!err) {
self._ffprobeData = data;
}
cb();
});
} | [
"function",
"(",
"cb",
")",
"{",
"if",
"(",
"!",
"readMetadata",
")",
"{",
"return",
"cb",
"(",
")",
";",
"}",
"self",
".",
"ffprobe",
"(",
"0",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"!",
"err",
")",
"{",
"self",
".",... | Read metadata if required | [
"Read",
"metadata",
"if",
"required"
] | bee107787dcdccd7e4749e062c2601c47870d776 | https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/bee107787dcdccd7e4749e062c2601c47870d776/lib/processor.js#L302-L314 | train | |
fluent-ffmpeg/node-fluent-ffmpeg | lib/processor.js | function(cb) {
var args;
try {
args = self._getArguments();
} catch(e) {
return cb(e);
}
cb(null, args);
} | javascript | function(cb) {
var args;
try {
args = self._getArguments();
} catch(e) {
return cb(e);
}
cb(null, args);
} | [
"function",
"(",
"cb",
")",
"{",
"var",
"args",
";",
"try",
"{",
"args",
"=",
"self",
".",
"_getArguments",
"(",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"return",
"cb",
"(",
"e",
")",
";",
"}",
"cb",
"(",
"null",
",",
"args",
")",
";",
... | Build argument list | [
"Build",
"argument",
"list"
] | bee107787dcdccd7e4749e062c2601c47870d776 | https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/bee107787dcdccd7e4749e062c2601c47870d776/lib/processor.js#L338-L347 | train | |
fluent-ffmpeg/node-fluent-ffmpeg | lib/processor.js | function(args, cb) {
self.availableEncoders(function(err, encoders) {
for (var i = 0; i < args.length; i++) {
if (args[i] === '-acodec' || args[i] === '-vcodec') {
i++;
if ((args[i] in encoders) && encoders[args[i]].experimental) {
args.splice(i... | javascript | function(args, cb) {
self.availableEncoders(function(err, encoders) {
for (var i = 0; i < args.length; i++) {
if (args[i] === '-acodec' || args[i] === '-vcodec') {
i++;
if ((args[i] in encoders) && encoders[args[i]].experimental) {
args.splice(i... | [
"function",
"(",
"args",
",",
"cb",
")",
"{",
"self",
".",
"availableEncoders",
"(",
"function",
"(",
"err",
",",
"encoders",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",... | Add "-strict experimental" option where needed | [
"Add",
"-",
"strict",
"experimental",
"option",
"where",
"needed"
] | bee107787dcdccd7e4749e062c2601c47870d776 | https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/bee107787dcdccd7e4749e062c2601c47870d776/lib/processor.js#L350-L365 | train | |
mrvautin/adminMongo | monitoring.js | serverMonitoringCleanup | function serverMonitoringCleanup(db, conn){
var exclude = {
eventDate: 0,
pid: 0,
version: 0,
uptime: 0,
network: 0,
connectionName: 0,
connections: 0,
memory: 0,
dataRetrieved: 0,
docCounts: 0
};
var retainedRecords = (24 * 60... | javascript | function serverMonitoringCleanup(db, conn){
var exclude = {
eventDate: 0,
pid: 0,
version: 0,
uptime: 0,
network: 0,
connectionName: 0,
connections: 0,
memory: 0,
dataRetrieved: 0,
docCounts: 0
};
var retainedRecords = (24 * 60... | [
"function",
"serverMonitoringCleanup",
"(",
"db",
",",
"conn",
")",
"{",
"var",
"exclude",
"=",
"{",
"eventDate",
":",
"0",
",",
"pid",
":",
"0",
",",
"version",
":",
"0",
",",
"uptime",
":",
"0",
",",
"network",
":",
"0",
",",
"connectionName",
":",... | Removes old monitoring data. We only want basic monitoring with the last 100 events. We keep last 80 and remove the rest to be sure. | [
"Removes",
"old",
"monitoring",
"data",
".",
"We",
"only",
"want",
"basic",
"monitoring",
"with",
"the",
"last",
"100",
"events",
".",
"We",
"keep",
"last",
"80",
"and",
"remove",
"the",
"rest",
"to",
"be",
"sure",
"."
] | edcef9d12f22298e0ef4e509f88f06ea8967647c | https://github.com/mrvautin/adminMongo/blob/edcef9d12f22298e0ef4e509f88f06ea8967647c/monitoring.js#L5-L29 | train |
adobe-webplatform/Snap.svg | demos/animated-game/js/backbone.js | function(name, callback, context) {
if (!eventsApi(this, 'once', name, [callback, context]) || !callback) return this;
var self = this;
var once = _.once(function() {
self.off(name, once);
callback.apply(this, arguments);
});
once._callback = callback;
return this.on(... | javascript | function(name, callback, context) {
if (!eventsApi(this, 'once', name, [callback, context]) || !callback) return this;
var self = this;
var once = _.once(function() {
self.off(name, once);
callback.apply(this, arguments);
});
once._callback = callback;
return this.on(... | [
"function",
"(",
"name",
",",
"callback",
",",
"context",
")",
"{",
"if",
"(",
"!",
"eventsApi",
"(",
"this",
",",
"'once'",
",",
"name",
",",
"[",
"callback",
",",
"context",
"]",
")",
"||",
"!",
"callback",
")",
"return",
"this",
";",
"var",
"sel... | Bind an event to only be triggered a single time. After the first time the callback is invoked, it will be removed. | [
"Bind",
"an",
"event",
"to",
"only",
"be",
"triggered",
"a",
"single",
"time",
".",
"After",
"the",
"first",
"time",
"the",
"callback",
"is",
"invoked",
"it",
"will",
"be",
"removed",
"."
] | b242f49e6798ac297a3dad0dfb03c0893e394464 | https://github.com/adobe-webplatform/Snap.svg/blob/b242f49e6798ac297a3dad0dfb03c0893e394464/demos/animated-game/js/backbone.js#L90-L99 | train | |
adobe-webplatform/Snap.svg | demos/animated-game/js/backbone.js | function(options) {
options = options ? _.clone(options) : {};
if (options.parse === void 0) options.parse = true;
var model = this;
var success = options.success;
options.success = function(resp) {
if (!model.set(model.parse(resp, options), options)) return false;
if (succ... | javascript | function(options) {
options = options ? _.clone(options) : {};
if (options.parse === void 0) options.parse = true;
var model = this;
var success = options.success;
options.success = function(resp) {
if (!model.set(model.parse(resp, options), options)) return false;
if (succ... | [
"function",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"?",
"_",
".",
"clone",
"(",
"options",
")",
":",
"{",
"}",
";",
"if",
"(",
"options",
".",
"parse",
"===",
"void",
"0",
")",
"options",
".",
"parse",
"=",
"true",
";",
"var",
"mode... | Fetch the model from the server. If the server's representation of the model differs from its current attributes, they will be overridden, triggering a `"change"` event. | [
"Fetch",
"the",
"model",
"from",
"the",
"server",
".",
"If",
"the",
"server",
"s",
"representation",
"of",
"the",
"model",
"differs",
"from",
"its",
"current",
"attributes",
"they",
"will",
"be",
"overridden",
"triggering",
"a",
"change",
"event",
"."
] | b242f49e6798ac297a3dad0dfb03c0893e394464 | https://github.com/adobe-webplatform/Snap.svg/blob/b242f49e6798ac297a3dad0dfb03c0893e394464/demos/animated-game/js/backbone.js#L429-L441 | train | |
adobe-webplatform/Snap.svg | demos/animated-game/js/backbone.js | function(model, options) {
model = this._prepareModel(model, options);
this.add(model, _.extend({at: 0}, options));
return model;
} | javascript | function(model, options) {
model = this._prepareModel(model, options);
this.add(model, _.extend({at: 0}, options));
return model;
} | [
"function",
"(",
"model",
",",
"options",
")",
"{",
"model",
"=",
"this",
".",
"_prepareModel",
"(",
"model",
",",
"options",
")",
";",
"this",
".",
"add",
"(",
"model",
",",
"_",
".",
"extend",
"(",
"{",
"at",
":",
"0",
"}",
",",
"options",
")",... | Add a model to the beginning of the collection. | [
"Add",
"a",
"model",
"to",
"the",
"beginning",
"of",
"the",
"collection",
"."
] | b242f49e6798ac297a3dad0dfb03c0893e394464 | https://github.com/adobe-webplatform/Snap.svg/blob/b242f49e6798ac297a3dad0dfb03c0893e394464/demos/animated-game/js/backbone.js#L763-L767 | train | |
adobe-webplatform/Snap.svg | demos/animated-game/js/backbone.js | function(model, value, context) {
value || (value = this.comparator);
var iterator = _.isFunction(value) ? value : function(model) {
return model.get(value);
};
return _.sortedIndex(this.models, model, iterator, context);
} | javascript | function(model, value, context) {
value || (value = this.comparator);
var iterator = _.isFunction(value) ? value : function(model) {
return model.get(value);
};
return _.sortedIndex(this.models, model, iterator, context);
} | [
"function",
"(",
"model",
",",
"value",
",",
"context",
")",
"{",
"value",
"||",
"(",
"value",
"=",
"this",
".",
"comparator",
")",
";",
"var",
"iterator",
"=",
"_",
".",
"isFunction",
"(",
"value",
")",
"?",
"value",
":",
"function",
"(",
"model",
... | Figure out the smallest index at which a model should be inserted so as to maintain order. | [
"Figure",
"out",
"the",
"smallest",
"index",
"at",
"which",
"a",
"model",
"should",
"be",
"inserted",
"so",
"as",
"to",
"maintain",
"order",
"."
] | b242f49e6798ac297a3dad0dfb03c0893e394464 | https://github.com/adobe-webplatform/Snap.svg/blob/b242f49e6798ac297a3dad0dfb03c0893e394464/demos/animated-game/js/backbone.js#L830-L836 | train | |
adobe-webplatform/Snap.svg | demos/animated-game/js/backbone.js | function() {
if (!this.routes) return;
this.routes = _.result(this, 'routes');
var route, routes = _.keys(this.routes);
while ((route = routes.pop()) != null) {
this.route(route, this.routes[route]);
}
} | javascript | function() {
if (!this.routes) return;
this.routes = _.result(this, 'routes');
var route, routes = _.keys(this.routes);
while ((route = routes.pop()) != null) {
this.route(route, this.routes[route]);
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"routes",
")",
"return",
";",
"this",
".",
"routes",
"=",
"_",
".",
"result",
"(",
"this",
",",
"'routes'",
")",
";",
"var",
"route",
",",
"routes",
"=",
"_",
".",
"keys",
"(",
"this",
"."... | Bind all defined routes to `Backbone.history`. We have to reverse the order of the routes here to support behavior where the most general routes can be defined at the bottom of the route map. | [
"Bind",
"all",
"defined",
"routes",
"to",
"Backbone",
".",
"history",
".",
"We",
"have",
"to",
"reverse",
"the",
"order",
"of",
"the",
"routes",
"here",
"to",
"support",
"behavior",
"where",
"the",
"most",
"general",
"routes",
"can",
"be",
"defined",
"at",... | b242f49e6798ac297a3dad0dfb03c0893e394464 | https://github.com/adobe-webplatform/Snap.svg/blob/b242f49e6798ac297a3dad0dfb03c0893e394464/demos/animated-game/js/backbone.js#L1262-L1269 | train | |
adobe-webplatform/Snap.svg | demos/animated-game/js/backbone.js | function(location, fragment, replace) {
if (replace) {
var href = location.href.replace(/(javascript:|#).*$/, '');
location.replace(href + '#' + fragment);
} else {
// Some browsers require that `hash` contains a leading #.
location.hash = '#' + fragment;
}
} | javascript | function(location, fragment, replace) {
if (replace) {
var href = location.href.replace(/(javascript:|#).*$/, '');
location.replace(href + '#' + fragment);
} else {
// Some browsers require that `hash` contains a leading #.
location.hash = '#' + fragment;
}
} | [
"function",
"(",
"location",
",",
"fragment",
",",
"replace",
")",
"{",
"if",
"(",
"replace",
")",
"{",
"var",
"href",
"=",
"location",
".",
"href",
".",
"replace",
"(",
"/",
"(javascript:|#).*$",
"/",
",",
"''",
")",
";",
"location",
".",
"replace",
... | Update the hash location, either replacing the current entry, or adding a new one to the browser history. | [
"Update",
"the",
"hash",
"location",
"either",
"replacing",
"the",
"current",
"entry",
"or",
"adding",
"a",
"new",
"one",
"to",
"the",
"browser",
"history",
"."
] | b242f49e6798ac297a3dad0dfb03c0893e394464 | https://github.com/adobe-webplatform/Snap.svg/blob/b242f49e6798ac297a3dad0dfb03c0893e394464/demos/animated-game/js/backbone.js#L1498-L1506 | train | |
t1m0n/air-datepicker | dist/js/datepicker.js | function (param, value) {
var len = arguments.length,
lastSelectedDate = this.lastSelectedDate;
if (len == 2) {
this.opts[param] = value;
} else if (len == 1 && typeof param == 'object') {
this.opts = $.extend(true, this.opts, param)
... | javascript | function (param, value) {
var len = arguments.length,
lastSelectedDate = this.lastSelectedDate;
if (len == 2) {
this.opts[param] = value;
} else if (len == 1 && typeof param == 'object') {
this.opts = $.extend(true, this.opts, param)
... | [
"function",
"(",
"param",
",",
"value",
")",
"{",
"var",
"len",
"=",
"arguments",
".",
"length",
",",
"lastSelectedDate",
"=",
"this",
".",
"lastSelectedDate",
";",
"if",
"(",
"len",
"==",
"2",
")",
"{",
"this",
".",
"opts",
"[",
"param",
"]",
"=",
... | Updates datepicker options
@param {String|Object} param - parameter's name to update. If object then it will extend current options
@param {String|Number|Object} [value] - new param value | [
"Updates",
"datepicker",
"options"
] | 004188d9480e3711c08491d6bb988814314a2b13 | https://github.com/t1m0n/air-datepicker/blob/004188d9480e3711c08491d6bb988814314a2b13/dist/js/datepicker.js#L607-L653 | train | |
t1m0n/air-datepicker | dist/js/datepicker.js | function (date, type) {
var time = date.getTime(),
d = datepicker.getParsedDate(date),
min = datepicker.getParsedDate(this.minDate),
max = datepicker.getParsedDate(this.maxDate),
dMinTime = new Date(d.year, d.month, min.date).getTime(),
... | javascript | function (date, type) {
var time = date.getTime(),
d = datepicker.getParsedDate(date),
min = datepicker.getParsedDate(this.minDate),
max = datepicker.getParsedDate(this.maxDate),
dMinTime = new Date(d.year, d.month, min.date).getTime(),
... | [
"function",
"(",
"date",
",",
"type",
")",
"{",
"var",
"time",
"=",
"date",
".",
"getTime",
"(",
")",
",",
"d",
"=",
"datepicker",
".",
"getParsedDate",
"(",
"date",
")",
",",
"min",
"=",
"datepicker",
".",
"getParsedDate",
"(",
"this",
".",
"minDate... | Check if date is between minDate and maxDate
@param date {object} - date object
@param type {string} - cell type
@returns {boolean}
@private | [
"Check",
"if",
"date",
"is",
"between",
"minDate",
"and",
"maxDate"
] | 004188d9480e3711c08491d6bb988814314a2b13 | https://github.com/t1m0n/air-datepicker/blob/004188d9480e3711c08491d6bb988814314a2b13/dist/js/datepicker.js#L709-L722 | train | |
t1m0n/air-datepicker | dist/js/datepicker.js | function (date) {
var totalMonthDays = dp.getDaysCount(date),
firstMonthDay = new Date(date.getFullYear(), date.getMonth(), 1).getDay(),
lastMonthDay = new Date(date.getFullYear(), date.getMonth(), totalMonthDays).getDay(),
daysFromPevMonth = firstMonthDay - t... | javascript | function (date) {
var totalMonthDays = dp.getDaysCount(date),
firstMonthDay = new Date(date.getFullYear(), date.getMonth(), 1).getDay(),
lastMonthDay = new Date(date.getFullYear(), date.getMonth(), totalMonthDays).getDay(),
daysFromPevMonth = firstMonthDay - t... | [
"function",
"(",
"date",
")",
"{",
"var",
"totalMonthDays",
"=",
"dp",
".",
"getDaysCount",
"(",
"date",
")",
",",
"firstMonthDay",
"=",
"new",
"Date",
"(",
"date",
".",
"getFullYear",
"(",
")",
",",
"date",
".",
"getMonth",
"(",
")",
",",
"1",
")",
... | Calculates days number to render. Generates days html and returns it.
@param {object} date - Date object
@returns {string}
@private | [
"Calculates",
"days",
"number",
"to",
"render",
".",
"Generates",
"days",
"html",
"and",
"returns",
"it",
"."
] | 004188d9480e3711c08491d6bb988814314a2b13 | https://github.com/t1m0n/air-datepicker/blob/004188d9480e3711c08491d6bb988814314a2b13/dist/js/datepicker.js#L1643-L1665 | train | |
t1m0n/air-datepicker | dist/js/datepicker.js | function (date) {
var html = '',
d = dp.getParsedDate(date),
i = 0;
while(i < 12) {
html += this._getMonthHtml(new Date(d.year, i));
i++
}
return html;
} | javascript | function (date) {
var html = '',
d = dp.getParsedDate(date),
i = 0;
while(i < 12) {
html += this._getMonthHtml(new Date(d.year, i));
i++
}
return html;
} | [
"function",
"(",
"date",
")",
"{",
"var",
"html",
"=",
"''",
",",
"d",
"=",
"dp",
".",
"getParsedDate",
"(",
"date",
")",
",",
"i",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"12",
")",
"{",
"html",
"+=",
"this",
".",
"_getMonthHtml",
"(",
"new",
... | Generates months html
@param {object} date - date instance
@returns {string}
@private | [
"Generates",
"months",
"html"
] | 004188d9480e3711c08491d6bb988814314a2b13 | https://github.com/t1m0n/air-datepicker/blob/004188d9480e3711c08491d6bb988814314a2b13/dist/js/datepicker.js#L1682-L1693 | train | |
t1m0n/air-datepicker | dist/js/datepicker.js | function (date) {
this._setDefaultMinMaxTime();
if (date) {
if (dp.isSame(date, this.d.opts.minDate)) {
this._setMinTimeFromDate(this.d.opts.minDate);
} else if (dp.isSame(date, this.d.opts.maxDate)) {
this._setMaxTimeFromDa... | javascript | function (date) {
this._setDefaultMinMaxTime();
if (date) {
if (dp.isSame(date, this.d.opts.minDate)) {
this._setMinTimeFromDate(this.d.opts.minDate);
} else if (dp.isSame(date, this.d.opts.maxDate)) {
this._setMaxTimeFromDa... | [
"function",
"(",
"date",
")",
"{",
"this",
".",
"_setDefaultMinMaxTime",
"(",
")",
";",
"if",
"(",
"date",
")",
"{",
"if",
"(",
"dp",
".",
"isSame",
"(",
"date",
",",
"this",
".",
"d",
".",
"opts",
".",
"minDate",
")",
")",
"{",
"this",
".",
"_... | Sets minHours, minMinutes etc. from date. If date is not passed, than sets
values from options
@param [date] {object} - Date object, to get values from
@private | [
"Sets",
"minHours",
"minMinutes",
"etc",
".",
"from",
"date",
".",
"If",
"date",
"is",
"not",
"passed",
"than",
"sets",
"values",
"from",
"options"
] | 004188d9480e3711c08491d6bb988814314a2b13 | https://github.com/t1m0n/air-datepicker/blob/004188d9480e3711c08491d6bb988814314a2b13/dist/js/datepicker.js#L2125-L2136 | train | |
t1m0n/air-datepicker | dist/js/datepicker.js | function (date, ampm) {
var d = date,
hours = date;
if (date instanceof Date) {
d = dp.getParsedDate(date);
hours = d.hours;
}
var _ampm = ampm || this.d.ampm,
dayPeriod = 'am';
if (_ampm) {
... | javascript | function (date, ampm) {
var d = date,
hours = date;
if (date instanceof Date) {
d = dp.getParsedDate(date);
hours = d.hours;
}
var _ampm = ampm || this.d.ampm,
dayPeriod = 'am';
if (_ampm) {
... | [
"function",
"(",
"date",
",",
"ampm",
")",
"{",
"var",
"d",
"=",
"date",
",",
"hours",
"=",
"date",
";",
"if",
"(",
"date",
"instanceof",
"Date",
")",
"{",
"d",
"=",
"dp",
".",
"getParsedDate",
"(",
"date",
")",
";",
"hours",
"=",
"d",
".",
"ho... | Calculates valid hour value to display in text input and datepicker's body.
@param date {Date|Number} - date or hours
@param [ampm] {Boolean} - 12 hours mode
@returns {{hours: *, dayPeriod: string}}
@private | [
"Calculates",
"valid",
"hour",
"value",
"to",
"display",
"in",
"text",
"input",
"and",
"datepicker",
"s",
"body",
"."
] | 004188d9480e3711c08491d6bb988814314a2b13 | https://github.com/t1m0n/air-datepicker/blob/004188d9480e3711c08491d6bb988814314a2b13/dist/js/datepicker.js#L2150-L2183 | train | |
kevinchappell/formBuilder | src/demo/js/demo.js | toggleEdit | function toggleEdit() {
document.body.classList.toggle('form-rendered', editing)
if (!editing) {
$('.build-wrap').formBuilder('setData', $('.render-wrap').formRender('userData'))
} else {
const formRenderData = $('.build-wrap').formBuilder('getData', dataType)
$('.render-wrap').formRender(... | javascript | function toggleEdit() {
document.body.classList.toggle('form-rendered', editing)
if (!editing) {
$('.build-wrap').formBuilder('setData', $('.render-wrap').formRender('userData'))
} else {
const formRenderData = $('.build-wrap').formBuilder('getData', dataType)
$('.render-wrap').formRender(... | [
"function",
"toggleEdit",
"(",
")",
"{",
"document",
".",
"body",
".",
"classList",
".",
"toggle",
"(",
"'form-rendered'",
",",
"editing",
")",
"if",
"(",
"!",
"editing",
")",
"{",
"$",
"(",
"'.build-wrap'",
")",
".",
"formBuilder",
"(",
"'setData'",
","... | Toggles the edit mode for the demo
@return {Boolean} editMode | [
"Toggles",
"the",
"edit",
"mode",
"for",
"the",
"demo"
] | a5028073576002af518aabab93ca48efd5ed8514 | https://github.com/kevinchappell/formBuilder/blob/a5028073576002af518aabab93ca48efd5ed8514/src/demo/js/demo.js#L242-L256 | train |
kevinchappell/formBuilder | src/js/form-builder.js | function($field, isNew = false) {
let field = {}
if ($field instanceof jQuery) {
// get the default type etc & label for this field
field.type = $field[0].dataset.type
if (field.type) {
// check for a custom type
const custom = controls.custom.lookup(field.type)
if (cus... | javascript | function($field, isNew = false) {
let field = {}
if ($field instanceof jQuery) {
// get the default type etc & label for this field
field.type = $field[0].dataset.type
if (field.type) {
// check for a custom type
const custom = controls.custom.lookup(field.type)
if (cus... | [
"function",
"(",
"$field",
",",
"isNew",
"=",
"false",
")",
"{",
"let",
"field",
"=",
"{",
"}",
"if",
"(",
"$field",
"instanceof",
"jQuery",
")",
"{",
"// get the default type etc & label for this field",
"field",
".",
"type",
"=",
"$field",
"[",
"0",
"]",
... | builds the standard formbuilder datastructure for a field definition | [
"builds",
"the",
"standard",
"formbuilder",
"datastructure",
"for",
"a",
"field",
"definition"
] | a5028073576002af518aabab93ca48efd5ed8514 | https://github.com/kevinchappell/formBuilder/blob/a5028073576002af518aabab93ca48efd5ed8514/src/js/form-builder.js#L181-L239 | train | |
kevinchappell/formBuilder | src/js/form-builder.js | function(formData) {
formData = h.getData(formData)
if (formData && formData.length) {
formData.forEach(fieldData => prepFieldVars(trimObj(fieldData)))
d.stage.classList.remove('empty')
} else if (opts.defaultFields && opts.defaultFields.length) {
// Load default fields if none are set
... | javascript | function(formData) {
formData = h.getData(formData)
if (formData && formData.length) {
formData.forEach(fieldData => prepFieldVars(trimObj(fieldData)))
d.stage.classList.remove('empty')
} else if (opts.defaultFields && opts.defaultFields.length) {
// Load default fields if none are set
... | [
"function",
"(",
"formData",
")",
"{",
"formData",
"=",
"h",
".",
"getData",
"(",
"formData",
")",
"if",
"(",
"formData",
"&&",
"formData",
".",
"length",
")",
"{",
"formData",
".",
"forEach",
"(",
"fieldData",
"=>",
"prepFieldVars",
"(",
"trimObj",
"(",... | Parse saved XML template data | [
"Parse",
"saved",
"XML",
"template",
"data"
] | a5028073576002af518aabab93ca48efd5ed8514 | https://github.com/kevinchappell/formBuilder/blob/a5028073576002af518aabab93ca48efd5ed8514/src/js/form-builder.js#L242-L261 | train | |
kevinchappell/formBuilder | src/js/form-builder.js | userAttrType | function userAttrType(attr, attrData) {
return (
[
['array', ({ options }) => !!options],
[typeof attrData.value, () => true], // string, number,
].find(typeCondition => typeCondition[1](attrData))[0] || 'string'
)
} | javascript | function userAttrType(attr, attrData) {
return (
[
['array', ({ options }) => !!options],
[typeof attrData.value, () => true], // string, number,
].find(typeCondition => typeCondition[1](attrData))[0] || 'string'
)
} | [
"function",
"userAttrType",
"(",
"attr",
",",
"attrData",
")",
"{",
"return",
"(",
"[",
"[",
"'array'",
",",
"(",
"{",
"options",
"}",
")",
"=>",
"!",
"!",
"options",
"]",
",",
"[",
"typeof",
"attrData",
".",
"value",
",",
"(",
")",
"=>",
"true",
... | Detects the type of user defined attribute
@param {String} attr attribute name
@param {Object} attrData attribute config
@return {String} type of user attr | [
"Detects",
"the",
"type",
"of",
"user",
"defined",
"attribute"
] | a5028073576002af518aabab93ca48efd5ed8514 | https://github.com/kevinchappell/formBuilder/blob/a5028073576002af518aabab93ca48efd5ed8514/src/js/form-builder.js#L507-L514 | train |
kevinchappell/formBuilder | src/js/form-builder.js | inputUserAttrs | function inputUserAttrs(name, inputAttrs) {
const { class: classname, className, ...attrs } = inputAttrs
let textAttrs = {
id: name + '-' + data.lastID,
title: attrs.description || attrs.label || name.toUpperCase(),
name: name,
type: attrs.type || 'text',
className: [`fld-${name}`,... | javascript | function inputUserAttrs(name, inputAttrs) {
const { class: classname, className, ...attrs } = inputAttrs
let textAttrs = {
id: name + '-' + data.lastID,
title: attrs.description || attrs.label || name.toUpperCase(),
name: name,
type: attrs.type || 'text',
className: [`fld-${name}`,... | [
"function",
"inputUserAttrs",
"(",
"name",
",",
"inputAttrs",
")",
"{",
"const",
"{",
"class",
":",
"classname",
",",
"className",
",",
"...",
"attrs",
"}",
"=",
"inputAttrs",
"let",
"textAttrs",
"=",
"{",
"id",
":",
"name",
"+",
"'-'",
"+",
"data",
".... | Text input value for attribute
@param {String} name
@param {Object} inputAttrs also known as values
@return {String} input markup | [
"Text",
"input",
"value",
"for",
"attribute"
] | a5028073576002af518aabab93ca48efd5ed8514 | https://github.com/kevinchappell/formBuilder/blob/a5028073576002af518aabab93ca48efd5ed8514/src/js/form-builder.js#L562-L582 | train |
kevinchappell/formBuilder | src/js/form-builder.js | selectUserAttrs | function selectUserAttrs(name, fieldData) {
const { multiple, options, label: labelText, value, class: classname, className, ...restData } = fieldData
const optis = Object.keys(options).map(val => {
const attrs = { value: val }
const optionTextVal = options[val]
const optionText = Array.isArra... | javascript | function selectUserAttrs(name, fieldData) {
const { multiple, options, label: labelText, value, class: classname, className, ...restData } = fieldData
const optis = Object.keys(options).map(val => {
const attrs = { value: val }
const optionTextVal = options[val]
const optionText = Array.isArra... | [
"function",
"selectUserAttrs",
"(",
"name",
",",
"fieldData",
")",
"{",
"const",
"{",
"multiple",
",",
"options",
",",
"label",
":",
"labelText",
",",
"value",
",",
"class",
":",
"classname",
",",
"className",
",",
"...",
"restData",
"}",
"=",
"fieldData",... | Select input for multiple choice user attributes
@todo replace with selectAttr
@param {String} name
@param {Object} fieldData
@return {String} select markup | [
"Select",
"input",
"for",
"multiple",
"choice",
"user",
"attributes"
] | a5028073576002af518aabab93ca48efd5ed8514 | https://github.com/kevinchappell/formBuilder/blob/a5028073576002af518aabab93ca48efd5ed8514/src/js/form-builder.js#L591-L624 | train |
kevinchappell/formBuilder | src/js/form-builder.js | function(name, optionData, multipleSelect) {
const optionInputType = {
selected: multipleSelect ? 'checkbox' : 'radio',
}
const optionDataOrder = ['value', 'label', 'selected']
const optionInputs = []
const optionTemplate = { selected: false, label: '', value: '' }
optionData = Object.ass... | javascript | function(name, optionData, multipleSelect) {
const optionInputType = {
selected: multipleSelect ? 'checkbox' : 'radio',
}
const optionDataOrder = ['value', 'label', 'selected']
const optionInputs = []
const optionTemplate = { selected: false, label: '', value: '' }
optionData = Object.ass... | [
"function",
"(",
"name",
",",
"optionData",
",",
"multipleSelect",
")",
"{",
"const",
"optionInputType",
"=",
"{",
"selected",
":",
"multipleSelect",
"?",
"'checkbox'",
":",
"'radio'",
",",
"}",
"const",
"optionDataOrder",
"=",
"[",
"'value'",
",",
"'label'",
... | Select field html, since there may be multiple | [
"Select",
"field",
"html",
"since",
"there",
"may",
"be",
"multiple"
] | a5028073576002af518aabab93ca48efd5ed8514 | https://github.com/kevinchappell/formBuilder/blob/a5028073576002af518aabab93ca48efd5ed8514/src/js/form-builder.js#L954-L991 | train | |
stylelint/stylelint | lib/rules/selector-descendant-combinator-no-non-space/index.js | isActuallyCombinator | function isActuallyCombinator(combinatorNode) {
// `.foo /*comment*/, .bar`
// ^^
// If include comments, this spaces is a combinator, but it is not combinators.
if (!/^\s+$/.test(combinatorNode.value)) {
return true;
}
let next = combinatorNode.next();
while (skipTest(next)) {
next = next... | javascript | function isActuallyCombinator(combinatorNode) {
// `.foo /*comment*/, .bar`
// ^^
// If include comments, this spaces is a combinator, but it is not combinators.
if (!/^\s+$/.test(combinatorNode.value)) {
return true;
}
let next = combinatorNode.next();
while (skipTest(next)) {
next = next... | [
"function",
"isActuallyCombinator",
"(",
"combinatorNode",
")",
"{",
"// `.foo /*comment*/, .bar`",
"// ^^",
"// If include comments, this spaces is a combinator, but it is not combinators.",
"if",
"(",
"!",
"/",
"^\\s+$",
"/",
".",
"test",
"(",
"combinatorNode",
".",
"... | Check whether is actually a combinator.
@param {Node} combinatorNode The combinator node
@returns {boolean} `true` if is actually a combinator. | [
"Check",
"whether",
"is",
"actually",
"a",
"combinator",
"."
] | b35c55f6144d0cb03924498f275cc39c39de3816 | https://github.com/stylelint/stylelint/blob/b35c55f6144d0cb03924498f275cc39c39de3816/lib/rules/selector-descendant-combinator-no-non-space/index.js#L97-L154 | train |
stylelint/stylelint | lib/rules/selector-class-pattern/index.js | hasInterpolatingAmpersand | function hasInterpolatingAmpersand(selector) {
for (let i = 0, l = selector.length; i < l; i++) {
if (selector[i] !== "&") {
continue;
}
if (!_.isUndefined(selector[i - 1]) && !isCombinator(selector[i - 1])) {
return true;
}
if (!_.isUndefined(selector[i + 1]) && !isCombinator(select... | javascript | function hasInterpolatingAmpersand(selector) {
for (let i = 0, l = selector.length; i < l; i++) {
if (selector[i] !== "&") {
continue;
}
if (!_.isUndefined(selector[i - 1]) && !isCombinator(selector[i - 1])) {
return true;
}
if (!_.isUndefined(selector[i + 1]) && !isCombinator(select... | [
"function",
"hasInterpolatingAmpersand",
"(",
"selector",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"l",
"=",
"selector",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"if",
"(",
"selector",
"[",
"i",
"]",
"!==",
"\"&\"",
")... | An "interpolating ampersand" means an "&" used to interpolate within another simple selector, rather than an "&" that stands on its own as a simple selector | [
"An",
"interpolating",
"ampersand",
"means",
"an",
"&",
"used",
"to",
"interpolate",
"within",
"another",
"simple",
"selector",
"rather",
"than",
"an",
"&",
"that",
"stands",
"on",
"its",
"own",
"as",
"a",
"simple",
"selector"
] | b35c55f6144d0cb03924498f275cc39c39de3816 | https://github.com/stylelint/stylelint/blob/b35c55f6144d0cb03924498f275cc39c39de3816/lib/rules/selector-class-pattern/index.js#L104-L120 | train |
stylelint/stylelint | lib/rules/function-calc-no-invalid/index.js | verifyMathExpressions | function verifyMathExpressions(expression, node) {
if (expression.type === "MathExpression") {
const { operator, left, right } = expression;
if (operator === "+" || operator === "-") {
if (
expression.source.operator.end.index === right.source.start.index
... | javascript | function verifyMathExpressions(expression, node) {
if (expression.type === "MathExpression") {
const { operator, left, right } = expression;
if (operator === "+" || operator === "-") {
if (
expression.source.operator.end.index === right.source.start.index
... | [
"function",
"verifyMathExpressions",
"(",
"expression",
",",
"node",
")",
"{",
"if",
"(",
"expression",
".",
"type",
"===",
"\"MathExpression\"",
")",
"{",
"const",
"{",
"operator",
",",
"left",
",",
"right",
"}",
"=",
"expression",
";",
"if",
"(",
"operat... | Verify that each operation expression is valid.
Reports when a invalid operation expression is found.
@param {object} expression expression node.
@param {object} node calc function node.
@returns {void} | [
"Verify",
"that",
"each",
"operation",
"expression",
"is",
"valid",
".",
"Reports",
"when",
"a",
"invalid",
"operation",
"expression",
"is",
"found",
"."
] | b35c55f6144d0cb03924498f275cc39c39de3816 | https://github.com/stylelint/stylelint/blob/b35c55f6144d0cb03924498f275cc39c39de3816/lib/rules/function-calc-no-invalid/index.js#L85-L129 | train |
stylelint/stylelint | lib/rules/functionCommaSpaceChecker.js | getCommaCheckIndex | function getCommaCheckIndex(commaNode, nodeIndex) {
let commaBefore =
valueNode.before +
argumentStrings.slice(0, nodeIndex).join("") +
commaNode.before;
// 1. Remove comments including preceeding whitespace (when only succeeded by whitespace)
// 2. Remove all othe... | javascript | function getCommaCheckIndex(commaNode, nodeIndex) {
let commaBefore =
valueNode.before +
argumentStrings.slice(0, nodeIndex).join("") +
commaNode.before;
// 1. Remove comments including preceeding whitespace (when only succeeded by whitespace)
// 2. Remove all othe... | [
"function",
"getCommaCheckIndex",
"(",
"commaNode",
",",
"nodeIndex",
")",
"{",
"let",
"commaBefore",
"=",
"valueNode",
".",
"before",
"+",
"argumentStrings",
".",
"slice",
"(",
"0",
",",
"nodeIndex",
")",
".",
"join",
"(",
"\"\"",
")",
"+",
"commaNode",
"... | Gets the index of the comma for checking.
@param {Node} commaNode The comma node
@param {number} nodeIndex The index of the comma node
@returns {number} The index of the comma for checking | [
"Gets",
"the",
"index",
"of",
"the",
"comma",
"for",
"checking",
"."
] | b35c55f6144d0cb03924498f275cc39c39de3816 | https://github.com/stylelint/stylelint/blob/b35c55f6144d0cb03924498f275cc39c39de3816/lib/rules/functionCommaSpaceChecker.js#L55-L69 | train |
stylelint/stylelint | lib/rules/max-empty-lines/index.js | isEofNode | function isEofNode(document, root) {
if (!document || document.constructor.name !== "Document") {
return true;
}
// In the `postcss-html` and `postcss-jsx` syntax, checks that there is text after the given node.
let after;
if (root === document.last) {
after = _.get(document, "raws.afterEnd");
} e... | javascript | function isEofNode(document, root) {
if (!document || document.constructor.name !== "Document") {
return true;
}
// In the `postcss-html` and `postcss-jsx` syntax, checks that there is text after the given node.
let after;
if (root === document.last) {
after = _.get(document, "raws.afterEnd");
} e... | [
"function",
"isEofNode",
"(",
"document",
",",
"root",
")",
"{",
"if",
"(",
"!",
"document",
"||",
"document",
".",
"constructor",
".",
"name",
"!==",
"\"Document\"",
")",
"{",
"return",
"true",
";",
"}",
"// In the `postcss-html` and `postcss-jsx` syntax, checks ... | Checks whether the given node is the last node of file.
@param {Document|null} document the document node with `postcss-html` and `postcss-jsx`.
@param {Root} root the root node of css | [
"Checks",
"whether",
"the",
"given",
"node",
"is",
"the",
"last",
"node",
"of",
"file",
"."
] | b35c55f6144d0cb03924498f275cc39c39de3816 | https://github.com/stylelint/stylelint/blob/b35c55f6144d0cb03924498f275cc39c39de3816/lib/rules/max-empty-lines/index.js#L109-L126 | train |
stylelint/stylelint | lib/augmentConfig.js | augmentConfigBasic | function augmentConfigBasic(
stylelint /*: stylelint$internalApi*/,
config /*: stylelint$config*/,
configDir /*: string*/,
allowOverrides /*:: ?: boolean*/
) /*: Promise<stylelint$config>*/ {
return Promise.resolve()
.then(() => {
if (!allowOverrides) return config;
return _.merge(config, sty... | javascript | function augmentConfigBasic(
stylelint /*: stylelint$internalApi*/,
config /*: stylelint$config*/,
configDir /*: string*/,
allowOverrides /*:: ?: boolean*/
) /*: Promise<stylelint$config>*/ {
return Promise.resolve()
.then(() => {
if (!allowOverrides) return config;
return _.merge(config, sty... | [
"function",
"augmentConfigBasic",
"(",
"stylelint",
"/*: stylelint$internalApi*/",
",",
"config",
"/*: stylelint$config*/",
",",
"configDir",
"/*: string*/",
",",
"allowOverrides",
"/*:: ?: boolean*/",
")",
"/*: Promise<stylelint$config>*/",
"{",
"return",
"Promise",
".",
"re... | - Merges config and configOverrides - Makes all paths absolute - Merges extends | [
"-",
"Merges",
"config",
"and",
"configOverrides",
"-",
"Makes",
"all",
"paths",
"absolute",
"-",
"Merges",
"extends"
] | b35c55f6144d0cb03924498f275cc39c39de3816 | https://github.com/stylelint/stylelint/blob/b35c55f6144d0cb03924498f275cc39c39de3816/lib/augmentConfig.js#L16-L34 | train |
stylelint/stylelint | lib/augmentConfig.js | augmentConfigExtended | function augmentConfigExtended(
stylelint /*: stylelint$internalApi*/,
cosmiconfigResultArg /*: ?{
config: stylelint$config,
filepath: string,
}*/
) /*: Promise<?{ config: stylelint$config, filepath: string }>*/ {
const cosmiconfigResult = cosmiconfigResultArg; // Lock in for Flow
if (!cosmiconfig... | javascript | function augmentConfigExtended(
stylelint /*: stylelint$internalApi*/,
cosmiconfigResultArg /*: ?{
config: stylelint$config,
filepath: string,
}*/
) /*: Promise<?{ config: stylelint$config, filepath: string }>*/ {
const cosmiconfigResult = cosmiconfigResultArg; // Lock in for Flow
if (!cosmiconfig... | [
"function",
"augmentConfigExtended",
"(",
"stylelint",
"/*: stylelint$internalApi*/",
",",
"cosmiconfigResultArg",
"/*: ?{\n config: stylelint$config,\n filepath: string,\n }*/",
")",
"/*: Promise<?{ config: stylelint$config, filepath: string }>*/",
"{",
"const",
"cosmiconfigResult... | Extended configs need to be run through augmentConfigBasic but do not need the full treatment. Things like pluginFunctions will be resolved and added by the parent config. | [
"Extended",
"configs",
"need",
"to",
"be",
"run",
"through",
"augmentConfigBasic",
"but",
"do",
"not",
"need",
"the",
"full",
"treatment",
".",
"Things",
"like",
"pluginFunctions",
"will",
"be",
"resolved",
"and",
"added",
"by",
"the",
"parent",
"config",
"."
... | b35c55f6144d0cb03924498f275cc39c39de3816 | https://github.com/stylelint/stylelint/blob/b35c55f6144d0cb03924498f275cc39c39de3816/lib/augmentConfig.js#L39-L61 | train |
stylelint/stylelint | lib/augmentConfig.js | absolutizeProcessors | function absolutizeProcessors(
processors /*: stylelint$configProcessors*/,
configDir /*: string*/
) /*: stylelint$configProcessors*/ {
const normalizedProcessors = Array.isArray(processors)
? processors
: [processors];
return normalizedProcessors.map(item => {
if (typeof item === "string") {
... | javascript | function absolutizeProcessors(
processors /*: stylelint$configProcessors*/,
configDir /*: string*/
) /*: stylelint$configProcessors*/ {
const normalizedProcessors = Array.isArray(processors)
? processors
: [processors];
return normalizedProcessors.map(item => {
if (typeof item === "string") {
... | [
"function",
"absolutizeProcessors",
"(",
"processors",
"/*: stylelint$configProcessors*/",
",",
"configDir",
"/*: string*/",
")",
"/*: stylelint$configProcessors*/",
"{",
"const",
"normalizedProcessors",
"=",
"Array",
".",
"isArray",
"(",
"processors",
")",
"?",
"processors... | Processors are absolutized in their own way because they can be and return a string or an array | [
"Processors",
"are",
"absolutized",
"in",
"their",
"own",
"way",
"because",
"they",
"can",
"be",
"and",
"return",
"a",
"string",
"or",
"an",
"array"
] | b35c55f6144d0cb03924498f275cc39c39de3816 | https://github.com/stylelint/stylelint/blob/b35c55f6144d0cb03924498f275cc39c39de3816/lib/augmentConfig.js#L136-L151 | train |
stylelint/stylelint | lib/utils/addEmptyLineAfter.js | addEmptyLineAfter | function addEmptyLineAfter(
node /*: postcss$node*/,
newline /*: '\n' | '\r\n'*/
) /*: postcss$node*/ {
const after = _.last(node.raws.after.split(";"));
if (!/\r?\n/.test(after)) {
node.raws.after = node.raws.after + _.repeat(newline, 2);
} else {
node.raws.after = node.raws.after.replace(/(\r?\n)/,... | javascript | function addEmptyLineAfter(
node /*: postcss$node*/,
newline /*: '\n' | '\r\n'*/
) /*: postcss$node*/ {
const after = _.last(node.raws.after.split(";"));
if (!/\r?\n/.test(after)) {
node.raws.after = node.raws.after + _.repeat(newline, 2);
} else {
node.raws.after = node.raws.after.replace(/(\r?\n)/,... | [
"function",
"addEmptyLineAfter",
"(",
"node",
"/*: postcss$node*/",
",",
"newline",
"/*: '\\n' | '\\r\\n'*/",
")",
"/*: postcss$node*/",
"{",
"const",
"after",
"=",
"_",
".",
"last",
"(",
"node",
".",
"raws",
".",
"after",
".",
"split",
"(",
"\";\"",
")",
")",... | Add an empty line after a node. Mutates the node. | [
"Add",
"an",
"empty",
"line",
"after",
"a",
"node",
".",
"Mutates",
"the",
"node",
"."
] | b35c55f6144d0cb03924498f275cc39c39de3816 | https://github.com/stylelint/stylelint/blob/b35c55f6144d0cb03924498f275cc39c39de3816/lib/utils/addEmptyLineAfter.js#L7-L20 | train |
stylelint/stylelint | lib/utils/addEmptyLineBefore.js | addEmptyLineBefore | function addEmptyLineBefore(
node /*: postcss$node*/,
newline /*: '\n' | '\r\n'*/
) /*: postcss$node*/ {
if (!/\r?\n/.test(node.raws.before)) {
node.raws.before = _.repeat(newline, 2) + node.raws.before;
} else {
node.raws.before = node.raws.before.replace(/(\r?\n)/, `${newline}$1`);
}
return node;... | javascript | function addEmptyLineBefore(
node /*: postcss$node*/,
newline /*: '\n' | '\r\n'*/
) /*: postcss$node*/ {
if (!/\r?\n/.test(node.raws.before)) {
node.raws.before = _.repeat(newline, 2) + node.raws.before;
} else {
node.raws.before = node.raws.before.replace(/(\r?\n)/, `${newline}$1`);
}
return node;... | [
"function",
"addEmptyLineBefore",
"(",
"node",
"/*: postcss$node*/",
",",
"newline",
"/*: '\\n' | '\\r\\n'*/",
")",
"/*: postcss$node*/",
"{",
"if",
"(",
"!",
"/",
"\\r?\\n",
"/",
".",
"test",
"(",
"node",
".",
"raws",
".",
"before",
")",
")",
"{",
"node",
"... | Add an empty line before a node. Mutates the node. | [
"Add",
"an",
"empty",
"line",
"before",
"a",
"node",
".",
"Mutates",
"the",
"node",
"."
] | b35c55f6144d0cb03924498f275cc39c39de3816 | https://github.com/stylelint/stylelint/blob/b35c55f6144d0cb03924498f275cc39c39de3816/lib/utils/addEmptyLineBefore.js#L7-L18 | train |
lambci/docker-lambda | nodejs6.10/run/awslambda-mock.js | function(invokeId, errType, resultStr) {
if (!invoked) return
var diffMs = hrTimeMs(process.hrtime(start))
var billedMs = Math.min(100 * (Math.floor(diffMs / 100) + 1), TIMEOUT * 1000)
systemLog('END RequestId: ' + invokeId)
systemLog([
'REPORT RequestId: ' + invokeId,
'Duration: ' + dif... | javascript | function(invokeId, errType, resultStr) {
if (!invoked) return
var diffMs = hrTimeMs(process.hrtime(start))
var billedMs = Math.min(100 * (Math.floor(diffMs / 100) + 1), TIMEOUT * 1000)
systemLog('END RequestId: ' + invokeId)
systemLog([
'REPORT RequestId: ' + invokeId,
'Duration: ' + dif... | [
"function",
"(",
"invokeId",
",",
"errType",
",",
"resultStr",
")",
"{",
"if",
"(",
"!",
"invoked",
")",
"return",
"var",
"diffMs",
"=",
"hrTimeMs",
"(",
"process",
".",
"hrtime",
"(",
"start",
")",
")",
"var",
"billedMs",
"=",
"Math",
".",
"min",
"(... | eslint-disable-line no-unused-vars | [
"eslint",
"-",
"disable",
"-",
"line",
"no",
"-",
"unused",
"-",
"vars"
] | d5a7c1d5cb8615b98cfab8e802140182c897b23a | https://github.com/lambci/docker-lambda/blob/d5a7c1d5cb8615b98cfab8e802140182c897b23a/nodejs6.10/run/awslambda-mock.js#L88-L108 | train | |
lambci/docker-lambda | nodejs6.10/run/awslambda-mock.js | uuid | function uuid() {
return crypto.randomBytes(4).toString('hex') + '-' +
crypto.randomBytes(2).toString('hex') + '-' +
crypto.randomBytes(2).toString('hex').replace(/^./, '1') + '-' +
crypto.randomBytes(2).toString('hex') + '-' +
crypto.randomBytes(6).toString('hex')
} | javascript | function uuid() {
return crypto.randomBytes(4).toString('hex') + '-' +
crypto.randomBytes(2).toString('hex') + '-' +
crypto.randomBytes(2).toString('hex').replace(/^./, '1') + '-' +
crypto.randomBytes(2).toString('hex') + '-' +
crypto.randomBytes(6).toString('hex')
} | [
"function",
"uuid",
"(",
")",
"{",
"return",
"crypto",
".",
"randomBytes",
"(",
"4",
")",
".",
"toString",
"(",
"'hex'",
")",
"+",
"'-'",
"+",
"crypto",
".",
"randomBytes",
"(",
"2",
")",
".",
"toString",
"(",
"'hex'",
")",
"+",
"'-'",
"+",
"crypto... | Approximates the look of a v1 UUID | [
"Approximates",
"the",
"look",
"of",
"a",
"v1",
"UUID"
] | d5a7c1d5cb8615b98cfab8e802140182c897b23a | https://github.com/lambci/docker-lambda/blob/d5a7c1d5cb8615b98cfab8e802140182c897b23a/nodejs6.10/run/awslambda-mock.js#L143-L149 | train |
priologic/easyrtc | lib/easyrtc_public_obj.js | function(roomName, appRoomObj, callback) {
// Join room. Creates a default connection room object
e.app[appName].connection[easyrtcid].room[roomName] = {
apiField: {},
enteredOn: Date.now(),
gotListOn: Date.now(),
... | javascript | function(roomName, appRoomObj, callback) {
// Join room. Creates a default connection room object
e.app[appName].connection[easyrtcid].room[roomName] = {
apiField: {},
enteredOn: Date.now(),
gotListOn: Date.now(),
... | [
"function",
"(",
"roomName",
",",
"appRoomObj",
",",
"callback",
")",
"{",
"// Join room. Creates a default connection room object\r",
"e",
".",
"app",
"[",
"appName",
"]",
".",
"connection",
"[",
"easyrtcid",
"]",
".",
"room",
"[",
"roomName",
"]",
"=",
"{",
... | Local private function to create the default connection-room object in the private variable | [
"Local",
"private",
"function",
"to",
"create",
"the",
"default",
"connection",
"-",
"room",
"object",
"in",
"the",
"private",
"variable"
] | 5ea69776f319fab15a784f94db91a2c1f5154ef5 | https://github.com/priologic/easyrtc/blob/5ea69776f319fab15a784f94db91a2c1f5154ef5/lib/easyrtc_public_obj.js#L2362-L2381 | train | |
priologic/easyrtc | lib/easyrtc_default_event_listeners.js | function (err) {
if (err) {
try{
pub.util.sendSocketCallbackMsg(easyrtcid, socketCallback, pub.util.getErrorMsg("LOGIN_GEN_FAIL"), appObj);
socket.disconnect();
pub.util.logError("["+easyrtcid+"] General authentication error. Socket disconnected.", err... | javascript | function (err) {
if (err) {
try{
pub.util.sendSocketCallbackMsg(easyrtcid, socketCallback, pub.util.getErrorMsg("LOGIN_GEN_FAIL"), appObj);
socket.disconnect();
pub.util.logError("["+easyrtcid+"] General authentication error. Socket disconnected.", err... | [
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"try",
"{",
"pub",
".",
"util",
".",
"sendSocketCallbackMsg",
"(",
"easyrtcid",
",",
"socketCallback",
",",
"pub",
".",
"util",
".",
"getErrorMsg",
"(",
"\"LOGIN_GEN_FAIL\"",
")",
",",
"appObj... | This function is called upon completion of the async waterfall, or upon an error being thrown. | [
"This",
"function",
"is",
"called",
"upon",
"completion",
"of",
"the",
"async",
"waterfall",
"or",
"upon",
"an",
"error",
"being",
"thrown",
"."
] | 5ea69776f319fab15a784f94db91a2c1f5154ef5 | https://github.com/priologic/easyrtc/blob/5ea69776f319fab15a784f94db91a2c1f5154ef5/lib/easyrtc_default_event_listeners.js#L491-L501 | train | |
priologic/easyrtc | demos/js/demo_ice_filter.js | iceCandidateFilter | function iceCandidateFilter( iceCandidate, fromPeer) {
var sdp = iceCandidate.candidate;
if( sdp.indexOf("typ relay") > 0) { // is turn candidate
if( document.getElementById("allowTurn").checked ) {
return iceCandidate;
}
else {
return null;
}
}
else if( sdp... | javascript | function iceCandidateFilter( iceCandidate, fromPeer) {
var sdp = iceCandidate.candidate;
if( sdp.indexOf("typ relay") > 0) { // is turn candidate
if( document.getElementById("allowTurn").checked ) {
return iceCandidate;
}
else {
return null;
}
}
else if( sdp... | [
"function",
"iceCandidateFilter",
"(",
"iceCandidate",
",",
"fromPeer",
")",
"{",
"var",
"sdp",
"=",
"iceCandidate",
".",
"candidate",
";",
"if",
"(",
"sdp",
".",
"indexOf",
"(",
"\"typ relay\"",
")",
">",
"0",
")",
"{",
"// is turn candidate",
"if",
"(",
... | filter ice candidates according to the ice candidates checkbox. | [
"filter",
"ice",
"candidates",
"according",
"to",
"the",
"ice",
"candidates",
"checkbox",
"."
] | 5ea69776f319fab15a784f94db91a2c1f5154ef5 | https://github.com/priologic/easyrtc/blob/5ea69776f319fab15a784f94db91a2c1f5154ef5/demos/js/demo_ice_filter.js#L6-L35 | train |
priologic/easyrtc | demos/js/demo_multiparty.js | setThumbSizeAspect | function setThumbSizeAspect(percentSize, percentLeft, percentTop, parentw, parenth, aspect) {
var width, height;
if( parentw < parenth*aspectRatio){
width = parentw * percentSize;
height = width/aspect;
}
else {
height = parenth * percentSize;
width = height*asp... | javascript | function setThumbSizeAspect(percentSize, percentLeft, percentTop, parentw, parenth, aspect) {
var width, height;
if( parentw < parenth*aspectRatio){
width = parentw * percentSize;
height = width/aspect;
}
else {
height = parenth * percentSize;
width = height*asp... | [
"function",
"setThumbSizeAspect",
"(",
"percentSize",
",",
"percentLeft",
",",
"percentTop",
",",
"parentw",
",",
"parenth",
",",
"aspect",
")",
"{",
"var",
"width",
",",
"height",
";",
"if",
"(",
"parentw",
"<",
"parenth",
"*",
"aspectRatio",
")",
"{",
"w... | a negative percentLeft is interpreted as setting the right edge of the object that distance from the right edge of the parent. Similar for percentTop. | [
"a",
"negative",
"percentLeft",
"is",
"interpreted",
"as",
"setting",
"the",
"right",
"edge",
"of",
"the",
"object",
"that",
"distance",
"from",
"the",
"right",
"edge",
"of",
"the",
"parent",
".",
"Similar",
"for",
"percentTop",
"."
] | 5ea69776f319fab15a784f94db91a2c1f5154ef5 | https://github.com/priologic/easyrtc/blob/5ea69776f319fab15a784f94db91a2c1f5154ef5/demos/js/demo_multiparty.js#L70-L103 | train |
priologic/easyrtc | demos/js/demo_multiparty.js | establishConnection | function establishConnection(position) {
function callSuccess() {
connectCount++;
if( connectCount < maxCALLERS && position > 0) {
establishConnection(position-1);
}
}
function callFailure(errorCode, errorText) {
easyrtc.sho... | javascript | function establishConnection(position) {
function callSuccess() {
connectCount++;
if( connectCount < maxCALLERS && position > 0) {
establishConnection(position-1);
}
}
function callFailure(errorCode, errorText) {
easyrtc.sho... | [
"function",
"establishConnection",
"(",
"position",
")",
"{",
"function",
"callSuccess",
"(",
")",
"{",
"connectCount",
"++",
";",
"if",
"(",
"connectCount",
"<",
"maxCALLERS",
"&&",
"position",
">",
"0",
")",
"{",
"establishConnection",
"(",
"position",
"-",
... | Connect in reverse order. Latter arriving people are more likely to have empty slots. | [
"Connect",
"in",
"reverse",
"order",
".",
"Latter",
"arriving",
"people",
"are",
"more",
"likely",
"to",
"have",
"empty",
"slots",
"."
] | 5ea69776f319fab15a784f94db91a2c1f5154ef5 | https://github.com/priologic/easyrtc/blob/5ea69776f319fab15a784f94db91a2c1f5154ef5/demos/js/demo_multiparty.js#L541-L556 | train |
priologic/easyrtc | api/easyrtc.js | getCommonCapabilities | function getCommonCapabilities(localCapabilities, remoteCapabilities) {
var commonCapabilities = {
codecs: [],
headerExtensions: [],
fecMechanisms: []
};
var findCodecByPayloadType = function(pt, codecs) {
pt = parseInt(pt, 10);
for (var i = 0; i < codecs.length; i++) {
if (codecs[i].pa... | javascript | function getCommonCapabilities(localCapabilities, remoteCapabilities) {
var commonCapabilities = {
codecs: [],
headerExtensions: [],
fecMechanisms: []
};
var findCodecByPayloadType = function(pt, codecs) {
pt = parseInt(pt, 10);
for (var i = 0; i < codecs.length; i++) {
if (codecs[i].pa... | [
"function",
"getCommonCapabilities",
"(",
"localCapabilities",
",",
"remoteCapabilities",
")",
"{",
"var",
"commonCapabilities",
"=",
"{",
"codecs",
":",
"[",
"]",
",",
"headerExtensions",
":",
"[",
"]",
",",
"fecMechanisms",
":",
"[",
"]",
"}",
";",
"var",
... | Determines the intersection of local and remote capabilities. | [
"Determines",
"the",
"intersection",
"of",
"local",
"and",
"remote",
"capabilities",
"."
] | 5ea69776f319fab15a784f94db91a2c1f5154ef5 | https://github.com/priologic/easyrtc/blob/5ea69776f319fab15a784f94db91a2c1f5154ef5/api/easyrtc.js#L182-L257 | train |
priologic/easyrtc | api/easyrtc.js | isActionAllowedInSignalingState | function isActionAllowedInSignalingState(action, type, signalingState) {
return {
offer: {
setLocalDescription: ['stable', 'have-local-offer'],
setRemoteDescription: ['stable', 'have-remote-offer']
},
answer: {
setLocalDescription: ['have-remote-offer', 'have-local-pranswer'],
setR... | javascript | function isActionAllowedInSignalingState(action, type, signalingState) {
return {
offer: {
setLocalDescription: ['stable', 'have-local-offer'],
setRemoteDescription: ['stable', 'have-remote-offer']
},
answer: {
setLocalDescription: ['have-remote-offer', 'have-local-pranswer'],
setR... | [
"function",
"isActionAllowedInSignalingState",
"(",
"action",
",",
"type",
",",
"signalingState",
")",
"{",
"return",
"{",
"offer",
":",
"{",
"setLocalDescription",
":",
"[",
"'stable'",
",",
"'have-local-offer'",
"]",
",",
"setRemoteDescription",
":",
"[",
"'stab... | is action=setLocalDescription with type allowed in signalingState | [
"is",
"action",
"=",
"setLocalDescription",
"with",
"type",
"allowed",
"in",
"signalingState"
] | 5ea69776f319fab15a784f94db91a2c1f5154ef5 | https://github.com/priologic/easyrtc/blob/5ea69776f319fab15a784f94db91a2c1f5154ef5/api/easyrtc.js#L260-L271 | train |
priologic/easyrtc | api/easyrtc.js | function(window) {
var URL = window && window.URL;
if (!(typeof window === 'object' && window.HTMLMediaElement &&
'srcObject' in window.HTMLMediaElement.prototype &&
URL.createObjectURL && URL.revokeObjectURL)) {
// Only shim CreateObjectURL using srcObject if srcObject exists.
re... | javascript | function(window) {
var URL = window && window.URL;
if (!(typeof window === 'object' && window.HTMLMediaElement &&
'srcObject' in window.HTMLMediaElement.prototype &&
URL.createObjectURL && URL.revokeObjectURL)) {
// Only shim CreateObjectURL using srcObject if srcObject exists.
re... | [
"function",
"(",
"window",
")",
"{",
"var",
"URL",
"=",
"window",
"&&",
"window",
".",
"URL",
";",
"if",
"(",
"!",
"(",
"typeof",
"window",
"===",
"'object'",
"&&",
"window",
".",
"HTMLMediaElement",
"&&",
"'srcObject'",
"in",
"window",
".",
"HTMLMediaEl... | shimCreateObjectURL must be called before shimSourceObject to avoid loop. | [
"shimCreateObjectURL",
"must",
"be",
"called",
"before",
"shimSourceObject",
"to",
"avoid",
"loop",
"."
] | 5ea69776f319fab15a784f94db91a2c1f5154ef5 | https://github.com/priologic/easyrtc/blob/5ea69776f319fab15a784f94db91a2c1f5154ef5/api/easyrtc.js#L4038-L4087 | train | |
priologic/easyrtc | api/easyrtc.js | function(constraints, onSuccess, onError) {
var constraintsToFF37_ = function(c) {
if (typeof c !== 'object' || c.require) {
return c;
}
var require = [];
Object.keys(c).forEach(function(key) {
if (key === 'require' || key === 'advanced' || key === 'mediaSource') {
... | javascript | function(constraints, onSuccess, onError) {
var constraintsToFF37_ = function(c) {
if (typeof c !== 'object' || c.require) {
return c;
}
var require = [];
Object.keys(c).forEach(function(key) {
if (key === 'require' || key === 'advanced' || key === 'mediaSource') {
... | [
"function",
"(",
"constraints",
",",
"onSuccess",
",",
"onError",
")",
"{",
"var",
"constraintsToFF37_",
"=",
"function",
"(",
"c",
")",
"{",
"if",
"(",
"typeof",
"c",
"!==",
"'object'",
"||",
"c",
".",
"require",
")",
"{",
"return",
"c",
";",
"}",
"... | getUserMedia constraints shim. | [
"getUserMedia",
"constraints",
"shim",
"."
] | 5ea69776f319fab15a784f94db91a2c1f5154ef5 | https://github.com/priologic/easyrtc/blob/5ea69776f319fab15a784f94db91a2c1f5154ef5/api/easyrtc.js#L4791-L4849 | train | |
priologic/easyrtc | api/easyrtc.js | extractVersion | function extractVersion(uastring, expr, pos) {
var match = uastring.match(expr);
return match && match.length >= pos && parseInt(match[pos], 10);
} | javascript | function extractVersion(uastring, expr, pos) {
var match = uastring.match(expr);
return match && match.length >= pos && parseInt(match[pos], 10);
} | [
"function",
"extractVersion",
"(",
"uastring",
",",
"expr",
",",
"pos",
")",
"{",
"var",
"match",
"=",
"uastring",
".",
"match",
"(",
"expr",
")",
";",
"return",
"match",
"&&",
"match",
".",
"length",
">=",
"pos",
"&&",
"parseInt",
"(",
"match",
"[",
... | Extract browser version out of the provided user agent string.
@param {!string} uastring userAgent string.
@param {!string} expr Regular expression used as match criteria.
@param {!number} pos position in the version string to be returned.
@return {!number} browser version. | [
"Extract",
"browser",
"version",
"out",
"of",
"the",
"provided",
"user",
"agent",
"string",
"."
] | 5ea69776f319fab15a784f94db91a2c1f5154ef5 | https://github.com/priologic/easyrtc/blob/5ea69776f319fab15a784f94db91a2c1f5154ef5/api/easyrtc.js#L5300-L5303 | train |
priologic/easyrtc | api/easyrtc.js | function(window) {
var navigator = window && window.navigator;
// Returned result object.
var result = {};
result.browser = null;
result.version = null;
// Fail early if it's not a browser
if (typeof window === 'undefined' || !window.navigator) {
result.browser = 'Not a browser.';
... | javascript | function(window) {
var navigator = window && window.navigator;
// Returned result object.
var result = {};
result.browser = null;
result.version = null;
// Fail early if it's not a browser
if (typeof window === 'undefined' || !window.navigator) {
result.browser = 'Not a browser.';
... | [
"function",
"(",
"window",
")",
"{",
"var",
"navigator",
"=",
"window",
"&&",
"window",
".",
"navigator",
";",
"// Returned result object.",
"var",
"result",
"=",
"{",
"}",
";",
"result",
".",
"browser",
"=",
"null",
";",
"result",
".",
"version",
"=",
"... | Browser detector.
@return {object} result containing browser and version
properties. | [
"Browser",
"detector",
"."
] | 5ea69776f319fab15a784f94db91a2c1f5154ef5 | https://github.com/priologic/easyrtc/blob/5ea69776f319fab15a784f94db91a2c1f5154ef5/api/easyrtc.js#L5417-L5457 | train | |
priologic/easyrtc | api/easyrtc.js | addStreamToPeerConnection | function addStreamToPeerConnection(stream, peerConnection) {
if( peerConnection.addStream ) {
var existingStreams = peerConnection.getLocalStreams();
if (existingStreams.indexOf(stream) === -1) {
peerConnection.addStream(stream);
}
}
else {
v... | javascript | function addStreamToPeerConnection(stream, peerConnection) {
if( peerConnection.addStream ) {
var existingStreams = peerConnection.getLocalStreams();
if (existingStreams.indexOf(stream) === -1) {
peerConnection.addStream(stream);
}
}
else {
v... | [
"function",
"addStreamToPeerConnection",
"(",
"stream",
",",
"peerConnection",
")",
"{",
"if",
"(",
"peerConnection",
".",
"addStream",
")",
"{",
"var",
"existingStreams",
"=",
"peerConnection",
".",
"getLocalStreams",
"(",
")",
";",
"if",
"(",
"existingStreams",
... | this private method handles adding a stream to a peer connection. chrome only supports adding streams, safari only supports adding tracks. | [
"this",
"private",
"method",
"handles",
"adding",
"a",
"stream",
"to",
"a",
"peer",
"connection",
".",
"chrome",
"only",
"supports",
"adding",
"streams",
"safari",
"only",
"supports",
"adding",
"tracks",
"."
] | 5ea69776f319fab15a784f94db91a2c1f5154ef5 | https://github.com/priologic/easyrtc/blob/5ea69776f319fab15a784f94db91a2c1f5154ef5/api/easyrtc.js#L5731-L5754 | train |
priologic/easyrtc | api/easyrtc.js | isSocketConnected | function isSocketConnected(socket) {
return socket && (
(socket.socket && socket.socket.connected) || socket.connected
);
} | javascript | function isSocketConnected(socket) {
return socket && (
(socket.socket && socket.socket.connected) || socket.connected
);
} | [
"function",
"isSocketConnected",
"(",
"socket",
")",
"{",
"return",
"socket",
"&&",
"(",
"(",
"socket",
".",
"socket",
"&&",
"socket",
".",
"socket",
".",
"connected",
")",
"||",
"socket",
".",
"connected",
")",
";",
"}"
] | This function checks if a socket is actually connected.
@private
@param {Object} socket a socket.io socket.
@return true if the socket exists and is connected, false otherwise. | [
"This",
"function",
"checks",
"if",
"a",
"socket",
"is",
"actually",
"connected",
"."
] | 5ea69776f319fab15a784f94db91a2c1f5154ef5 | https://github.com/priologic/easyrtc/blob/5ea69776f319fab15a784f94db91a2c1f5154ef5/api/easyrtc.js#L5804-L5808 | 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.