id int32 0 58k | repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1 value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 |
|---|---|---|---|---|---|---|---|---|---|---|---|
32,000 | dimerapp/markdown | src/transformers/relativeLinks.js | updateUrl | function updateUrl (cb, urlNode, options) {
return cb(urlNode.url, options)
.then((response) => {
if (response) {
Object.assign(urlNode, response)
}
})
.catch(() => {
})
} | javascript | function updateUrl (cb, urlNode, options) {
return cb(urlNode.url, options)
.then((response) => {
if (response) {
Object.assign(urlNode, response)
}
})
.catch(() => {
})
} | [
"function",
"updateUrl",
"(",
"cb",
",",
"urlNode",
",",
"options",
")",
"{",
"return",
"cb",
"(",
"urlNode",
".",
"url",
",",
"options",
")",
".",
"then",
"(",
"(",
"response",
")",
"=>",
"{",
"if",
"(",
"response",
")",
"{",
"Object",
".",
"assig... | Updates the url of the image or link node by calling the
callback promise
@method updateUrl
@param {Function} cb
@param {Object} urlNode
@param {Object} options
@return {Promise} | [
"Updates",
"the",
"url",
"of",
"the",
"image",
"or",
"link",
"node",
"by",
"calling",
"the",
"callback",
"promise"
] | a7cf95347be424b293931e1a0933dbd294209d7a | https://github.com/dimerapp/markdown/blob/a7cf95347be424b293931e1a0933dbd294209d7a/src/transformers/relativeLinks.js#L27-L36 |
32,001 | dimerapp/markdown | src/transformers/toc.js | getTocNode | function getTocNode (tree) {
const tocNode = toc(tree, { maxDepth: 3, loose: false })
if (!tocNode.map || !tocNode.map.children[0] || !tocNode.map.children[0].children[1]) {
return
}
return {
type: 'TocNode',
data: {
hName: 'div',
hProperties: {
className: ['toc-container']
}
},
children: [
{
type: 'TocTitleNode',
data: {
hName: 'h2'
},
children: [{ type: 'text', value: 'Table of contents' }]
},
tocNode.map.children[0].children[1]
]
}
} | javascript | function getTocNode (tree) {
const tocNode = toc(tree, { maxDepth: 3, loose: false })
if (!tocNode.map || !tocNode.map.children[0] || !tocNode.map.children[0].children[1]) {
return
}
return {
type: 'TocNode',
data: {
hName: 'div',
hProperties: {
className: ['toc-container']
}
},
children: [
{
type: 'TocTitleNode',
data: {
hName: 'h2'
},
children: [{ type: 'text', value: 'Table of contents' }]
},
tocNode.map.children[0].children[1]
]
}
} | [
"function",
"getTocNode",
"(",
"tree",
")",
"{",
"const",
"tocNode",
"=",
"toc",
"(",
"tree",
",",
"{",
"maxDepth",
":",
"3",
",",
"loose",
":",
"false",
"}",
")",
"if",
"(",
"!",
"tocNode",
".",
"map",
"||",
"!",
"tocNode",
".",
"map",
".",
"chi... | Returns the node for TOC
@method getTocNode
@param {Object} tree
@return {Object} | [
"Returns",
"the",
"node",
"for",
"TOC"
] | a7cf95347be424b293931e1a0933dbd294209d7a | https://github.com/dimerapp/markdown/blob/a7cf95347be424b293931e1a0933dbd294209d7a/src/transformers/toc.js#L23-L49 |
32,002 | curran/d3-component | src/component.js | dataArray | function dataArray(data, context) {
data = Array.isArray(data) ? data : [data];
return context ? data.map(d => Object.assign(Object.create(context), d)) : data;
} | javascript | function dataArray(data, context) {
data = Array.isArray(data) ? data : [data];
return context ? data.map(d => Object.assign(Object.create(context), d)) : data;
} | [
"function",
"dataArray",
"(",
"data",
",",
"context",
")",
"{",
"data",
"=",
"Array",
".",
"isArray",
"(",
"data",
")",
"?",
"data",
":",
"[",
"data",
"]",
";",
"return",
"context",
"?",
"data",
".",
"map",
"(",
"d",
"=>",
"Object",
".",
"assign",
... | Computes the data to pass into the data join from component invocation arguments. | [
"Computes",
"the",
"data",
"to",
"pass",
"into",
"the",
"data",
"join",
"from",
"component",
"invocation",
"arguments",
"."
] | bf620b4f6e5cd4684a1cd81a95011b490180ba50 | https://github.com/curran/d3-component/blob/bf620b4f6e5cd4684a1cd81a95011b490180ba50/src/component.js#L15-L18 |
32,003 | curran/d3-component | src/component.js | destroyDescendant | function destroyDescendant() {
const instance = getInstance(this);
if (instance) {
const {
selection, datum, destroy, index,
} = instance;
destroy(selection, datum, index);
}
} | javascript | function destroyDescendant() {
const instance = getInstance(this);
if (instance) {
const {
selection, datum, destroy, index,
} = instance;
destroy(selection, datum, index);
}
} | [
"function",
"destroyDescendant",
"(",
")",
"{",
"const",
"instance",
"=",
"getInstance",
"(",
"this",
")",
";",
"if",
"(",
"instance",
")",
"{",
"const",
"{",
"selection",
",",
"datum",
",",
"destroy",
",",
"index",
",",
"}",
"=",
"instance",
";",
"des... | Destroys a descendant component instance. Does not remove its DOM node, as one if its ancestors will be removed. | [
"Destroys",
"a",
"descendant",
"component",
"instance",
".",
"Does",
"not",
"remove",
"its",
"DOM",
"node",
"as",
"one",
"if",
"its",
"ancestors",
"will",
"be",
"removed",
"."
] | bf620b4f6e5cd4684a1cd81a95011b490180ba50 | https://github.com/curran/d3-component/blob/bf620b4f6e5cd4684a1cd81a95011b490180ba50/src/component.js#L22-L30 |
32,004 | curran/d3-component | src/component.js | destroyInstance | function destroyInstance() {
const {
selection, datum, destroy, index,
} = getInstance(this);
selection.selectAll('*').each(destroyDescendant);
const transition = destroy(selection, datum, index);
(transition || selection).remove();
} | javascript | function destroyInstance() {
const {
selection, datum, destroy, index,
} = getInstance(this);
selection.selectAll('*').each(destroyDescendant);
const transition = destroy(selection, datum, index);
(transition || selection).remove();
} | [
"function",
"destroyInstance",
"(",
")",
"{",
"const",
"{",
"selection",
",",
"datum",
",",
"destroy",
",",
"index",
",",
"}",
"=",
"getInstance",
"(",
"this",
")",
";",
"selection",
".",
"selectAll",
"(",
"'*'",
")",
".",
"each",
"(",
"destroyDescendant... | Destroys the component instance and its descendant component instances. | [
"Destroys",
"the",
"component",
"instance",
"and",
"its",
"descendant",
"component",
"instances",
"."
] | bf620b4f6e5cd4684a1cd81a95011b490180ba50 | https://github.com/curran/d3-component/blob/bf620b4f6e5cd4684a1cd81a95011b490180ba50/src/component.js#L33-L40 |
32,005 | curran/d3-component | src/component.js | createInstance | function createInstance(datum, index) {
const selection = select(this);
setInstance(this, {
component, selection, destroy, datum, index,
});
create(selection, datum, index);
} | javascript | function createInstance(datum, index) {
const selection = select(this);
setInstance(this, {
component, selection, destroy, datum, index,
});
create(selection, datum, index);
} | [
"function",
"createInstance",
"(",
"datum",
",",
"index",
")",
"{",
"const",
"selection",
"=",
"select",
"(",
"this",
")",
";",
"setInstance",
"(",
"this",
",",
"{",
"component",
",",
"selection",
",",
"destroy",
",",
"datum",
",",
"index",
",",
"}",
"... | Creates a new component instance and stores it on the DOM node. | [
"Creates",
"a",
"new",
"component",
"instance",
"and",
"stores",
"it",
"on",
"the",
"DOM",
"node",
"."
] | bf620b4f6e5cd4684a1cd81a95011b490180ba50 | https://github.com/curran/d3-component/blob/bf620b4f6e5cd4684a1cd81a95011b490180ba50/src/component.js#L65-L71 |
32,006 | curran/d3-component | src/component.js | component | function component(container, data, context) {
const selection = container.nodeName ? select(container) : container;
const instances = selection
.selectAll(mine)
.data(dataArray(data, context), key);
instances
.exit()
.each(destroyInstance);
return instances
.enter().append(tagName)
.attr('class', className)
.each(createInstance)
.merge(instances)
.each(renderInstance);
} | javascript | function component(container, data, context) {
const selection = container.nodeName ? select(container) : container;
const instances = selection
.selectAll(mine)
.data(dataArray(data, context), key);
instances
.exit()
.each(destroyInstance);
return instances
.enter().append(tagName)
.attr('class', className)
.each(createInstance)
.merge(instances)
.each(renderInstance);
} | [
"function",
"component",
"(",
"container",
",",
"data",
",",
"context",
")",
"{",
"const",
"selection",
"=",
"container",
".",
"nodeName",
"?",
"select",
"(",
"container",
")",
":",
"container",
";",
"const",
"instances",
"=",
"selection",
".",
"selectAll",
... | The returned component instance. | [
"The",
"returned",
"component",
"instance",
"."
] | bf620b4f6e5cd4684a1cd81a95011b490180ba50 | https://github.com/curran/d3-component/blob/bf620b4f6e5cd4684a1cd81a95011b490180ba50/src/component.js#L81-L95 |
32,007 | quorrajs/NodeSession | lib/SessionManager.js | SessionManager | function SessionManager(config, encrypter) {
/**
* The configuration object
*
* @var Object
* @protected
*/
this.__config = config;
/**
* The registered custom driver creators.
*
* @var Object
* @protected
*/
this.__customCreators = {};
/**
* The encrypter instance.
* An encrypter implements encrypt and decrypt methods.
*
* @var Object
* @protected
*/
this.__encrypter = encrypter;
/**
* The session database model instance
*
* @var Object
* @protected
*/
this.__sessionModel;
/**
* The memory session handler storage
* @type {null}
* @protected
*/
this.__memorySession = Object.create(null);
} | javascript | function SessionManager(config, encrypter) {
/**
* The configuration object
*
* @var Object
* @protected
*/
this.__config = config;
/**
* The registered custom driver creators.
*
* @var Object
* @protected
*/
this.__customCreators = {};
/**
* The encrypter instance.
* An encrypter implements encrypt and decrypt methods.
*
* @var Object
* @protected
*/
this.__encrypter = encrypter;
/**
* The session database model instance
*
* @var Object
* @protected
*/
this.__sessionModel;
/**
* The memory session handler storage
* @type {null}
* @protected
*/
this.__memorySession = Object.create(null);
} | [
"function",
"SessionManager",
"(",
"config",
",",
"encrypter",
")",
"{",
"/**\n * The configuration object\n *\n * @var Object\n * @protected\n */",
"this",
".",
"__config",
"=",
"config",
";",
"/**\n * The registered custom driver creators.\n *\n * @var... | Create a session manager instance.
@param {Object} config
@param {Object} [encrypter]
@constructor | [
"Create",
"a",
"session",
"manager",
"instance",
"."
] | c5f597a7a2eaf9f7c5b56fcbb338d69b048247f5 | https://github.com/quorrajs/NodeSession/blob/c5f597a7a2eaf9f7c5b56fcbb338d69b048247f5/lib/SessionManager.js#L24-L64 |
32,008 | quorrajs/NodeSession | index.js | NodeSession | function NodeSession(config, encrypter) {
var defaults = {
'driver': 'file',
'lifetime': 300000, // five minutes
'expireOnClose': false,
'files': process.cwd()+'/sessions',
'connection': false,
'table': 'sessions',
'lottery': [2, 100],
'cookie': 'node_session',
'path': '/',
'domain': null,
'secure': false,
'httpOnly': true,
'encrypt': false
};
/**
* The Session configuration
*
* @type {Object}
* @private
*/
this.__config = _.merge(defaults, config);
if(this.__config.trustProxy && !this.__config.trustProxyFn) {
this.__config.trustProxyFn = util.compileTrust(this.__config.trustProxy)
}
/**
* The session manager instance
* @type {SessionManager}
* @private
*/
this.__manager = new SessionManager(this.__config, encrypter);
if (!this.__config.secret) {
throw new Error('secret option required for sessions');
}
} | javascript | function NodeSession(config, encrypter) {
var defaults = {
'driver': 'file',
'lifetime': 300000, // five minutes
'expireOnClose': false,
'files': process.cwd()+'/sessions',
'connection': false,
'table': 'sessions',
'lottery': [2, 100],
'cookie': 'node_session',
'path': '/',
'domain': null,
'secure': false,
'httpOnly': true,
'encrypt': false
};
/**
* The Session configuration
*
* @type {Object}
* @private
*/
this.__config = _.merge(defaults, config);
if(this.__config.trustProxy && !this.__config.trustProxyFn) {
this.__config.trustProxyFn = util.compileTrust(this.__config.trustProxy)
}
/**
* The session manager instance
* @type {SessionManager}
* @private
*/
this.__manager = new SessionManager(this.__config, encrypter);
if (!this.__config.secret) {
throw new Error('secret option required for sessions');
}
} | [
"function",
"NodeSession",
"(",
"config",
",",
"encrypter",
")",
"{",
"var",
"defaults",
"=",
"{",
"'driver'",
":",
"'file'",
",",
"'lifetime'",
":",
"300000",
",",
"// five minutes",
"'expireOnClose'",
":",
"false",
",",
"'files'",
":",
"process",
".",
"cwd... | Create a new NodeSession instance
@param {Object} config - session configuration object
@param {Object | void} encrypter
@constructor | [
"Create",
"a",
"new",
"NodeSession",
"instance"
] | c5f597a7a2eaf9f7c5b56fcbb338d69b048247f5 | https://github.com/quorrajs/NodeSession/blob/c5f597a7a2eaf9f7c5b56fcbb338d69b048247f5/index.js#L23-L62 |
32,009 | azu/podspec-bump | lib/podspec-searcher.js | searchPodspecFilePath | function searchPodspecFilePath(currentDir, callback) {
var cDir = currentDir || process.cwd();// default: cwd
fs.readdir(cDir, function (err, files) {
if (err) {
return callback(err);
}
var results = files.filter(function (file) {
return path.extname(file) === '.podspec';
});
// return first filePath
if (results.length == 0) {
callback(new Error("not found podspec file"));
} else {
var filePath = results.shift();
callback(null, filePath);
}
});
} | javascript | function searchPodspecFilePath(currentDir, callback) {
var cDir = currentDir || process.cwd();// default: cwd
fs.readdir(cDir, function (err, files) {
if (err) {
return callback(err);
}
var results = files.filter(function (file) {
return path.extname(file) === '.podspec';
});
// return first filePath
if (results.length == 0) {
callback(new Error("not found podspec file"));
} else {
var filePath = results.shift();
callback(null, filePath);
}
});
} | [
"function",
"searchPodspecFilePath",
"(",
"currentDir",
",",
"callback",
")",
"{",
"var",
"cDir",
"=",
"currentDir",
"||",
"process",
".",
"cwd",
"(",
")",
";",
"// default: cwd",
"fs",
".",
"readdir",
"(",
"cDir",
",",
"function",
"(",
"err",
",",
"files"... | find podspec and return find first file path
@param currentDir
@param callback | [
"find",
"podspec",
"and",
"return",
"find",
"first",
"file",
"path"
] | 9bc2ea57592aeff2920b70437f6ebf30a67b904e | https://github.com/azu/podspec-bump/blob/9bc2ea57592aeff2920b70437f6ebf30a67b904e/lib/podspec-searcher.js#L13-L30 |
32,010 | mozillascience/software-citation-tools | CLI/argumentParser.js | getFormat | function getFormat(formatString) {
let format = formatString.toLowerCase();
if(format == 'apa' || format == 'a') {
return CitationCore.styles.apa;
}
else if(format == 'chicago' || format == 'c') {
return CitationCore.styles.chicago;
}
else if(format == 'bibtexmisc' || format == 'bm') {
return CitationCore.styles.bibtexMisc;
}
else if(format == 'bibtexsoftware' || format == 'bs'){
return CitationCore.styles.biblatexSoftware;
}
throw new Error(formatString + ' is an unsuported citation format. Try "apa" or "chicago"');
} | javascript | function getFormat(formatString) {
let format = formatString.toLowerCase();
if(format == 'apa' || format == 'a') {
return CitationCore.styles.apa;
}
else if(format == 'chicago' || format == 'c') {
return CitationCore.styles.chicago;
}
else if(format == 'bibtexmisc' || format == 'bm') {
return CitationCore.styles.bibtexMisc;
}
else if(format == 'bibtexsoftware' || format == 'bs'){
return CitationCore.styles.biblatexSoftware;
}
throw new Error(formatString + ' is an unsuported citation format. Try "apa" or "chicago"');
} | [
"function",
"getFormat",
"(",
"formatString",
")",
"{",
"let",
"format",
"=",
"formatString",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"format",
"==",
"'apa'",
"||",
"format",
"==",
"'a'",
")",
"{",
"return",
"CitationCore",
".",
"styles",
".",
"apa... | Determines the Formatter object from a string.
@param {string} formatString - The string representation of a format. For example c or 'chicago' will return the Chicago Formatter.
@return {Formatter} - The formatter for the given description.
@throws {Error} Will throw an error if a formatter is not found | [
"Determines",
"the",
"Formatter",
"object",
"from",
"a",
"string",
"."
] | 65a73c4af3cd52c0b1997abc7de21fe4d4e0fdd0 | https://github.com/mozillascience/software-citation-tools/blob/65a73c4af3cd52c0b1997abc7de21fe4d4e0fdd0/CLI/argumentParser.js#L58-L73 |
32,011 | mozillascience/software-citation-tools | CLI/argumentParser.js | parseFormat | function parseFormat(index, args, formatOptions) {
let nextValue = args.getNextValue(index);
if(nextValue != null) {
formatOptions.style = getFormat(nextValue);
return index + 2;
}
throw new Error('No format provided');
} | javascript | function parseFormat(index, args, formatOptions) {
let nextValue = args.getNextValue(index);
if(nextValue != null) {
formatOptions.style = getFormat(nextValue);
return index + 2;
}
throw new Error('No format provided');
} | [
"function",
"parseFormat",
"(",
"index",
",",
"args",
",",
"formatOptions",
")",
"{",
"let",
"nextValue",
"=",
"args",
".",
"getNextValue",
"(",
"index",
")",
";",
"if",
"(",
"nextValue",
"!=",
"null",
")",
"{",
"formatOptions",
".",
"style",
"=",
"getFo... | Parses the format flag.
@param The index | [
"Parses",
"the",
"format",
"flag",
"."
] | 65a73c4af3cd52c0b1997abc7de21fe4d4e0fdd0 | https://github.com/mozillascience/software-citation-tools/blob/65a73c4af3cd52c0b1997abc7de21fe4d4e0fdd0/CLI/argumentParser.js#L79-L87 |
32,012 | mckamey/jsonml | jsonml-html.js | getType | function getType(val) {
switch (typeof val) {
case 'object':
return !val ? NUL : (isArray(val) ? ARY : (isMarkup(val) ? RAW : ((val instanceof Date) ? VAL : OBJ)));
case 'function':
return FUN;
case 'undefined':
return NUL;
default:
return VAL;
}
} | javascript | function getType(val) {
switch (typeof val) {
case 'object':
return !val ? NUL : (isArray(val) ? ARY : (isMarkup(val) ? RAW : ((val instanceof Date) ? VAL : OBJ)));
case 'function':
return FUN;
case 'undefined':
return NUL;
default:
return VAL;
}
} | [
"function",
"getType",
"(",
"val",
")",
"{",
"switch",
"(",
"typeof",
"val",
")",
"{",
"case",
"'object'",
":",
"return",
"!",
"val",
"?",
"NUL",
":",
"(",
"isArray",
"(",
"val",
")",
"?",
"ARY",
":",
"(",
"isMarkup",
"(",
"val",
")",
"?",
"RAW",... | Determines the type of the value
@private
@param {*} val the object being tested
@return {number} | [
"Determines",
"the",
"type",
"of",
"the",
"value"
] | 16916da0cf9db226167a4cccb375ca5032daedf0 | https://github.com/mckamey/jsonml/blob/16916da0cf9db226167a4cccb375ca5032daedf0/jsonml-html.js#L292-L303 |
32,013 | mckamey/jsonml | jsonml-html.js | function(elem, name, handler) {
if (name.substr(0,2) === 'on') {
name = name.substr(2);
}
switch (typeof handler) {
case 'function':
if (elem.addEventListener) {
// DOM Level 2
elem.addEventListener(name, handler, false);
} else if (elem.attachEvent && getType(elem[name]) !== NUL) {
// IE legacy events
elem.attachEvent('on'+name, handler);
} else {
// DOM Level 0
var old = elem['on'+name] || elem[name];
elem['on'+name] = elem[name] = !isFunction(old) ? handler :
function(e) {
return (old.call(this, e) !== false) && (handler.call(this, e) !== false);
};
}
break;
case 'string':
// inline functions are DOM Level 0
/*jslint evil:true */
elem['on'+name] = new Function('event', handler);
/*jslint evil:false */
break;
}
} | javascript | function(elem, name, handler) {
if (name.substr(0,2) === 'on') {
name = name.substr(2);
}
switch (typeof handler) {
case 'function':
if (elem.addEventListener) {
// DOM Level 2
elem.addEventListener(name, handler, false);
} else if (elem.attachEvent && getType(elem[name]) !== NUL) {
// IE legacy events
elem.attachEvent('on'+name, handler);
} else {
// DOM Level 0
var old = elem['on'+name] || elem[name];
elem['on'+name] = elem[name] = !isFunction(old) ? handler :
function(e) {
return (old.call(this, e) !== false) && (handler.call(this, e) !== false);
};
}
break;
case 'string':
// inline functions are DOM Level 0
/*jslint evil:true */
elem['on'+name] = new Function('event', handler);
/*jslint evil:false */
break;
}
} | [
"function",
"(",
"elem",
",",
"name",
",",
"handler",
")",
"{",
"if",
"(",
"name",
".",
"substr",
"(",
"0",
",",
"2",
")",
"===",
"'on'",
")",
"{",
"name",
"=",
"name",
".",
"substr",
"(",
"2",
")",
";",
"}",
"switch",
"(",
"typeof",
"handler",... | Adds an event handler to an element
@private
@param {Node} elem The element
@param {string} name The event name
@param {function(Event)} handler The event handler | [
"Adds",
"an",
"event",
"handler",
"to",
"an",
"element"
] | 16916da0cf9db226167a4cccb375ca5032daedf0 | https://github.com/mckamey/jsonml/blob/16916da0cf9db226167a4cccb375ca5032daedf0/jsonml-html.js#L341-L373 | |
32,014 | mckamey/jsonml | jsonml-html.js | function(node, pattern) {
if (!!node && (node.nodeType === 3) && pattern.exec(node.nodeValue)) {
node.nodeValue = node.nodeValue.replace(pattern, '');
}
} | javascript | function(node, pattern) {
if (!!node && (node.nodeType === 3) && pattern.exec(node.nodeValue)) {
node.nodeValue = node.nodeValue.replace(pattern, '');
}
} | [
"function",
"(",
"node",
",",
"pattern",
")",
"{",
"if",
"(",
"!",
"!",
"node",
"&&",
"(",
"node",
".",
"nodeType",
"===",
"3",
")",
"&&",
"pattern",
".",
"exec",
"(",
"node",
".",
"nodeValue",
")",
")",
"{",
"node",
".",
"nodeValue",
"=",
"node"... | Trims whitespace pattern from the text node
@private
@param {Node} node The node | [
"Trims",
"whitespace",
"pattern",
"from",
"the",
"text",
"node"
] | 16916da0cf9db226167a4cccb375ca5032daedf0 | https://github.com/mckamey/jsonml/blob/16916da0cf9db226167a4cccb375ca5032daedf0/jsonml-html.js#L544-L548 | |
32,015 | mckamey/jsonml | jsonml-html.js | function(elem) {
if (elem) {
while (isWhitespace(elem.firstChild)) {
// trim leading whitespace text nodes
elem.removeChild(elem.firstChild);
}
// trim leading whitespace text
trimPattern(elem.firstChild, LEADING);
while (isWhitespace(elem.lastChild)) {
// trim trailing whitespace text nodes
elem.removeChild(elem.lastChild);
}
// trim trailing whitespace text
trimPattern(elem.lastChild, TRAILING);
}
} | javascript | function(elem) {
if (elem) {
while (isWhitespace(elem.firstChild)) {
// trim leading whitespace text nodes
elem.removeChild(elem.firstChild);
}
// trim leading whitespace text
trimPattern(elem.firstChild, LEADING);
while (isWhitespace(elem.lastChild)) {
// trim trailing whitespace text nodes
elem.removeChild(elem.lastChild);
}
// trim trailing whitespace text
trimPattern(elem.lastChild, TRAILING);
}
} | [
"function",
"(",
"elem",
")",
"{",
"if",
"(",
"elem",
")",
"{",
"while",
"(",
"isWhitespace",
"(",
"elem",
".",
"firstChild",
")",
")",
"{",
"// trim leading whitespace text nodes\r",
"elem",
".",
"removeChild",
"(",
"elem",
".",
"firstChild",
")",
";",
"}... | Removes leading and trailing whitespace nodes
@private
@param {Node} elem The node | [
"Removes",
"leading",
"and",
"trailing",
"whitespace",
"nodes"
] | 16916da0cf9db226167a4cccb375ca5032daedf0 | https://github.com/mckamey/jsonml/blob/16916da0cf9db226167a4cccb375ca5032daedf0/jsonml-html.js#L556-L571 | |
32,016 | mckamey/jsonml | jsonml-html.js | function(value) {
var wrapper = createElement('div');
wrapper.innerHTML = ''+value;
// trim extraneous whitespace
trimWhitespace(wrapper);
// eliminate wrapper for single nodes
if (wrapper.childNodes.length === 1) {
return wrapper.firstChild;
}
// create a document fragment to hold elements
var frag = createElement('');
while (wrapper.firstChild) {
frag.appendChild(wrapper.firstChild);
}
return frag;
} | javascript | function(value) {
var wrapper = createElement('div');
wrapper.innerHTML = ''+value;
// trim extraneous whitespace
trimWhitespace(wrapper);
// eliminate wrapper for single nodes
if (wrapper.childNodes.length === 1) {
return wrapper.firstChild;
}
// create a document fragment to hold elements
var frag = createElement('');
while (wrapper.firstChild) {
frag.appendChild(wrapper.firstChild);
}
return frag;
} | [
"function",
"(",
"value",
")",
"{",
"var",
"wrapper",
"=",
"createElement",
"(",
"'div'",
")",
";",
"wrapper",
".",
"innerHTML",
"=",
"''",
"+",
"value",
";",
"// trim extraneous whitespace\r",
"trimWhitespace",
"(",
"wrapper",
")",
";",
"// eliminate wrapper fo... | Converts the markup to DOM nodes
@private
@param {string|Markup} value The node
@return {Node} | [
"Converts",
"the",
"markup",
"to",
"DOM",
"nodes"
] | 16916da0cf9db226167a4cccb375ca5032daedf0 | https://github.com/mckamey/jsonml/blob/16916da0cf9db226167a4cccb375ca5032daedf0/jsonml-html.js#L580-L598 | |
32,017 | mattdesl/keytime | demo/dom/index.js | toggle | function toggle(ev) {
if (ev)
ev.preventDefault()
autoTime = 0
autoPlay = true
curTimeline = curTimeline === anim1 ? anim2 : anim1
duration = curTimeline.duration()
//clear style
widget.element.style.cssText = ''
editor.show(curTimeline === anim1 ? 0 : 1)
editor.hide(curTimeline === anim1 ? 1 : 0)
} | javascript | function toggle(ev) {
if (ev)
ev.preventDefault()
autoTime = 0
autoPlay = true
curTimeline = curTimeline === anim1 ? anim2 : anim1
duration = curTimeline.duration()
//clear style
widget.element.style.cssText = ''
editor.show(curTimeline === anim1 ? 0 : 1)
editor.hide(curTimeline === anim1 ? 1 : 0)
} | [
"function",
"toggle",
"(",
"ev",
")",
"{",
"if",
"(",
"ev",
")",
"ev",
".",
"preventDefault",
"(",
")",
"autoTime",
"=",
"0",
"autoPlay",
"=",
"true",
"curTimeline",
"=",
"curTimeline",
"===",
"anim1",
"?",
"anim2",
":",
"anim1",
"duration",
"=",
"curT... | toggle new timeline | [
"toggle",
"new",
"timeline"
] | 7b09e6a42c7b2e00d1af8b2aac97d04235fda5e5 | https://github.com/mattdesl/keytime/blob/7b09e6a42c7b2e00d1af8b2aac97d04235fda5e5/demo/dom/index.js#L70-L84 |
32,018 | M-Ulyanov/ImageComparison | src/ImageComparison.js | incrementPosition | function incrementPosition() {
comparison._animateInterval = setInterval(function () {
currentPositionInPercent++;
comparison._updatePosition(currentPositionInPercent);
if (currentPositionInPercent >= newPositionInPercent) {
setFinalPositionAndClearInterval();
}
}, 10);
} | javascript | function incrementPosition() {
comparison._animateInterval = setInterval(function () {
currentPositionInPercent++;
comparison._updatePosition(currentPositionInPercent);
if (currentPositionInPercent >= newPositionInPercent) {
setFinalPositionAndClearInterval();
}
}, 10);
} | [
"function",
"incrementPosition",
"(",
")",
"{",
"comparison",
".",
"_animateInterval",
"=",
"setInterval",
"(",
"function",
"(",
")",
"{",
"currentPositionInPercent",
"++",
";",
"comparison",
".",
"_updatePosition",
"(",
"currentPositionInPercent",
")",
";",
"if",
... | Support animate functions | [
"Support",
"animate",
"functions"
] | 9128f409fbb2a6396681a4b752d900e46aa9c041 | https://github.com/M-Ulyanov/ImageComparison/blob/9128f409fbb2a6396681a4b752d900e46aa9c041/src/ImageComparison.js#L183-L191 |
32,019 | M-Ulyanov/ImageComparison | src/ImageComparison.js | function (target, objects, options) {
for (var object in objects) {
if (objects.hasOwnProperty(object)) {
recursiveMerge(target, objects[object]);
}
}
function recursiveMerge(target, object) {
for (var property in object) {
if (object.hasOwnProperty(property)) {
var current = object[property];
if (utils.getConstructor(current) === 'Object') {
if (!target[property]) {
target[property] = {};
}
recursiveMerge(target[property], current);
}
else {
// clearEmpty
if (options.clearEmpty) {
if (current == null) {
continue;
}
}
target[property] = current;
}
}
}
}
return target;
} | javascript | function (target, objects, options) {
for (var object in objects) {
if (objects.hasOwnProperty(object)) {
recursiveMerge(target, objects[object]);
}
}
function recursiveMerge(target, object) {
for (var property in object) {
if (object.hasOwnProperty(property)) {
var current = object[property];
if (utils.getConstructor(current) === 'Object') {
if (!target[property]) {
target[property] = {};
}
recursiveMerge(target[property], current);
}
else {
// clearEmpty
if (options.clearEmpty) {
if (current == null) {
continue;
}
}
target[property] = current;
}
}
}
}
return target;
} | [
"function",
"(",
"target",
",",
"objects",
",",
"options",
")",
"{",
"for",
"(",
"var",
"object",
"in",
"objects",
")",
"{",
"if",
"(",
"objects",
".",
"hasOwnProperty",
"(",
"object",
")",
")",
"{",
"recursiveMerge",
"(",
"target",
",",
"objects",
"["... | Native extend object
@param target
@param objects
@param options
@returns {*} | [
"Native",
"extend",
"object"
] | 9128f409fbb2a6396681a4b752d900e46aa9c041 | https://github.com/M-Ulyanov/ImageComparison/blob/9128f409fbb2a6396681a4b752d900e46aa9c041/src/ImageComparison.js#L244-L276 | |
32,020 | M-Ulyanov/ImageComparison | src/ImageComparison.js | function (element, events, func) {
for (var i = 0; i < events.length; i++) {
element.addEventListener(events[i], func);
}
} | javascript | function (element, events, func) {
for (var i = 0; i < events.length; i++) {
element.addEventListener(events[i], func);
}
} | [
"function",
"(",
"element",
",",
"events",
",",
"func",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"events",
".",
"length",
";",
"i",
"++",
")",
"{",
"element",
".",
"addEventListener",
"(",
"events",
"[",
"i",
"]",
",",
"func",
... | Set Multi addEventListener
@param element
@param events
@param func | [
"Set",
"Multi",
"addEventListener"
] | 9128f409fbb2a6396681a4b752d900e46aa9c041 | https://github.com/M-Ulyanov/ImageComparison/blob/9128f409fbb2a6396681a4b752d900e46aa9c041/src/ImageComparison.js#L285-L289 | |
32,021 | Matt-Esch/vtree | diff.js | destroyWidgets | function destroyWidgets(vNode, patch, index) {
if (isWidget(vNode)) {
if (typeof vNode.destroy === "function") {
patch[index] = new VPatch(VPatch.REMOVE, vNode, null)
}
} else if (isVNode(vNode) && (vNode.hasWidgets || vNode.hasThunks)) {
var children = vNode.children
var len = children.length
for (var i = 0; i < len; i++) {
var child = children[i]
index += 1
destroyWidgets(child, patch, index)
if (isVNode(child) && child.count) {
index += child.count
}
}
} else if (isThunk(vNode)) {
thunks(vNode, null, patch, index)
}
} | javascript | function destroyWidgets(vNode, patch, index) {
if (isWidget(vNode)) {
if (typeof vNode.destroy === "function") {
patch[index] = new VPatch(VPatch.REMOVE, vNode, null)
}
} else if (isVNode(vNode) && (vNode.hasWidgets || vNode.hasThunks)) {
var children = vNode.children
var len = children.length
for (var i = 0; i < len; i++) {
var child = children[i]
index += 1
destroyWidgets(child, patch, index)
if (isVNode(child) && child.count) {
index += child.count
}
}
} else if (isThunk(vNode)) {
thunks(vNode, null, patch, index)
}
} | [
"function",
"destroyWidgets",
"(",
"vNode",
",",
"patch",
",",
"index",
")",
"{",
"if",
"(",
"isWidget",
"(",
"vNode",
")",
")",
"{",
"if",
"(",
"typeof",
"vNode",
".",
"destroy",
"===",
"\"function\"",
")",
"{",
"patch",
"[",
"index",
"]",
"=",
"new... | Patch records for all destroyed widgets must be added because we need a DOM node reference for the destroy function | [
"Patch",
"records",
"for",
"all",
"destroyed",
"widgets",
"must",
"be",
"added",
"because",
"we",
"need",
"a",
"DOM",
"node",
"reference",
"for",
"the",
"destroy",
"function"
] | edd6b3c236b48742b5a89c87621a2c651e75eb71 | https://github.com/Matt-Esch/vtree/blob/edd6b3c236b48742b5a89c87621a2c651e75eb71/diff.js#L167-L188 |
32,022 | Matt-Esch/vtree | diff.js | thunks | function thunks(a, b, patch, index) {
var nodes = handleThunk(a, b);
var thunkPatch = diff(nodes.a, nodes.b)
if (hasPatches(thunkPatch)) {
patch[index] = new VPatch(VPatch.THUNK, null, thunkPatch)
}
} | javascript | function thunks(a, b, patch, index) {
var nodes = handleThunk(a, b);
var thunkPatch = diff(nodes.a, nodes.b)
if (hasPatches(thunkPatch)) {
patch[index] = new VPatch(VPatch.THUNK, null, thunkPatch)
}
} | [
"function",
"thunks",
"(",
"a",
",",
"b",
",",
"patch",
",",
"index",
")",
"{",
"var",
"nodes",
"=",
"handleThunk",
"(",
"a",
",",
"b",
")",
";",
"var",
"thunkPatch",
"=",
"diff",
"(",
"nodes",
".",
"a",
",",
"nodes",
".",
"b",
")",
"if",
"(",
... | Create a sub-patch for thunks | [
"Create",
"a",
"sub",
"-",
"patch",
"for",
"thunks"
] | edd6b3c236b48742b5a89c87621a2c651e75eb71 | https://github.com/Matt-Esch/vtree/blob/edd6b3c236b48742b5a89c87621a2c651e75eb71/diff.js#L191-L197 |
32,023 | neoziro/std-mocks | index.js | use | function use(options) {
options = _.defaults(options || {}, {
stdout: true,
stderr: true,
print: false
});
if (options.stdout)
wrapWrite('stdout', options.print);
if (options.stderr)
wrapWrite('stderr', options.print);
} | javascript | function use(options) {
options = _.defaults(options || {}, {
stdout: true,
stderr: true,
print: false
});
if (options.stdout)
wrapWrite('stdout', options.print);
if (options.stderr)
wrapWrite('stderr', options.print);
} | [
"function",
"use",
"(",
"options",
")",
"{",
"options",
"=",
"_",
".",
"defaults",
"(",
"options",
"||",
"{",
"}",
",",
"{",
"stdout",
":",
"true",
",",
"stderr",
":",
"true",
",",
"print",
":",
"false",
"}",
")",
";",
"if",
"(",
"options",
".",
... | Start mocking std output.
@param {object} [options] Options
@param {boolean} [options.stdout=true] Mock stdout
@param {boolean} [options.stderr=true] Mock stderr
@param {boolean} [options.print=false] Also print to std | [
"Start",
"mocking",
"std",
"output",
"."
] | d7e4e310c2e24e1835b5c408eec70009c9c3a1a6 | https://github.com/neoziro/std-mocks/blob/d7e4e310c2e24e1835b5c408eec70009c9c3a1a6/index.js#L36-L48 |
32,024 | neoziro/std-mocks | index.js | wrapWrite | function wrapWrite(std, print) {
process[std].write = function (data) {
cachedData[std].push(data);
if (print)
originalWrites[std].apply(process[std], arguments);
};
} | javascript | function wrapWrite(std, print) {
process[std].write = function (data) {
cachedData[std].push(data);
if (print)
originalWrites[std].apply(process[std], arguments);
};
} | [
"function",
"wrapWrite",
"(",
"std",
",",
"print",
")",
"{",
"process",
"[",
"std",
"]",
".",
"write",
"=",
"function",
"(",
"data",
")",
"{",
"cachedData",
"[",
"std",
"]",
".",
"push",
"(",
"data",
")",
";",
"if",
"(",
"print",
")",
"originalWrit... | Wrap write method.
@param {string} std Std
@param {boolean} print Also print to std | [
"Wrap",
"write",
"method",
"."
] | d7e4e310c2e24e1835b5c408eec70009c9c3a1a6 | https://github.com/neoziro/std-mocks/blob/d7e4e310c2e24e1835b5c408eec70009c9c3a1a6/index.js#L57-L64 |
32,025 | neoziro/std-mocks | index.js | restore | function restore(options) {
options = _.defaults(options || {}, {
stdout: true,
stderr: true
});
if (options.stdout)
process.stdout.write = originalWrites.stdout;
if (options.stderr)
process.stderr.write = originalWrites.stderr;
} | javascript | function restore(options) {
options = _.defaults(options || {}, {
stdout: true,
stderr: true
});
if (options.stdout)
process.stdout.write = originalWrites.stdout;
if (options.stderr)
process.stderr.write = originalWrites.stderr;
} | [
"function",
"restore",
"(",
"options",
")",
"{",
"options",
"=",
"_",
".",
"defaults",
"(",
"options",
"||",
"{",
"}",
",",
"{",
"stdout",
":",
"true",
",",
"stderr",
":",
"true",
"}",
")",
";",
"if",
"(",
"options",
".",
"stdout",
")",
"process",
... | Restore std output.
@param {object} [options] Options
@param {boolean} [options.stdout=true] Mock stdout
@param {boolean} [options.stderr=true] Mock stderr | [
"Restore",
"std",
"output",
"."
] | d7e4e310c2e24e1835b5c408eec70009c9c3a1a6 | https://github.com/neoziro/std-mocks/blob/d7e4e310c2e24e1835b5c408eec70009c9c3a1a6/index.js#L74-L85 |
32,026 | neoziro/std-mocks | index.js | flush | function flush(options) {
options = _.defaults(options || {}, {
stdout: true,
stderr: true
});
var flushed = {};
if (options.stdout) {
flushed.stdout = cachedData.stdout;
cachedData.stdout = [];
}
if (options.stderr) {
flushed.stderr = cachedData.stderr;
cachedData.stderr = [];
}
return flushed;
} | javascript | function flush(options) {
options = _.defaults(options || {}, {
stdout: true,
stderr: true
});
var flushed = {};
if (options.stdout) {
flushed.stdout = cachedData.stdout;
cachedData.stdout = [];
}
if (options.stderr) {
flushed.stderr = cachedData.stderr;
cachedData.stderr = [];
}
return flushed;
} | [
"function",
"flush",
"(",
"options",
")",
"{",
"options",
"=",
"_",
".",
"defaults",
"(",
"options",
"||",
"{",
"}",
",",
"{",
"stdout",
":",
"true",
",",
"stderr",
":",
"true",
"}",
")",
";",
"var",
"flushed",
"=",
"{",
"}",
";",
"if",
"(",
"o... | Flush collected data.
@param {object} [options] Options
@param {boolean} [options.stdout=true] Mock stdout
@param {boolean} [options.stderr=true] Mock stderr
@returns {object} Object containing two array corresponding to outputs. | [
"Flush",
"collected",
"data",
"."
] | d7e4e310c2e24e1835b5c408eec70009c9c3a1a6 | https://github.com/neoziro/std-mocks/blob/d7e4e310c2e24e1835b5c408eec70009c9c3a1a6/index.js#L96-L115 |
32,027 | JSONScript/jsonscript-js | lib/instruction_keywords.js | eval$ref | function eval$ref(params, dataPath) {
dataPath = dataPath.replace(this.refPrefixRegexp, '');
var $ref = params.$ref;
if ($ref.indexOf('0/') == 0) throw new Error('Cannot reference the same $ref instruction or child');
var pathParsed = pointer.parse(dataPath);
var absPointerParsed = util.toAbsolutePointer($ref, pathParsed);
// N# pointer returns property/index
if (typeof absPointerParsed == 'string') return absPointerParsed;
if (!absPointerParsed) absPointerParsed = pointer.parse($ref);
var i = 0; // find the root to be evaluated
while (i < pathParsed.length
&& pathParsed[i] == absPointerParsed[i]) i++;
if (i == pathParsed.length) throw new Error('Cannot reference the same $ref instruction or child');
if (!isNaN(pathParsed[i]) && !isNaN(absPointerParsed[i]) && absPointerParsed[i] > pathParsed[i])
throw new Error('cannot reference the next item from the previous item');
var rootPointerParsed = absPointerParsed.slice(0, i+1);
var rootPointer = pointer.compile(rootPointerParsed);
var pointerFromRoot = pointer.compile(absPointerParsed.slice(i+1));
if (this.evaluatedRefs[rootPointer])
return getRefValue(this.script, rootPointer, pointerFromRoot);
var self = this;
var pendingRef = self.pendingRefs[rootPointer]
= self.pendingRefs[rootPointer] || new PendingRef(rootPointer);
return new Promise(function (resolve, reject) {
pendingRef.addCallback(function () {
resolve(getRefValue(self.script, rootPointer, pointerFromRoot));
});
});
} | javascript | function eval$ref(params, dataPath) {
dataPath = dataPath.replace(this.refPrefixRegexp, '');
var $ref = params.$ref;
if ($ref.indexOf('0/') == 0) throw new Error('Cannot reference the same $ref instruction or child');
var pathParsed = pointer.parse(dataPath);
var absPointerParsed = util.toAbsolutePointer($ref, pathParsed);
// N# pointer returns property/index
if (typeof absPointerParsed == 'string') return absPointerParsed;
if (!absPointerParsed) absPointerParsed = pointer.parse($ref);
var i = 0; // find the root to be evaluated
while (i < pathParsed.length
&& pathParsed[i] == absPointerParsed[i]) i++;
if (i == pathParsed.length) throw new Error('Cannot reference the same $ref instruction or child');
if (!isNaN(pathParsed[i]) && !isNaN(absPointerParsed[i]) && absPointerParsed[i] > pathParsed[i])
throw new Error('cannot reference the next item from the previous item');
var rootPointerParsed = absPointerParsed.slice(0, i+1);
var rootPointer = pointer.compile(rootPointerParsed);
var pointerFromRoot = pointer.compile(absPointerParsed.slice(i+1));
if (this.evaluatedRefs[rootPointer])
return getRefValue(this.script, rootPointer, pointerFromRoot);
var self = this;
var pendingRef = self.pendingRefs[rootPointer]
= self.pendingRefs[rootPointer] || new PendingRef(rootPointer);
return new Promise(function (resolve, reject) {
pendingRef.addCallback(function () {
resolve(getRefValue(self.script, rootPointer, pointerFromRoot));
});
});
} | [
"function",
"eval$ref",
"(",
"params",
",",
"dataPath",
")",
"{",
"dataPath",
"=",
"dataPath",
".",
"replace",
"(",
"this",
".",
"refPrefixRegexp",
",",
"''",
")",
";",
"var",
"$ref",
"=",
"params",
".",
"$ref",
";",
"if",
"(",
"$ref",
".",
"indexOf",
... | resolve reference to the current script
@this Evaluation
@param {Object} params instruction keywords ($ref)
@param {String} dataPath current path (JSON pointer)
@return {Promise|Any} reolved reference | [
"resolve",
"reference",
"to",
"the",
"current",
"script"
] | 4b17d7f263b8db928d2e8fe3e3d828550d07cafc | https://github.com/JSONScript/jsonscript-js/blob/4b17d7f263b8db928d2e8fe3e3d828550d07cafc/lib/instruction_keywords.js#L48-L83 |
32,028 | JSONScript/jsonscript-js | lib/jsonscript.js | addInstruction | function addInstruction(definition, keywordFunc, _regenerateSchemas) {
var valid = this._validateInstruction(definition);
if (!valid) throw new Ajv.ValidationError(this._validateInstruction.errors);
// TODO check instruction is unique
this._instructions.push(definition);
var keyword = definition.evaluate.validatorKeyword;
this._evalKeywords[keyword] = keywordFunc;
addAjvKeyword.call(this, keyword, 'object', true);
if (_regenerateSchemas !== false) generateSchemas();
} | javascript | function addInstruction(definition, keywordFunc, _regenerateSchemas) {
var valid = this._validateInstruction(definition);
if (!valid) throw new Ajv.ValidationError(this._validateInstruction.errors);
// TODO check instruction is unique
this._instructions.push(definition);
var keyword = definition.evaluate.validatorKeyword;
this._evalKeywords[keyword] = keywordFunc;
addAjvKeyword.call(this, keyword, 'object', true);
if (_regenerateSchemas !== false) generateSchemas();
} | [
"function",
"addInstruction",
"(",
"definition",
",",
"keywordFunc",
",",
"_regenerateSchemas",
")",
"{",
"var",
"valid",
"=",
"this",
".",
"_validateInstruction",
"(",
"definition",
")",
";",
"if",
"(",
"!",
"valid",
")",
"throw",
"new",
"Ajv",
".",
"Valida... | add JSONScript instruction to the interpreter
@this JSONScript
@param {Object} definition instruction definition, should be valid according to the schema http://www.jsonscript.org/schema/instruction.json#
@param {Function} keywordFunc function to implement the instruction, accepts instruction object and dataPath as parameter, should return sync/async value or Script instance
@param {Boolean} _regenerateSchemas pass false to prevent regenerating the schemas, can be used when multiple instructions are added | [
"add",
"JSONScript",
"instruction",
"to",
"the",
"interpreter"
] | 4b17d7f263b8db928d2e8fe3e3d828550d07cafc | https://github.com/JSONScript/jsonscript-js/blob/4b17d7f263b8db928d2e8fe3e3d828550d07cafc/lib/jsonscript.js#L103-L112 |
32,029 | JSONScript/jsonscript-js | lib/jsonscript.js | addMacro | function addMacro(definition, _regenerateSchemas) {
var valid = this._validateMacro(definition);
if (!valid) throw new Ajv.ValidationError(this._validateMacro.errors);
// TODO check macro is unique
this._macros.push(definition);
if (_regenerateSchemas !== false) generateSchemas();
} | javascript | function addMacro(definition, _regenerateSchemas) {
var valid = this._validateMacro(definition);
if (!valid) throw new Ajv.ValidationError(this._validateMacro.errors);
// TODO check macro is unique
this._macros.push(definition);
if (_regenerateSchemas !== false) generateSchemas();
} | [
"function",
"addMacro",
"(",
"definition",
",",
"_regenerateSchemas",
")",
"{",
"var",
"valid",
"=",
"this",
".",
"_validateMacro",
"(",
"definition",
")",
";",
"if",
"(",
"!",
"valid",
")",
"throw",
"new",
"Ajv",
".",
"ValidationError",
"(",
"this",
".",
... | add JSONScript macro to the interpreter
@this JSONScript
@param {Object} definition macro definition, should be valid according to the schema http://www.jsonscript.org/schema/macro.json#
@param {Boolean} _regenerateSchemas pass false to prevent regenerating the schemas, can be used when multiple macros are added | [
"add",
"JSONScript",
"macro",
"to",
"the",
"interpreter"
] | 4b17d7f263b8db928d2e8fe3e3d828550d07cafc | https://github.com/JSONScript/jsonscript-js/blob/4b17d7f263b8db928d2e8fe3e3d828550d07cafc/lib/jsonscript.js#L121-L127 |
32,030 | JSONScript/jsonscript-js | lib/jsonscript.js | addExecutor | function addExecutor(name, executor) {
if (this._executors[name]) throw new Error('executor "' + name + '" is already defined');
this._executors[name] = executor;
} | javascript | function addExecutor(name, executor) {
if (this._executors[name]) throw new Error('executor "' + name + '" is already defined');
this._executors[name] = executor;
} | [
"function",
"addExecutor",
"(",
"name",
",",
"executor",
")",
"{",
"if",
"(",
"this",
".",
"_executors",
"[",
"name",
"]",
")",
"throw",
"new",
"Error",
"(",
"'executor \"'",
"+",
"name",
"+",
"'\" is already defined'",
")",
";",
"this",
".",
"_executors",... | add external executor to JSONScript interpreter
@this JSONScript
@param {String} name executor name to use in $exec keyword
@param {Object|Function} executor executor object or function | [
"add",
"external",
"executor",
"to",
"JSONScript",
"interpreter"
] | 4b17d7f263b8db928d2e8fe3e3d828550d07cafc | https://github.com/JSONScript/jsonscript-js/blob/4b17d7f263b8db928d2e8fe3e3d828550d07cafc/lib/jsonscript.js#L136-L139 |
32,031 | JSONScript/jsonscript-js | lib/jsonscript.js | addAjvKeywords | function addAjvKeywords() {
addAjvKeyword.call(this, 'validateAsync');
addAjvKeyword.call(this, 'itemsSerial', 'array');
this._evalKeywords.objectToAsync = util.objectToPromise;
this._evalKeywords.valueToAsync = util.toPromise;
addAjvKeyword.call(this, 'objectToAsync', 'object', true);
addAjvKeyword.call(this, 'valueToAsync', undefined, true);
this.ajv.addKeyword('resolvePendingRefs', {
validate: evaluationKeywords.resolvePendingRefs,
schema: false
});
this.ajv.addKeyword('expandJsMacro', {
compile: compileExpandJsMacro
});
} | javascript | function addAjvKeywords() {
addAjvKeyword.call(this, 'validateAsync');
addAjvKeyword.call(this, 'itemsSerial', 'array');
this._evalKeywords.objectToAsync = util.objectToPromise;
this._evalKeywords.valueToAsync = util.toPromise;
addAjvKeyword.call(this, 'objectToAsync', 'object', true);
addAjvKeyword.call(this, 'valueToAsync', undefined, true);
this.ajv.addKeyword('resolvePendingRefs', {
validate: evaluationKeywords.resolvePendingRefs,
schema: false
});
this.ajv.addKeyword('expandJsMacro', {
compile: compileExpandJsMacro
});
} | [
"function",
"addAjvKeywords",
"(",
")",
"{",
"addAjvKeyword",
".",
"call",
"(",
"this",
",",
"'validateAsync'",
")",
";",
"addAjvKeyword",
".",
"call",
"(",
"this",
",",
"'itemsSerial'",
",",
"'array'",
")",
";",
"this",
".",
"_evalKeywords",
".",
"objectToA... | private function to add Ajv keywords that are used in the schema that evaluates scripts
@this JSONScript | [
"private",
"function",
"to",
"add",
"Ajv",
"keywords",
"that",
"are",
"used",
"in",
"the",
"schema",
"that",
"evaluates",
"scripts"
] | 4b17d7f263b8db928d2e8fe3e3d828550d07cafc | https://github.com/JSONScript/jsonscript-js/blob/4b17d7f263b8db928d2e8fe3e3d828550d07cafc/lib/jsonscript.js#L156-L170 |
32,032 | JSONScript/jsonscript-js | lib/jsonscript.js | addCoreInstructions | function addCoreInstructions() {
this._validateInstruction = this.ajv.compile(require('jsonscript/schema/instruction.json'));
coreInstructions.forEach(function (inst) {
this.addInstruction(inst, instructionKeywords[inst.evaluate.validatorKeyword], false);
}, this);
} | javascript | function addCoreInstructions() {
this._validateInstruction = this.ajv.compile(require('jsonscript/schema/instruction.json'));
coreInstructions.forEach(function (inst) {
this.addInstruction(inst, instructionKeywords[inst.evaluate.validatorKeyword], false);
}, this);
} | [
"function",
"addCoreInstructions",
"(",
")",
"{",
"this",
".",
"_validateInstruction",
"=",
"this",
".",
"ajv",
".",
"compile",
"(",
"require",
"(",
"'jsonscript/schema/instruction.json'",
")",
")",
";",
"coreInstructions",
".",
"forEach",
"(",
"function",
"(",
... | private function to add all standard JSONScript instructions to the interpreter
@this JSONScript | [
"private",
"function",
"to",
"add",
"all",
"standard",
"JSONScript",
"instructions",
"to",
"the",
"interpreter"
] | 4b17d7f263b8db928d2e8fe3e3d828550d07cafc | https://github.com/JSONScript/jsonscript-js/blob/4b17d7f263b8db928d2e8fe3e3d828550d07cafc/lib/jsonscript.js#L195-L200 |
32,033 | JSONScript/jsonscript-js | lib/jsonscript.js | addCoreMacros | function addCoreMacros() {
this._validateMacro = this.ajv.compile(require('jsonscript/schema/macro.json'));
coreMacros.forEach(function (macro) {
this.addMacro(macro, false);
}, this);
} | javascript | function addCoreMacros() {
this._validateMacro = this.ajv.compile(require('jsonscript/schema/macro.json'));
coreMacros.forEach(function (macro) {
this.addMacro(macro, false);
}, this);
} | [
"function",
"addCoreMacros",
"(",
")",
"{",
"this",
".",
"_validateMacro",
"=",
"this",
".",
"ajv",
".",
"compile",
"(",
"require",
"(",
"'jsonscript/schema/macro.json'",
")",
")",
";",
"coreMacros",
".",
"forEach",
"(",
"function",
"(",
"macro",
")",
"{",
... | private function to add all core JSONScript macros to the interpreter
@this JSONScript | [
"private",
"function",
"to",
"add",
"all",
"core",
"JSONScript",
"macros",
"to",
"the",
"interpreter"
] | 4b17d7f263b8db928d2e8fe3e3d828550d07cafc | https://github.com/JSONScript/jsonscript-js/blob/4b17d7f263b8db928d2e8fe3e3d828550d07cafc/lib/jsonscript.js#L217-L222 |
32,034 | JSONScript/jsonscript-js | lib/jsonscript.js | generateSchemas | function generateSchemas() {
// this.ajv.addMetaSchema(_generate.call(this, 'evaluate_metaschema'));
this._validate = this.ajv.compile(_generate.call(this, 'schema'));
this._expandMacros = this.ajv.compile(_generate.call(this, 'expand_macros'));
this._evaluate = this.ajv.compile(_generate.call(this, 'evaluate'));
// console.log(this._validate.toString().length, this._evaluate.toString().length);
} | javascript | function generateSchemas() {
// this.ajv.addMetaSchema(_generate.call(this, 'evaluate_metaschema'));
this._validate = this.ajv.compile(_generate.call(this, 'schema'));
this._expandMacros = this.ajv.compile(_generate.call(this, 'expand_macros'));
this._evaluate = this.ajv.compile(_generate.call(this, 'evaluate'));
// console.log(this._validate.toString().length, this._evaluate.toString().length);
} | [
"function",
"generateSchemas",
"(",
")",
"{",
"// this.ajv.addMetaSchema(_generate.call(this, 'evaluate_metaschema'));",
"this",
".",
"_validate",
"=",
"this",
".",
"ajv",
".",
"compile",
"(",
"_generate",
".",
"call",
"(",
"this",
",",
"'schema'",
")",
")",
";",
... | private function to regenerate validation and evaluation schemas, called when an instruction is added
@this JSONScript | [
"private",
"function",
"to",
"regenerate",
"validation",
"and",
"evaluation",
"schemas",
"called",
"when",
"an",
"instruction",
"is",
"added"
] | 4b17d7f263b8db928d2e8fe3e3d828550d07cafc | https://github.com/JSONScript/jsonscript-js/blob/4b17d7f263b8db928d2e8fe3e3d828550d07cafc/lib/jsonscript.js#L229-L235 |
32,035 | JSONScript/jsonscript-js | lib/jsonscript.js | _generate | function _generate(schemaName) {
var schema = generateSchema(schemaName, this._instructions, this._macros, this._opts.strict);
this.ajv.removeSchema(schema.id);
return schema;
} | javascript | function _generate(schemaName) {
var schema = generateSchema(schemaName, this._instructions, this._macros, this._opts.strict);
this.ajv.removeSchema(schema.id);
return schema;
} | [
"function",
"_generate",
"(",
"schemaName",
")",
"{",
"var",
"schema",
"=",
"generateSchema",
"(",
"schemaName",
",",
"this",
".",
"_instructions",
",",
"this",
".",
"_macros",
",",
"this",
".",
"_opts",
".",
"strict",
")",
";",
"this",
".",
"ajv",
".",
... | private function to generate one of schemas used by the interpreter
@this JSONScript
@param {String} schemaName schema name
@return {Object} generated schema object | [
"private",
"function",
"to",
"generate",
"one",
"of",
"schemas",
"used",
"by",
"the",
"interpreter"
] | 4b17d7f263b8db928d2e8fe3e3d828550d07cafc | https://github.com/JSONScript/jsonscript-js/blob/4b17d7f263b8db928d2e8fe3e3d828550d07cafc/lib/jsonscript.js#L244-L248 |
32,036 | JSONScript/jsonscript-js | lib/evaluation_keywords.js | resolvePendingRefs | function resolvePendingRefs(data, dataPath) {
dataPath = dataPath.replace(/^\/script/, '');
this.evaluatedRefs[dataPath] = true;
var ref = this.pendingRefs[dataPath];
if (ref) ref.resolve();
return true;
} | javascript | function resolvePendingRefs(data, dataPath) {
dataPath = dataPath.replace(/^\/script/, '');
this.evaluatedRefs[dataPath] = true;
var ref = this.pendingRefs[dataPath];
if (ref) ref.resolve();
return true;
} | [
"function",
"resolvePendingRefs",
"(",
"data",
",",
"dataPath",
")",
"{",
"dataPath",
"=",
"dataPath",
".",
"replace",
"(",
"/",
"^\\/script",
"/",
",",
"''",
")",
";",
"this",
".",
"evaluatedRefs",
"[",
"dataPath",
"]",
"=",
"true",
";",
"var",
"ref",
... | Validation function for custom validation keyword resolvePendingRefs.
It marks the current path as evaluated and resolves pending references.
@this Evaluation
@param {Object} data Current script, not used
@param {String} dataPath Current data path (JSON pointer)
@return {Boolean} validation result | [
"Validation",
"function",
"for",
"custom",
"validation",
"keyword",
"resolvePendingRefs",
".",
"It",
"marks",
"the",
"current",
"path",
"as",
"evaluated",
"and",
"resolves",
"pending",
"references",
"."
] | 4b17d7f263b8db928d2e8fe3e3d828550d07cafc | https://github.com/JSONScript/jsonscript-js/blob/4b17d7f263b8db928d2e8fe3e3d828550d07cafc/lib/evaluation_keywords.js#L22-L28 |
32,037 | JSONScript/jsonscript-js | lib/util.js | toAbsolutePointer | function toAbsolutePointer(relativePointer, basePointerParsed) {
var base = basePointerParsed;
var matches = relativePointer.match(RELATIVE_JSON_POINTER);
if (!matches) return;
var lvl = base.length;
var up = +matches[1];
var jsonPointer = matches[2];
if (jsonPointer == '#') {
if (up >= lvl) throw new Error('Cannot access property/index ' + up + ' levels up, current level is ' + lvl);
return base[lvl-up-1]; // resolved pointer value
}
if (up > lvl) throw new Error('Cannot reference script ' + up + ' levels up, current level is ' + lvl);
var parsedPointer = pointer.parse(jsonPointer);
if (up > 0) base = base.slice(0, -up);
return base.concat(parsedPointer); // parsed absolute pointer as array
} | javascript | function toAbsolutePointer(relativePointer, basePointerParsed) {
var base = basePointerParsed;
var matches = relativePointer.match(RELATIVE_JSON_POINTER);
if (!matches) return;
var lvl = base.length;
var up = +matches[1];
var jsonPointer = matches[2];
if (jsonPointer == '#') {
if (up >= lvl) throw new Error('Cannot access property/index ' + up + ' levels up, current level is ' + lvl);
return base[lvl-up-1]; // resolved pointer value
}
if (up > lvl) throw new Error('Cannot reference script ' + up + ' levels up, current level is ' + lvl);
var parsedPointer = pointer.parse(jsonPointer);
if (up > 0) base = base.slice(0, -up);
return base.concat(parsedPointer); // parsed absolute pointer as array
} | [
"function",
"toAbsolutePointer",
"(",
"relativePointer",
",",
"basePointerParsed",
")",
"{",
"var",
"base",
"=",
"basePointerParsed",
";",
"var",
"matches",
"=",
"relativePointer",
".",
"match",
"(",
"RELATIVE_JSON_POINTER",
")",
";",
"if",
"(",
"!",
"matches",
... | converts relative JSON-pointer to an absolute JSON-pointer
@param {String} relativePointer relative JSON-pointer
@param {Array<String>} basePointerParsed current base JSON-pointer parsed to segments and unescaped
@return {Array<String>} absolute JSON-pointer | [
"converts",
"relative",
"JSON",
"-",
"pointer",
"to",
"an",
"absolute",
"JSON",
"-",
"pointer"
] | 4b17d7f263b8db928d2e8fe3e3d828550d07cafc | https://github.com/JSONScript/jsonscript-js/blob/4b17d7f263b8db928d2e8fe3e3d828550d07cafc/lib/util.js#L85-L101 |
32,038 | sabberworm/karma-iframes | static/iframes-adapter.js | suiteStarted | function suiteStarted() {
// Have all suites started?
if(hasPendingSuites()) {
return;
}
// All suites have started, send the total to karma
let [total, finished] = countTests();
if(isDebug) {
console.debug(`All ${Object.keys(suites).length} suites have started, expecting ${total} tests (of which ${finished} have already finished)`);
}
karma.info({total});
// Send the pending results
pendingResults.forEach(sendResult);
pendingResults = [];
} | javascript | function suiteStarted() {
// Have all suites started?
if(hasPendingSuites()) {
return;
}
// All suites have started, send the total to karma
let [total, finished] = countTests();
if(isDebug) {
console.debug(`All ${Object.keys(suites).length} suites have started, expecting ${total} tests (of which ${finished} have already finished)`);
}
karma.info({total});
// Send the pending results
pendingResults.forEach(sendResult);
pendingResults = [];
} | [
"function",
"suiteStarted",
"(",
")",
"{",
"// Have all suites started?",
"if",
"(",
"hasPendingSuites",
"(",
")",
")",
"{",
"return",
";",
"}",
"// All suites have started, send the total to karma",
"let",
"[",
"total",
",",
"finished",
"]",
"=",
"countTests",
"(",... | Some suite has started | [
"Some",
"suite",
"has",
"started"
] | a31b712175edcba63c29afcf35b5d11ced89e9a4 | https://github.com/sabberworm/karma-iframes/blob/a31b712175edcba63c29afcf35b5d11ced89e9a4/static/iframes-adapter.js#L177-L191 |
32,039 | sabberworm/karma-iframes | static/iframes-adapter.js | suiteComplete | function suiteComplete(result) {
if (result.coverage) {
coverageCollector.addCoverage(result.coverage);
}
// Have all suites completed?
let completedSuites = suitesWithState('complete');
if(Object.keys(completedSuites).length < Object.keys(suites).length) {
return;
}
// All suites have completed, send the “complete” message to karma
if(isDebug) {
let [total, finished] = countTests();
console.debug(`All ${Object.keys(suites).length} suites have completed, ran ${finished} of ${total} tests`);
}
if (result.coverage) {
result.coverage = coverageCollector.getFinalCoverage();
}
karma.complete(result);
} | javascript | function suiteComplete(result) {
if (result.coverage) {
coverageCollector.addCoverage(result.coverage);
}
// Have all suites completed?
let completedSuites = suitesWithState('complete');
if(Object.keys(completedSuites).length < Object.keys(suites).length) {
return;
}
// All suites have completed, send the “complete” message to karma
if(isDebug) {
let [total, finished] = countTests();
console.debug(`All ${Object.keys(suites).length} suites have completed, ran ${finished} of ${total} tests`);
}
if (result.coverage) {
result.coverage = coverageCollector.getFinalCoverage();
}
karma.complete(result);
} | [
"function",
"suiteComplete",
"(",
"result",
")",
"{",
"if",
"(",
"result",
".",
"coverage",
")",
"{",
"coverageCollector",
".",
"addCoverage",
"(",
"result",
".",
"coverage",
")",
";",
"}",
"// Have all suites completed?",
"let",
"completedSuites",
"=",
"suitesW... | Some suite has completed | [
"Some",
"suite",
"has",
"completed"
] | a31b712175edcba63c29afcf35b5d11ced89e9a4 | https://github.com/sabberworm/karma-iframes/blob/a31b712175edcba63c29afcf35b5d11ced89e9a4/static/iframes-adapter.js#L194-L213 |
32,040 | sabberworm/karma-iframes | lib/rewrite-middleware.js | includeServedOnly | function includeServedOnly(files) {
files = Object.assign({}, files);
let oldIncluded = files.included;
files.included = files.served
// Don’t include the files that are included in the outer context
.filter(file => oldIncluded.indexOf(file) === -1)
// Don’t include this (or other) contexts
.filter(file => !isIFrameHtml(file.path))
// Don’t include files that were never included to begin with (before the framework ran)
// FIXME: find the most specific applicable pattern first
.filter(file => !nonIncludedFiles.some(pattern => minimatch(file.originalPath, pattern.pattern)))
// Don’t include the reverse context (it is included by the `transform` function below)
.filter(file => file.originalPath !== REVERSE_CONTEXT);
return files;
} | javascript | function includeServedOnly(files) {
files = Object.assign({}, files);
let oldIncluded = files.included;
files.included = files.served
// Don’t include the files that are included in the outer context
.filter(file => oldIncluded.indexOf(file) === -1)
// Don’t include this (or other) contexts
.filter(file => !isIFrameHtml(file.path))
// Don’t include files that were never included to begin with (before the framework ran)
// FIXME: find the most specific applicable pattern first
.filter(file => !nonIncludedFiles.some(pattern => minimatch(file.originalPath, pattern.pattern)))
// Don’t include the reverse context (it is included by the `transform` function below)
.filter(file => file.originalPath !== REVERSE_CONTEXT);
return files;
} | [
"function",
"includeServedOnly",
"(",
"files",
")",
"{",
"files",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"files",
")",
";",
"let",
"oldIncluded",
"=",
"files",
".",
"included",
";",
"files",
".",
"included",
"=",
"files",
".",
"served",
"// ... | Reverse included and served files | [
"Reverse",
"included",
"and",
"served",
"files"
] | a31b712175edcba63c29afcf35b5d11ced89e9a4 | https://github.com/sabberworm/karma-iframes/blob/a31b712175edcba63c29afcf35b5d11ced89e9a4/lib/rewrite-middleware.js#L29-L43 |
32,041 | felixarntz/wp-media-picker | wp-media-picker.js | getAttachment | function getAttachment( val, valType, onFound, onNotFound ) {
var requestData;
if ( ! val ) {
onNotFound();
return;
}
if ( 'url' === valType ) {
requestData = {
action: 'get-attachment-by-url',
url: val
};
} else {
requestData = {
action: 'get-attachment',
id: parseInt( val, 10 )
};
}
wp.media.ajax({
type: 'POST',
data: requestData,
success: onFound,
error: onNotFound
});
} | javascript | function getAttachment( val, valType, onFound, onNotFound ) {
var requestData;
if ( ! val ) {
onNotFound();
return;
}
if ( 'url' === valType ) {
requestData = {
action: 'get-attachment-by-url',
url: val
};
} else {
requestData = {
action: 'get-attachment',
id: parseInt( val, 10 )
};
}
wp.media.ajax({
type: 'POST',
data: requestData,
success: onFound,
error: onNotFound
});
} | [
"function",
"getAttachment",
"(",
"val",
",",
"valType",
",",
"onFound",
",",
"onNotFound",
")",
"{",
"var",
"requestData",
";",
"if",
"(",
"!",
"val",
")",
"{",
"onNotFound",
"(",
")",
";",
"return",
";",
"}",
"if",
"(",
"'url'",
"===",
"valType",
"... | Gets an attachment object via AJAX based on a given ID or URL.
@since 0.7.0
@private
@param {number|string} val Attachment ID or URL.
@param {string} valType Whether 'val' was provided as 'id' or 'url'.
@param {function} onFound Callback to pass the found attachment to.
@param {function} onNotFound Callback to run if no attachment was found.
@return {void} | [
"Gets",
"an",
"attachment",
"object",
"via",
"AJAX",
"based",
"on",
"a",
"given",
"ID",
"or",
"URL",
"."
] | 256f813d9fabf557ef0545355f7fc24432a873d1 | https://github.com/felixarntz/wp-media-picker/blob/256f813d9fabf557ef0545355f7fc24432a873d1/wp-media-picker.js#L37-L63 |
32,042 | felixarntz/wp-media-picker | wp-media-picker.js | function() {
_.defaults( this.options, {
query: {},
multiple: false,
editable: true,
filterable: 'all',
searchable: true,
displaySettings: false,
displayUserSettings: false,
editing: false,
state: 'insert',
metadata: {}
});
Select.prototype.initialize.apply( this, arguments );
} | javascript | function() {
_.defaults( this.options, {
query: {},
multiple: false,
editable: true,
filterable: 'all',
searchable: true,
displaySettings: false,
displayUserSettings: false,
editing: false,
state: 'insert',
metadata: {}
});
Select.prototype.initialize.apply( this, arguments );
} | [
"function",
"(",
")",
"{",
"_",
".",
"defaults",
"(",
"this",
".",
"options",
",",
"{",
"query",
":",
"{",
"}",
",",
"multiple",
":",
"false",
",",
"editable",
":",
"true",
",",
"filterable",
":",
"'all'",
",",
"searchable",
":",
"true",
",",
"disp... | Initializes the media frame.
@since 0.7.0
@returns {void} | [
"Initializes",
"the",
"media",
"frame",
"."
] | 256f813d9fabf557ef0545355f7fc24432a873d1 | https://github.com/felixarntz/wp-media-picker/blob/256f813d9fabf557ef0545355f7fc24432a873d1/wp-media-picker.js#L84-L99 | |
32,043 | felixarntz/wp-media-picker | wp-media-picker.js | function() {
this.states.add([
new wp.media.controller.Library({
id: 'insert',
title: this.options.title,
selection: this.options.selection,
priority: 20,
toolbar: 'main-insert',
filterable: this.options.filterable,
searchable: this.options.searchable,
library: wp.media.query( this.options.query ),
multiple: this.options.multiple,
editable: this.options.editable,
displaySettings: this.options.displaySettings,
displayUserSettings: this.options.displayUserSettings
}),
new wp.media.controller.EditImage({ model: this.options.editImage })
]);
} | javascript | function() {
this.states.add([
new wp.media.controller.Library({
id: 'insert',
title: this.options.title,
selection: this.options.selection,
priority: 20,
toolbar: 'main-insert',
filterable: this.options.filterable,
searchable: this.options.searchable,
library: wp.media.query( this.options.query ),
multiple: this.options.multiple,
editable: this.options.editable,
displaySettings: this.options.displaySettings,
displayUserSettings: this.options.displayUserSettings
}),
new wp.media.controller.EditImage({ model: this.options.editImage })
]);
} | [
"function",
"(",
")",
"{",
"this",
".",
"states",
".",
"add",
"(",
"[",
"new",
"wp",
".",
"media",
".",
"controller",
".",
"Library",
"(",
"{",
"id",
":",
"'insert'",
",",
"title",
":",
"this",
".",
"options",
".",
"title",
",",
"selection",
":",
... | Creates the default states.
@since 0.7.0
@returns {void} | [
"Creates",
"the",
"default",
"states",
"."
] | 256f813d9fabf557ef0545355f7fc24432a873d1 | https://github.com/felixarntz/wp-media-picker/blob/256f813d9fabf557ef0545355f7fc24432a873d1/wp-media-picker.js#L108-L127 | |
32,044 | felixarntz/wp-media-picker | wp-media-picker.js | function() {
var view = new wp.media.view.EditImage({
controller: this,
model: this.state().get( 'image' )
}).render();
this.content.set( view );
view.loadEditor();
} | javascript | function() {
var view = new wp.media.view.EditImage({
controller: this,
model: this.state().get( 'image' )
}).render();
this.content.set( view );
view.loadEditor();
} | [
"function",
"(",
")",
"{",
"var",
"view",
"=",
"new",
"wp",
".",
"media",
".",
"view",
".",
"EditImage",
"(",
"{",
"controller",
":",
"this",
",",
"model",
":",
"this",
".",
"state",
"(",
")",
".",
"get",
"(",
"'image'",
")",
"}",
")",
".",
"re... | Renders the edit image content.
@since 0.7.0
@returns {void} | [
"Renders",
"the",
"edit",
"image",
"content",
"."
] | 256f813d9fabf557ef0545355f7fc24432a873d1 | https://github.com/felixarntz/wp-media-picker/blob/256f813d9fabf557ef0545355f7fc24432a873d1/wp-media-picker.js#L152-L161 | |
32,045 | felixarntz/wp-media-picker | wp-media-picker.js | function( view ) {
var controller = this;
view.set( 'insert', {
style: 'primary',
priority: 80,
text: controller.options.buttonText,
requires: { selection: true },
click: function() {
controller.close();
controller.state().trigger( 'insert', controller.state().get( 'selection' ) ).reset();
}
});
} | javascript | function( view ) {
var controller = this;
view.set( 'insert', {
style: 'primary',
priority: 80,
text: controller.options.buttonText,
requires: { selection: true },
click: function() {
controller.close();
controller.state().trigger( 'insert', controller.state().get( 'selection' ) ).reset();
}
});
} | [
"function",
"(",
"view",
")",
"{",
"var",
"controller",
"=",
"this",
";",
"view",
".",
"set",
"(",
"'insert'",
",",
"{",
"style",
":",
"'primary'",
",",
"priority",
":",
"80",
",",
"text",
":",
"controller",
".",
"options",
".",
"buttonText",
",",
"r... | Renders the main insert toolbar.
@since 0.7.0
@param {wp.Backbone.View} view Toolbar view.
@returns {void} | [
"Renders",
"the",
"main",
"insert",
"toolbar",
"."
] | 256f813d9fabf557ef0545355f7fc24432a873d1 | https://github.com/felixarntz/wp-media-picker/blob/256f813d9fabf557ef0545355f7fc24432a873d1/wp-media-picker.js#L172-L185 | |
32,046 | felixarntz/wp-media-picker | wp-media-picker.js | function() {
var self = this;
$.extend( self.options, self.element.data() );
// Use the 'type' query attribute in favor of 'post_mime_type'.
if ( self.options.query && self.options.query.post_mime_type ) {
self.options.query.type = self.options.query.post_mime_type;
delete self.options.query.post_mime_type;
}
self._content_id = 'wp-mediapicker-content-' + self.element.attr( 'id' );
self.element.hide().wrap( '<div class="wp-mediapicker-container" />' );
self._wrap = self.element.parent();
self._open_button = $( '<button type="button" class="wp-mediapicker-open-button button" />' ).insertAfter( self.element );
self._remove_button = $( '<button type="button" class="wp-mediapicker-remove-button button-link button-link-delete" />' ).hide().insertAfter( self._open_button ).text( self.options.label_remove );
self._content_wrap = $( '<div class="wp-mediapicker-content-wrap" />' ).insertAfter( self._remove_button );
self._content = $( '<div class="wp-mediapicker-content" />' ).appendTo( self._content_wrap ).attr( 'id', self._content_id );
self._frame = new MediaPickerFrame({
title: self.options.label_modal,
buttonText: self.options.label_button,
frame: 'select',
state: 'insert',
selection: new wp.media.model.Selection( [], {
multiple: self.options.multiple
}),
query: self.options.query,
multiple: self.options.multiple,
filterable: self.options.filterable,
searchable: self.options.searchable,
editable: self.options.editable
});
self._setValue( self.element.val() );
self._addListeners();
} | javascript | function() {
var self = this;
$.extend( self.options, self.element.data() );
// Use the 'type' query attribute in favor of 'post_mime_type'.
if ( self.options.query && self.options.query.post_mime_type ) {
self.options.query.type = self.options.query.post_mime_type;
delete self.options.query.post_mime_type;
}
self._content_id = 'wp-mediapicker-content-' + self.element.attr( 'id' );
self.element.hide().wrap( '<div class="wp-mediapicker-container" />' );
self._wrap = self.element.parent();
self._open_button = $( '<button type="button" class="wp-mediapicker-open-button button" />' ).insertAfter( self.element );
self._remove_button = $( '<button type="button" class="wp-mediapicker-remove-button button-link button-link-delete" />' ).hide().insertAfter( self._open_button ).text( self.options.label_remove );
self._content_wrap = $( '<div class="wp-mediapicker-content-wrap" />' ).insertAfter( self._remove_button );
self._content = $( '<div class="wp-mediapicker-content" />' ).appendTo( self._content_wrap ).attr( 'id', self._content_id );
self._frame = new MediaPickerFrame({
title: self.options.label_modal,
buttonText: self.options.label_button,
frame: 'select',
state: 'insert',
selection: new wp.media.model.Selection( [], {
multiple: self.options.multiple
}),
query: self.options.query,
multiple: self.options.multiple,
filterable: self.options.filterable,
searchable: self.options.searchable,
editable: self.options.editable
});
self._setValue( self.element.val() );
self._addListeners();
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"$",
".",
"extend",
"(",
"self",
".",
"options",
",",
"self",
".",
"element",
".",
"data",
"(",
")",
")",
";",
"// Use the 'type' query attribute in favor of 'post_mime_type'.",
"if",
"(",
"self",
... | Creates the media picker markup and initializes the media frame for the element.
@since 0.1.0
@returns {void} | [
"Creates",
"the",
"media",
"picker",
"markup",
"and",
"initializes",
"the",
"media",
"frame",
"for",
"the",
"element",
"."
] | 256f813d9fabf557ef0545355f7fc24432a873d1 | https://github.com/felixarntz/wp-media-picker/blob/256f813d9fabf557ef0545355f7fc24432a873d1/wp-media-picker.js#L222-L261 | |
32,047 | felixarntz/wp-media-picker | wp-media-picker.js | function() {
var self = this;
self._frame.on( 'insert', function() {
var selection = self._frame.state().get( 'selection' );
var attachments = selection.models.map( function( model ) {
return _.extend( {}, model.toJSON() );
});
var attachment = _.extend( {}, selection.first().toJSON() );
self._setAttachment( attachment );
$( document ).trigger( 'wpMediaPicker.insert', [ attachments, self ] );
});
self._open_button.on( 'click', function() {
var selection = self._frame.state( 'insert' ).get( 'selection' );
selection.reset( self._attachment ? [ self._attachment ] : [] );
self.open();
});
self._remove_button.on( 'click', function() {
self._setAttachment( null );
});
} | javascript | function() {
var self = this;
self._frame.on( 'insert', function() {
var selection = self._frame.state().get( 'selection' );
var attachments = selection.models.map( function( model ) {
return _.extend( {}, model.toJSON() );
});
var attachment = _.extend( {}, selection.first().toJSON() );
self._setAttachment( attachment );
$( document ).trigger( 'wpMediaPicker.insert', [ attachments, self ] );
});
self._open_button.on( 'click', function() {
var selection = self._frame.state( 'insert' ).get( 'selection' );
selection.reset( self._attachment ? [ self._attachment ] : [] );
self.open();
});
self._remove_button.on( 'click', function() {
self._setAttachment( null );
});
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"_frame",
".",
"on",
"(",
"'insert'",
",",
"function",
"(",
")",
"{",
"var",
"selection",
"=",
"self",
".",
"_frame",
".",
"state",
"(",
")",
".",
"get",
"(",
"'selection'",
... | Adds event listeners for the media picker buttons and the media frame inserter.
@since 0.1.0
@returns {void} | [
"Adds",
"event",
"listeners",
"for",
"the",
"media",
"picker",
"buttons",
"and",
"the",
"media",
"frame",
"inserter",
"."
] | 256f813d9fabf557ef0545355f7fc24432a873d1 | https://github.com/felixarntz/wp-media-picker/blob/256f813d9fabf557ef0545355f7fc24432a873d1/wp-media-picker.js#L270-L295 | |
32,048 | felixarntz/wp-media-picker | wp-media-picker.js | function( attachment ) {
var self = this;
self._attachment = attachment;
self._open_button.text( self.options.label_replace );
self._remove_button.show();
var preview_content = '';
if ( 'video' === attachment.type ) {
// for video attachments, show the video player, optionally with the poster
var poster = '';
if ( attachment.image && attachment.image.src !== attachment.icon ) {
poster = attachment.image.src;
}
preview_content += '<video class="wp-video-shortcode" preload="metadata"' + ( poster ? ' poster="' + poster + '"' : '' ) + ' controls><source type="' + attachment.mime + '" src="' + attachment.url + '" /></video>';
} else if ( 'audio' === attachment.type ) {
// for audio attachments, show the audio player, with either the cover or the mime type icon
if ( attachment.image && attachment.image.src && attachment.image.src !== attachment.icon ) {
preview_content += '<img class="wp-audio-cover" src="' + attachment.image.src + '" alt="' + attachment.filename + '" />';
} else {
preview_content += '<div class="mime-type-icon"><img src="' + attachment.icon + '" /><span>' + attachment.filename + '</span></div>';
}
preview_content += '<audio class="wp-audio-shortcode" width="100%" preload="none" controls><source type="' + attachment.mime + '" src="' + attachment.url + '" /></audio>';
} else {
var src = 'image' === attachment.type ? attachment.url : undefined;
if ( attachment.sizes ) {
if ( attachment.sizes.large ) {
src = attachment.sizes.large.url;
} else if ( attachment.sizes.full ) {
src = attachment.sizes.full.url;
}
}
if ( src ) {
preview_content += '<img src="' + src + '" alt="' + attachment.alt + '" />';
} else {
preview_content += '<div class="mime-type-icon"><img src="' + attachment.icon + '" /><span>' + attachment.filename + '</span></div>';
}
}
if ( 0 <= preview_content.search( '<img ' ) ) {
self._content.addClass( 'size-auto' );
} else {
self._content.removeClass( 'size-auto' );
}
self._content.show().html( preview_content );
} | javascript | function( attachment ) {
var self = this;
self._attachment = attachment;
self._open_button.text( self.options.label_replace );
self._remove_button.show();
var preview_content = '';
if ( 'video' === attachment.type ) {
// for video attachments, show the video player, optionally with the poster
var poster = '';
if ( attachment.image && attachment.image.src !== attachment.icon ) {
poster = attachment.image.src;
}
preview_content += '<video class="wp-video-shortcode" preload="metadata"' + ( poster ? ' poster="' + poster + '"' : '' ) + ' controls><source type="' + attachment.mime + '" src="' + attachment.url + '" /></video>';
} else if ( 'audio' === attachment.type ) {
// for audio attachments, show the audio player, with either the cover or the mime type icon
if ( attachment.image && attachment.image.src && attachment.image.src !== attachment.icon ) {
preview_content += '<img class="wp-audio-cover" src="' + attachment.image.src + '" alt="' + attachment.filename + '" />';
} else {
preview_content += '<div class="mime-type-icon"><img src="' + attachment.icon + '" /><span>' + attachment.filename + '</span></div>';
}
preview_content += '<audio class="wp-audio-shortcode" width="100%" preload="none" controls><source type="' + attachment.mime + '" src="' + attachment.url + '" /></audio>';
} else {
var src = 'image' === attachment.type ? attachment.url : undefined;
if ( attachment.sizes ) {
if ( attachment.sizes.large ) {
src = attachment.sizes.large.url;
} else if ( attachment.sizes.full ) {
src = attachment.sizes.full.url;
}
}
if ( src ) {
preview_content += '<img src="' + src + '" alt="' + attachment.alt + '" />';
} else {
preview_content += '<div class="mime-type-icon"><img src="' + attachment.icon + '" /><span>' + attachment.filename + '</span></div>';
}
}
if ( 0 <= preview_content.search( '<img ' ) ) {
self._content.addClass( 'size-auto' );
} else {
self._content.removeClass( 'size-auto' );
}
self._content.show().html( preview_content );
} | [
"function",
"(",
"attachment",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"_attachment",
"=",
"attachment",
";",
"self",
".",
"_open_button",
".",
"text",
"(",
"self",
".",
"options",
".",
"label_replace",
")",
";",
"self",
".",
"_remove_but... | Creates the preview content markup for a given attachment.
@since 0.1.0
@param {object} attachment WordPress attachment data.
@returns {void} | [
"Creates",
"the",
"preview",
"content",
"markup",
"for",
"a",
"given",
"attachment",
"."
] | 256f813d9fabf557ef0545355f7fc24432a873d1 | https://github.com/felixarntz/wp-media-picker/blob/256f813d9fabf557ef0545355f7fc24432a873d1/wp-media-picker.js#L306-L354 | |
32,049 | felixarntz/wp-media-picker | wp-media-picker.js | function() {
var self = this;
self._attachment = null;
self._open_button.text( self.options.label_add );
self._remove_button.hide();
self._content.hide().empty().removeClass( 'size-auto' );
} | javascript | function() {
var self = this;
self._attachment = null;
self._open_button.text( self.options.label_add );
self._remove_button.hide();
self._content.hide().empty().removeClass( 'size-auto' );
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"_attachment",
"=",
"null",
";",
"self",
".",
"_open_button",
".",
"text",
"(",
"self",
".",
"options",
".",
"label_add",
")",
";",
"self",
".",
"_remove_button",
".",
"hide",
"... | Resets the preview content markup.
@since 0.1.0
@returns {void} | [
"Resets",
"the",
"preview",
"content",
"markup",
"."
] | 256f813d9fabf557ef0545355f7fc24432a873d1 | https://github.com/felixarntz/wp-media-picker/blob/256f813d9fabf557ef0545355f7fc24432a873d1/wp-media-picker.js#L363-L371 | |
32,050 | felixarntz/wp-media-picker | wp-media-picker.js | function( attachment ) {
var noChange = ( attachment && this._attachment && attachment.id === this._attachment.id ) || ( ! attachment && ! this._attachment );
if ( ! attachment ) {
this._resetContent();
if ( noChange ) {
return;
}
this.element.val( null );
this.element.trigger( 'change' );
if ( 'function' === typeof this.options.clear ) {
this.options.clear.call( this );
}
$( document ).trigger( 'wpMediaPicker.updateField', [ null, this ] );
return;
}
this._createContent( attachment );
if ( noChange ) {
return;
}
if ( 'url' === this.options.store ) {
this.element.val( attachment.url );
} else {
this.element.val( attachment.id );
}
this.element.trigger( 'change' );
if ( 'function' === typeof this.options.change ) {
this.options.change.call( this );
}
$( document ).trigger( 'wpMediaPicker.updateField', [ attachment, this ] );
} | javascript | function( attachment ) {
var noChange = ( attachment && this._attachment && attachment.id === this._attachment.id ) || ( ! attachment && ! this._attachment );
if ( ! attachment ) {
this._resetContent();
if ( noChange ) {
return;
}
this.element.val( null );
this.element.trigger( 'change' );
if ( 'function' === typeof this.options.clear ) {
this.options.clear.call( this );
}
$( document ).trigger( 'wpMediaPicker.updateField', [ null, this ] );
return;
}
this._createContent( attachment );
if ( noChange ) {
return;
}
if ( 'url' === this.options.store ) {
this.element.val( attachment.url );
} else {
this.element.val( attachment.id );
}
this.element.trigger( 'change' );
if ( 'function' === typeof this.options.change ) {
this.options.change.call( this );
}
$( document ).trigger( 'wpMediaPicker.updateField', [ attachment, this ] );
} | [
"function",
"(",
"attachment",
")",
"{",
"var",
"noChange",
"=",
"(",
"attachment",
"&&",
"this",
".",
"_attachment",
"&&",
"attachment",
".",
"id",
"===",
"this",
".",
"_attachment",
".",
"id",
")",
"||",
"(",
"!",
"attachment",
"&&",
"!",
"this",
"."... | Sets the currently selected attachment.
If the attachment is different from the current attachment,
change events will be triggered.
@since 0.7.0
@param {object} attachment WordPress attachment data.
@returns {void} | [
"Sets",
"the",
"currently",
"selected",
"attachment",
"."
] | 256f813d9fabf557ef0545355f7fc24432a873d1 | https://github.com/felixarntz/wp-media-picker/blob/256f813d9fabf557ef0545355f7fc24432a873d1/wp-media-picker.js#L396-L435 | |
32,051 | felixarntz/wp-media-picker | wp-media-picker.js | function( val ) {
var self = this;
getAttachment(
val,
self.options.store,
function( attachment ) {
self._setAttachment( attachment );
},
function() {
self._setAttachment( null );
}
);
} | javascript | function( val ) {
var self = this;
getAttachment(
val,
self.options.store,
function( attachment ) {
self._setAttachment( attachment );
},
function() {
self._setAttachment( null );
}
);
} | [
"function",
"(",
"val",
")",
"{",
"var",
"self",
"=",
"this",
";",
"getAttachment",
"(",
"val",
",",
"self",
".",
"options",
".",
"store",
",",
"function",
"(",
"attachment",
")",
"{",
"self",
".",
"_setAttachment",
"(",
"attachment",
")",
";",
"}",
... | Sets the current value of the element.
This is not the attachment, but the ID or URL depending on the store option.
@since 0.7.0
@param {number|string} val Attachment ID, URL, or empty string if no attachment selected.
@returns {void} | [
"Sets",
"the",
"current",
"value",
"of",
"the",
"element",
"."
] | 256f813d9fabf557ef0545355f7fc24432a873d1 | https://github.com/felixarntz/wp-media-picker/blob/256f813d9fabf557ef0545355f7fc24432a873d1/wp-media-picker.js#L469-L482 | |
32,052 | mclaeysb/simplepolygon | index.js | determineParents | function determineParents() {
var featuresWithoutParent = [];
for (var i = 0; i < output.features.length; i++) {
debugAll("Output ring " + i + " has parent " + output.features[i].properties.parent);
if (output.features[i].properties.parent == -1) featuresWithoutParent.push(i);
}
debugAll("The following output ring(s) have no parent: " + featuresWithoutParent);
if (featuresWithoutParent.length > 1) {
for (var i = 0; i < featuresWithoutParent.length; i++) {
var parent = -1;
var parentArea = Infinity;
for (var j = 0; j < output.features.length; j++) {
if (featuresWithoutParent[i] == j) continue
if (inside(helpers.point(output.features[featuresWithoutParent[i]].geometry.coordinates[0][0]), output.features[j], true)) {
if (area(output.features[j]) < parentArea) {
parent = j;
debugAll("Ring "+featuresWithoutParent[i]+" lies inside output ring "+j);
}
}
}
output.features[featuresWithoutParent[i]].properties.parent = parent;
debugAll("Ring "+featuresWithoutParent[i]+" is assigned parent "+parent);
}
}
} | javascript | function determineParents() {
var featuresWithoutParent = [];
for (var i = 0; i < output.features.length; i++) {
debugAll("Output ring " + i + " has parent " + output.features[i].properties.parent);
if (output.features[i].properties.parent == -1) featuresWithoutParent.push(i);
}
debugAll("The following output ring(s) have no parent: " + featuresWithoutParent);
if (featuresWithoutParent.length > 1) {
for (var i = 0; i < featuresWithoutParent.length; i++) {
var parent = -1;
var parentArea = Infinity;
for (var j = 0; j < output.features.length; j++) {
if (featuresWithoutParent[i] == j) continue
if (inside(helpers.point(output.features[featuresWithoutParent[i]].geometry.coordinates[0][0]), output.features[j], true)) {
if (area(output.features[j]) < parentArea) {
parent = j;
debugAll("Ring "+featuresWithoutParent[i]+" lies inside output ring "+j);
}
}
}
output.features[featuresWithoutParent[i]].properties.parent = parent;
debugAll("Ring "+featuresWithoutParent[i]+" is assigned parent "+parent);
}
}
} | [
"function",
"determineParents",
"(",
")",
"{",
"var",
"featuresWithoutParent",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"output",
".",
"features",
".",
"length",
";",
"i",
"++",
")",
"{",
"debugAll",
"(",
"\"Output ring \"",... | These functions are also used if no intersections are found | [
"These",
"functions",
"are",
"also",
"used",
"if",
"no",
"intersections",
"are",
"found"
] | 3a148cb6ea9bde679041809861e7548e4197163b | https://github.com/mclaeysb/simplepolygon/blob/3a148cb6ea9bde679041809861e7548e4197163b/index.js#L279-L303 |
32,053 | mclaeysb/simplepolygon | index.js | function (coord, ringAndEdge1, ringAndEdge2, nxtIsectAlongRingAndEdge1, nxtIsectAlongRingAndEdge2, ringAndEdge1Walkable, ringAndEdge2Walkable) {
this.coord = coord; // [x,y] of this intersection
this.ringAndEdge1 = ringAndEdge1; // first edge of this intersection
this.ringAndEdge2 = ringAndEdge2; // second edge of this intersection
this.nxtIsectAlongRingAndEdge1 = nxtIsectAlongRingAndEdge1; // the next intersection when following ringAndEdge1
this.nxtIsectAlongRingAndEdge2 = nxtIsectAlongRingAndEdge2; // the next intersection when following ringAndEdge2
this.ringAndEdge1Walkable = ringAndEdge1Walkable; // May we (still) walk away from this intersection over ringAndEdge1?
this.ringAndEdge2Walkable = ringAndEdge2Walkable; // May we (still) walk away from this intersection over ringAndEdge2?
} | javascript | function (coord, ringAndEdge1, ringAndEdge2, nxtIsectAlongRingAndEdge1, nxtIsectAlongRingAndEdge2, ringAndEdge1Walkable, ringAndEdge2Walkable) {
this.coord = coord; // [x,y] of this intersection
this.ringAndEdge1 = ringAndEdge1; // first edge of this intersection
this.ringAndEdge2 = ringAndEdge2; // second edge of this intersection
this.nxtIsectAlongRingAndEdge1 = nxtIsectAlongRingAndEdge1; // the next intersection when following ringAndEdge1
this.nxtIsectAlongRingAndEdge2 = nxtIsectAlongRingAndEdge2; // the next intersection when following ringAndEdge2
this.ringAndEdge1Walkable = ringAndEdge1Walkable; // May we (still) walk away from this intersection over ringAndEdge1?
this.ringAndEdge2Walkable = ringAndEdge2Walkable; // May we (still) walk away from this intersection over ringAndEdge2?
} | [
"function",
"(",
"coord",
",",
"ringAndEdge1",
",",
"ringAndEdge2",
",",
"nxtIsectAlongRingAndEdge1",
",",
"nxtIsectAlongRingAndEdge2",
",",
"ringAndEdge1Walkable",
",",
"ringAndEdge2Walkable",
")",
"{",
"this",
".",
"coord",
"=",
"coord",
";",
"// [x,y] of this interse... | Constructor for an intersection. There are two intersection-pseudo-vertices per self-intersection and one ring-pseudo-vertex per ring-vertex-intersection. Their labels 1 and 2 are not assigned a particular meaning but are permanent once given. | [
"Constructor",
"for",
"an",
"intersection",
".",
"There",
"are",
"two",
"intersection",
"-",
"pseudo",
"-",
"vertices",
"per",
"self",
"-",
"intersection",
"and",
"one",
"ring",
"-",
"pseudo",
"-",
"vertex",
"per",
"ring",
"-",
"vertex",
"-",
"intersection",... | 3a148cb6ea9bde679041809861e7548e4197163b | https://github.com/mclaeysb/simplepolygon/blob/3a148cb6ea9bde679041809861e7548e4197163b/index.js#L342-L350 | |
32,054 | mclaeysb/simplepolygon | index.js | isConvex | function isConvex(pts, righthanded){
// 'pts' is an [x,y] pair
// 'righthanded' is a boolean
if (typeof(righthanded) === 'undefined') righthanded = true;
if (pts.length != 3) throw new Error("This function requires an array of three points [x,y]");
var d = (pts[1][0] - pts[0][0]) * (pts[2][1] - pts[0][1]) - (pts[1][1] - pts[0][1]) * (pts[2][0] - pts[0][0]);
return (d >= 0) == righthanded;
} | javascript | function isConvex(pts, righthanded){
// 'pts' is an [x,y] pair
// 'righthanded' is a boolean
if (typeof(righthanded) === 'undefined') righthanded = true;
if (pts.length != 3) throw new Error("This function requires an array of three points [x,y]");
var d = (pts[1][0] - pts[0][0]) * (pts[2][1] - pts[0][1]) - (pts[1][1] - pts[0][1]) * (pts[2][0] - pts[0][0]);
return (d >= 0) == righthanded;
} | [
"function",
"isConvex",
"(",
"pts",
",",
"righthanded",
")",
"{",
"// 'pts' is an [x,y] pair",
"// 'righthanded' is a boolean",
"if",
"(",
"typeof",
"(",
"righthanded",
")",
"===",
"'undefined'",
")",
"righthanded",
"=",
"true",
";",
"if",
"(",
"pts",
".",
"leng... | Function to determine if three consecutive points of a simple, non-self-intersecting ring make up a convex vertex, assuming the ring is right- or lefthanded | [
"Function",
"to",
"determine",
"if",
"three",
"consecutive",
"points",
"of",
"a",
"simple",
"non",
"-",
"self",
"-",
"intersecting",
"ring",
"make",
"up",
"a",
"convex",
"vertex",
"assuming",
"the",
"ring",
"is",
"right",
"-",
"or",
"lefthanded"
] | 3a148cb6ea9bde679041809861e7548e4197163b | https://github.com/mclaeysb/simplepolygon/blob/3a148cb6ea9bde679041809861e7548e4197163b/index.js#L353-L360 |
32,055 | mclaeysb/simplepolygon | index.js | windingOfRing | function windingOfRing(ring){
// 'ring' is an array of [x,y] pairs with the last equal to the first
// Compute the winding number based on the vertex with the smallest x-value, it precessor and successor. An extremal vertex of a simple, non-self-intersecting ring is always convex, so the only reason it is not is because the winding number we use to compute it is wrong
var leftVtx = 0;
for (var i = 0; i < ring.length-1; i++) { if (ring[i][0] < ring[leftVtx][0]) leftVtx = i; }
if (isConvex([ring[(leftVtx-1).modulo(ring.length-1)],ring[leftVtx],ring[(leftVtx+1).modulo(ring.length-1)]],true)) {
var winding = 1;
} else {
var winding = -1;
}
return winding
} | javascript | function windingOfRing(ring){
// 'ring' is an array of [x,y] pairs with the last equal to the first
// Compute the winding number based on the vertex with the smallest x-value, it precessor and successor. An extremal vertex of a simple, non-self-intersecting ring is always convex, so the only reason it is not is because the winding number we use to compute it is wrong
var leftVtx = 0;
for (var i = 0; i < ring.length-1; i++) { if (ring[i][0] < ring[leftVtx][0]) leftVtx = i; }
if (isConvex([ring[(leftVtx-1).modulo(ring.length-1)],ring[leftVtx],ring[(leftVtx+1).modulo(ring.length-1)]],true)) {
var winding = 1;
} else {
var winding = -1;
}
return winding
} | [
"function",
"windingOfRing",
"(",
"ring",
")",
"{",
"// 'ring' is an array of [x,y] pairs with the last equal to the first",
"// Compute the winding number based on the vertex with the smallest x-value, it precessor and successor. An extremal vertex of a simple, non-self-intersecting ring is always co... | Function to compute winding of simple, non-self-intersecting ring | [
"Function",
"to",
"compute",
"winding",
"of",
"simple",
"non",
"-",
"self",
"-",
"intersecting",
"ring"
] | 3a148cb6ea9bde679041809861e7548e4197163b | https://github.com/mclaeysb/simplepolygon/blob/3a148cb6ea9bde679041809861e7548e4197163b/index.js#L363-L374 |
32,056 | btwael/zazate.js | core/scales.js | natural_minor | function natural_minor(note) {
var i = get_notes(notes.to_major(note));
var arr = i.slice(5, i.length);
for (var k = 0; k < 5; k++) {
arr.push(i[k]);
};
return arr;
} | javascript | function natural_minor(note) {
var i = get_notes(notes.to_major(note));
var arr = i.slice(5, i.length);
for (var k = 0; k < 5; k++) {
arr.push(i[k]);
};
return arr;
} | [
"function",
"natural_minor",
"(",
"note",
")",
"{",
"var",
"i",
"=",
"get_notes",
"(",
"notes",
".",
"to_major",
"(",
"note",
")",
")",
";",
"var",
"arr",
"=",
"i",
".",
"slice",
"(",
"5",
",",
"i",
".",
"length",
")",
";",
"for",
"(",
"var",
"... | The minor modes | [
"The",
"minor",
"modes"
] | bdf26d30428b57c2b84e64930c72da3a1059df23 | https://github.com/btwael/zazate.js/blob/bdf26d30428b57c2b84e64930c72da3a1059df23/core/scales.js#L68-L75 |
32,057 | multiplex/multiplex.js | src/lib/collections/list.js | function (item, comparer, index, count) {
index = index || 0;
count = count || this.length;
comparer = Comparer.from(comparer);
return binarySearch(this, index, count, item, comparer.compare);
} | javascript | function (item, comparer, index, count) {
index = index || 0;
count = count || this.length;
comparer = Comparer.from(comparer);
return binarySearch(this, index, count, item, comparer.compare);
} | [
"function",
"(",
"item",
",",
"comparer",
",",
"index",
",",
"count",
")",
"{",
"index",
"=",
"index",
"||",
"0",
";",
"count",
"=",
"count",
"||",
"this",
".",
"length",
";",
"comparer",
"=",
"Comparer",
".",
"from",
"(",
"comparer",
")",
";",
"re... | Searches a range of elements in the sorted List for an element using the specified comparer and returns the zero-based index of the element.
@param {Object} item The object to locate.
@param {Comparer=} comparer The Comparer implementation to use when comparing elements.
@param {Number=} index The zero-based starting index of the range to search.
@param {Number=} count The length of the range to search.
@returns {Number} | [
"Searches",
"a",
"range",
"of",
"elements",
"in",
"the",
"sorted",
"List",
"for",
"an",
"element",
"using",
"the",
"specified",
"comparer",
"and",
"returns",
"the",
"zero",
"-",
"based",
"index",
"of",
"the",
"element",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/list.js#L74-L80 | |
32,058 | multiplex/multiplex.js | src/lib/collections/list.js | function (startIndexOrMatch, countOrMatch, match) {
var len = this.length,
startIndex = isNumber(startIndexOrMatch) ? startIndexOrMatch : 0,
count = isNumber(countOrMatch) ? countOrMatch : len - startIndex;
match = isFunction(startIndexOrMatch) ? startIndexOrMatch : (isFunction(countOrMatch) ? countOrMatch : match);
assertType(match, Function);
validateListIndex(this, startIndex);
while (count-- > 0 && startIndex < len) {
if (match(this[startIndex]) === true) {
return startIndex;
}
startIndex++;
}
return -1;
} | javascript | function (startIndexOrMatch, countOrMatch, match) {
var len = this.length,
startIndex = isNumber(startIndexOrMatch) ? startIndexOrMatch : 0,
count = isNumber(countOrMatch) ? countOrMatch : len - startIndex;
match = isFunction(startIndexOrMatch) ? startIndexOrMatch : (isFunction(countOrMatch) ? countOrMatch : match);
assertType(match, Function);
validateListIndex(this, startIndex);
while (count-- > 0 && startIndex < len) {
if (match(this[startIndex]) === true) {
return startIndex;
}
startIndex++;
}
return -1;
} | [
"function",
"(",
"startIndexOrMatch",
",",
"countOrMatch",
",",
"match",
")",
"{",
"var",
"len",
"=",
"this",
".",
"length",
",",
"startIndex",
"=",
"isNumber",
"(",
"startIndexOrMatch",
")",
"?",
"startIndexOrMatch",
":",
"0",
",",
"count",
"=",
"isNumber",... | Searches for an element that matches the conditions defined by the specified predicate,
and returns the zero-based index of the first occurrence within the range of elements
in the List that starts at the specified index and contains the specified number of elements.
@param {Number|Function} startIndexOrMatch The zero-based starting index of the search or the predicate function, eg. function(item)
@param {Number|Function=} countOrMatch The number of elements in the section to search or the predicate function, eg. function(item)
@param {Function=} match The predicate function that defines the conditions of the elements to search for, eg. function(item)
@returns {Number} | [
"Searches",
"for",
"an",
"element",
"that",
"matches",
"the",
"conditions",
"defined",
"by",
"the",
"specified",
"predicate",
"and",
"returns",
"the",
"zero",
"-",
"based",
"index",
"of",
"the",
"first",
"occurrence",
"within",
"the",
"range",
"of",
"elements"... | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/list.js#L149-L168 | |
32,059 | multiplex/multiplex.js | src/lib/collections/list.js | function (match) {
assertType(match, Function);
var len = this.length;
while (len-- > 0) {
if (match(this[len]) === true) {
return this[len];
}
}
return undefined;
} | javascript | function (match) {
assertType(match, Function);
var len = this.length;
while (len-- > 0) {
if (match(this[len]) === true) {
return this[len];
}
}
return undefined;
} | [
"function",
"(",
"match",
")",
"{",
"assertType",
"(",
"match",
",",
"Function",
")",
";",
"var",
"len",
"=",
"this",
".",
"length",
";",
"while",
"(",
"len",
"--",
">",
"0",
")",
"{",
"if",
"(",
"match",
"(",
"this",
"[",
"len",
"]",
")",
"===... | Searches for an element that matches the conditions defined by the specified predicate,
and returns the last occurrence within the entire List.
@param {Function} match The predicate function that defines the conditions of the elements to search for. eg. function(item)
@returns {Object} | [
"Searches",
"for",
"an",
"element",
"that",
"matches",
"the",
"conditions",
"defined",
"by",
"the",
"specified",
"predicate",
"and",
"returns",
"the",
"last",
"occurrence",
"within",
"the",
"entire",
"List",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/list.js#L176-L187 | |
32,060 | multiplex/multiplex.js | src/lib/collections/list.js | function (match) {
assertType(match, Function);
var arr = new Array(this.length),
count = 0;
for (var i = 0, len = this.length; i < len; i++) {
if (match(this[i]) === true) {
arr[count++] = this[i];
}
}
arr.length = count;
return new List(arr);
} | javascript | function (match) {
assertType(match, Function);
var arr = new Array(this.length),
count = 0;
for (var i = 0, len = this.length; i < len; i++) {
if (match(this[i]) === true) {
arr[count++] = this[i];
}
}
arr.length = count;
return new List(arr);
} | [
"function",
"(",
"match",
")",
"{",
"assertType",
"(",
"match",
",",
"Function",
")",
";",
"var",
"arr",
"=",
"new",
"Array",
"(",
"this",
".",
"length",
")",
",",
"count",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"this... | Retrieves all the elements that match the conditions defined by the specified predicate.
@param {Function} match The predicate function that defines the conditions of the elements to search for. eg. function(item)
@returns {List} | [
"Retrieves",
"all",
"the",
"elements",
"that",
"match",
"the",
"conditions",
"defined",
"by",
"the",
"specified",
"predicate",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/list.js#L223-L237 | |
32,061 | multiplex/multiplex.js | src/lib/collections/list.js | function (index, count) {
validateListIndex(this, index + count - 1);
return new List(this.slice(index, index + count));
} | javascript | function (index, count) {
validateListIndex(this, index + count - 1);
return new List(this.slice(index, index + count));
} | [
"function",
"(",
"index",
",",
"count",
")",
"{",
"validateListIndex",
"(",
"this",
",",
"index",
"+",
"count",
"-",
"1",
")",
";",
"return",
"new",
"List",
"(",
"this",
".",
"slice",
"(",
"index",
",",
"index",
"+",
"count",
")",
")",
";",
"}"
] | Creates a shallow copy of a range of elements in the source List.
@param {Number} index The zero-based List index at which the range starts.
@param {Number} count The number of elements in the range.
@returns {List} | [
"Creates",
"a",
"shallow",
"copy",
"of",
"a",
"range",
"of",
"elements",
"in",
"the",
"source",
"List",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/list.js#L255-L258 | |
32,062 | multiplex/multiplex.js | src/lib/collections/list.js | function (index, item) {
if (index !== this.length) {
validateListIndex(this, index);
}
var len = ++this.length;
while (len-- > index) {
this[len] = this[len - 1];
}
this[index] = item;
} | javascript | function (index, item) {
if (index !== this.length) {
validateListIndex(this, index);
}
var len = ++this.length;
while (len-- > index) {
this[len] = this[len - 1];
}
this[index] = item;
} | [
"function",
"(",
"index",
",",
"item",
")",
"{",
"if",
"(",
"index",
"!==",
"this",
".",
"length",
")",
"{",
"validateListIndex",
"(",
"this",
",",
"index",
")",
";",
"}",
"var",
"len",
"=",
"++",
"this",
".",
"length",
";",
"while",
"(",
"len",
... | Inserts an element into the List at the specified index.
@param {Number} index The zero-based index at which item should be inserted.
@param {Object} item The object to insert. | [
"Inserts",
"an",
"element",
"into",
"the",
"List",
"at",
"the",
"specified",
"index",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/list.js#L274-L286 | |
32,063 | multiplex/multiplex.js | src/lib/collections/list.js | function (index, collection) {
assertType(index, Number);
assertNotNull(collection);
if (index !== this.length) {
validateListIndex(this, index);
}
var arr = buffer(collection),
count = arr.length,
len = this.length + count;
this.length = len;
while (len-- > index) {
this[len] = this[len - count];
}
while (count-- > 0) {
this[index + count] = arr[count];
}
} | javascript | function (index, collection) {
assertType(index, Number);
assertNotNull(collection);
if (index !== this.length) {
validateListIndex(this, index);
}
var arr = buffer(collection),
count = arr.length,
len = this.length + count;
this.length = len;
while (len-- > index) {
this[len] = this[len - count];
}
while (count-- > 0) {
this[index + count] = arr[count];
}
} | [
"function",
"(",
"index",
",",
"collection",
")",
"{",
"assertType",
"(",
"index",
",",
"Number",
")",
";",
"assertNotNull",
"(",
"collection",
")",
";",
"if",
"(",
"index",
"!==",
"this",
".",
"length",
")",
"{",
"validateListIndex",
"(",
"this",
",",
... | Inserts the elements of a collection into the List at the specified index.
@param {Number} index The zero-based index at which item should be inserted.
@param {Iterable} collection The collection whose elements should be inserted into the List. | [
"Inserts",
"the",
"elements",
"of",
"a",
"collection",
"into",
"the",
"List",
"at",
"the",
"specified",
"index",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/list.js#L293-L314 | |
32,064 | multiplex/multiplex.js | src/lib/collections/list.js | function (match) {
assertType(match, Function);
var freeIndex = 0,
len = this.length;
while (freeIndex < len && !match(this[freeIndex])) {
freeIndex++;
}
if (freeIndex >= len) {
return 0;
}
var current = freeIndex + 1;
while (current < len) {
while (current < len && match(this[current])) {
current++;
}
if (current < len) {
this[freeIndex++] = this[current++];
}
}
shrinkList(this, freeIndex);
return len - freeIndex;
} | javascript | function (match) {
assertType(match, Function);
var freeIndex = 0,
len = this.length;
while (freeIndex < len && !match(this[freeIndex])) {
freeIndex++;
}
if (freeIndex >= len) {
return 0;
}
var current = freeIndex + 1;
while (current < len) {
while (current < len && match(this[current])) {
current++;
}
if (current < len) {
this[freeIndex++] = this[current++];
}
}
shrinkList(this, freeIndex);
return len - freeIndex;
} | [
"function",
"(",
"match",
")",
"{",
"assertType",
"(",
"match",
",",
"Function",
")",
";",
"var",
"freeIndex",
"=",
"0",
",",
"len",
"=",
"this",
".",
"length",
";",
"while",
"(",
"freeIndex",
"<",
"len",
"&&",
"!",
"match",
"(",
"this",
"[",
"free... | Removes all the elements that match the conditions defined by the specified predicate.
@param {Function} match The predicate function that defines the conditions of the elements to remove. eg. function(item)
@returns {Number} | [
"Removes",
"all",
"the",
"elements",
"that",
"match",
"the",
"conditions",
"defined",
"by",
"the",
"specified",
"predicate",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/list.js#L346-L374 | |
32,065 | multiplex/multiplex.js | src/lib/collections/list.js | function (index) {
validateListIndex(this, index);
var i = index,
len = --this.length;
for (; i < len; i++) {
this[i] = this[i + 1];
}
delete this[len];
} | javascript | function (index) {
validateListIndex(this, index);
var i = index,
len = --this.length;
for (; i < len; i++) {
this[i] = this[i + 1];
}
delete this[len];
} | [
"function",
"(",
"index",
")",
"{",
"validateListIndex",
"(",
"this",
",",
"index",
")",
";",
"var",
"i",
"=",
"index",
",",
"len",
"=",
"--",
"this",
".",
"length",
";",
"for",
"(",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"this",
"[",
... | Removes the element at the specified index of the List.
@param {Number} index The zero-based index of the element to remove. | [
"Removes",
"the",
"element",
"at",
"the",
"specified",
"index",
"of",
"the",
"List",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/list.js#L380-L391 | |
32,066 | multiplex/multiplex.js | src/lib/collections/list.js | function (index, count) {
validateListIndex(this, index + count - 1);
var len = this.length - count;
for (; index < len; index++) {
this[index] = this[index + count];
}
shrinkList(this, len);
} | javascript | function (index, count) {
validateListIndex(this, index + count - 1);
var len = this.length - count;
for (; index < len; index++) {
this[index] = this[index + count];
}
shrinkList(this, len);
} | [
"function",
"(",
"index",
",",
"count",
")",
"{",
"validateListIndex",
"(",
"this",
",",
"index",
"+",
"count",
"-",
"1",
")",
";",
"var",
"len",
"=",
"this",
".",
"length",
"-",
"count",
";",
"for",
"(",
";",
"index",
"<",
"len",
";",
"index",
"... | Removes a range of elements from the List.
@param {Number} index The zero-based index of the element to remove.
@param {Number} count The number of elements to remove. | [
"Removes",
"a",
"range",
"of",
"elements",
"from",
"the",
"List",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/list.js#L398-L408 | |
32,067 | multiplex/multiplex.js | src/lib/collections/list.js | function (index, count) {
index = index || 0;
count = count || this.length;
validateListIndex(this, index + count - 1);
var arr = this.slice(index, index + count).reverse(),
len = arr.length;
while (len-- > 0) {
this[len + index] = arr[len];
}
return this;
} | javascript | function (index, count) {
index = index || 0;
count = count || this.length;
validateListIndex(this, index + count - 1);
var arr = this.slice(index, index + count).reverse(),
len = arr.length;
while (len-- > 0) {
this[len + index] = arr[len];
}
return this;
} | [
"function",
"(",
"index",
",",
"count",
")",
"{",
"index",
"=",
"index",
"||",
"0",
";",
"count",
"=",
"count",
"||",
"this",
".",
"length",
";",
"validateListIndex",
"(",
"this",
",",
"index",
"+",
"count",
"-",
"1",
")",
";",
"var",
"arr",
"=",
... | Reverses the order of the elements in the specified range.
@param {Number=} index The zero-based starting index of the range to reverse.
@param {Number=} count The number of elements in the range to reverse. | [
"Reverses",
"the",
"order",
"of",
"the",
"elements",
"in",
"the",
"specified",
"range",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/list.js#L415-L428 | |
32,068 | multiplex/multiplex.js | src/lib/collections/list.js | function (indexOrComparer, count, comparer) {
var index = isNumber(indexOrComparer) ? indexOrComparer : 0,
total = count || this.length - index,
comparision = indexOrComparer === null ? null :
(isFunction(indexOrComparer) ? indexOrComparer :
Comparer.from(comparer || indexOrComparer).compare);
validateListIndex(this, index + total - 1);
var arr = this.slice(index, index + total).sort(comparision),
len = arr.length;
while (len-- > 0) {
this[len + index] = arr[len];
}
} | javascript | function (indexOrComparer, count, comparer) {
var index = isNumber(indexOrComparer) ? indexOrComparer : 0,
total = count || this.length - index,
comparision = indexOrComparer === null ? null :
(isFunction(indexOrComparer) ? indexOrComparer :
Comparer.from(comparer || indexOrComparer).compare);
validateListIndex(this, index + total - 1);
var arr = this.slice(index, index + total).sort(comparision),
len = arr.length;
while (len-- > 0) {
this[len + index] = arr[len];
}
} | [
"function",
"(",
"indexOrComparer",
",",
"count",
",",
"comparer",
")",
"{",
"var",
"index",
"=",
"isNumber",
"(",
"indexOrComparer",
")",
"?",
"indexOrComparer",
":",
"0",
",",
"total",
"=",
"count",
"||",
"this",
".",
"length",
"-",
"index",
",",
"comp... | Sorts the elements in a range of elements in List using the specified comparer.
@param {Number|Function|Comparer} val The starting index, the comparison function or the Comparer.
@param {Number=} count The length of the range to sort.
@param {Comparer=} comparer The Comparer implementation to use when comparing elements. | [
"Sorts",
"the",
"elements",
"in",
"a",
"range",
"of",
"elements",
"in",
"List",
"using",
"the",
"specified",
"comparer",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/list.js#L463-L478 | |
32,069 | multiplex/multiplex.js | src/lib/collections/list.js | function (match) {
assertType(match, Function);
for (var i = 0, len = this.length; i < len; i++) {
if (match(this[i]) === false) {
return false;
}
}
return true;
} | javascript | function (match) {
assertType(match, Function);
for (var i = 0, len = this.length; i < len; i++) {
if (match(this[i]) === false) {
return false;
}
}
return true;
} | [
"function",
"(",
"match",
")",
"{",
"assertType",
"(",
"match",
",",
"Function",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"this",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"match",
"(",
"thi... | Determines whether every element in the List matches the conditions defined by the specified predicate.
@param {Function} match The Predicate function that defines the conditions to check against the elements, eg. function(item)
@returns {Boolean} | [
"Determines",
"whether",
"every",
"element",
"in",
"the",
"List",
"matches",
"the",
"conditions",
"defined",
"by",
"the",
"specified",
"predicate",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/list.js#L493-L503 | |
32,070 | multiplex/multiplex.js | src/lib/runtime/runtime.js | hashMany | function hashMany(obj) {
var h = hash(obj, false);
// Combine hash codes for given inputs
if (arguments.length > 1) {
var len = arguments.length,
i = 0;
while (i < len) {
h = combineHash(h, hash(arguments[i++], false));
}
}
return h;
} | javascript | function hashMany(obj) {
var h = hash(obj, false);
// Combine hash codes for given inputs
if (arguments.length > 1) {
var len = arguments.length,
i = 0;
while (i < len) {
h = combineHash(h, hash(arguments[i++], false));
}
}
return h;
} | [
"function",
"hashMany",
"(",
"obj",
")",
"{",
"var",
"h",
"=",
"hash",
"(",
"obj",
",",
"false",
")",
";",
"// Combine hash codes for given inputs",
"if",
"(",
"arguments",
".",
"length",
">",
"1",
")",
"{",
"var",
"len",
"=",
"arguments",
".",
"length",... | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures such as a hash table.
@param {Object} obj An object to retrieve the hash code for.
@param {...Objects} rest Optional number of objects to combine their hash codes.
@returns {Number} | [
"Serves",
"as",
"a",
"hash",
"function",
"for",
"a",
"particular",
"type",
"suitable",
"for",
"use",
"in",
"hashing",
"algorithms",
"and",
"data",
"structures",
"such",
"as",
"a",
"hash",
"table",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/runtime/runtime.js#L32-L46 |
32,071 | multiplex/multiplex.js | external/lodash/lodash.core.js | basePick | function basePick(object, props) {
object = Object(object);
return reduce(props, function(result, key) {
if (key in object) {
result[key] = object[key];
}
return result;
}, {});
} | javascript | function basePick(object, props) {
object = Object(object);
return reduce(props, function(result, key) {
if (key in object) {
result[key] = object[key];
}
return result;
}, {});
} | [
"function",
"basePick",
"(",
"object",
",",
"props",
")",
"{",
"object",
"=",
"Object",
"(",
"object",
")",
";",
"return",
"reduce",
"(",
"props",
",",
"function",
"(",
"result",
",",
"key",
")",
"{",
"if",
"(",
"key",
"in",
"object",
")",
"{",
"re... | The base implementation of `_.pick` without support for individual
property identifiers.
@private
@param {Object} object The source object.
@param {string[]} props The property identifiers to pick.
@returns {Object} Returns the new object. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"pick",
"without",
"support",
"for",
"individual",
"property",
"identifiers",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/external/lodash/lodash.core.js#L796-L804 |
32,072 | multiplex/multiplex.js | src/lib/collections/linked-list.js | function () {
while (this.head !== null) {
var temp = this.head;
this.head = this.head.next(); // use next() the instead of "_next", otherwise it will loop forever
temp._list = null;
temp._next = null;
temp._prev = null;
}
this.head = null;
this.size = 0;
} | javascript | function () {
while (this.head !== null) {
var temp = this.head;
this.head = this.head.next(); // use next() the instead of "_next", otherwise it will loop forever
temp._list = null;
temp._next = null;
temp._prev = null;
}
this.head = null;
this.size = 0;
} | [
"function",
"(",
")",
"{",
"while",
"(",
"this",
".",
"head",
"!==",
"null",
")",
"{",
"var",
"temp",
"=",
"this",
".",
"head",
";",
"this",
".",
"head",
"=",
"this",
".",
"head",
".",
"next",
"(",
")",
";",
"// use next() the instead of \"_next\", oth... | Removes all nodes from the LinkedList. | [
"Removes",
"all",
"nodes",
"from",
"the",
"LinkedList",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/linked-list.js#L40-L51 | |
32,073 | multiplex/multiplex.js | src/lib/collections/linked-list.js | function (node, value) {
assertType(node, LinkedListNode);
var newNode;
if (value instanceof LinkedListNode) {
newNode = value;
this.insertNodeBefore(node._next, newNode);
}
else {
newNode = new LinkedListNode(value);
this.addAfter(node, newNode);
}
return newNode;
} | javascript | function (node, value) {
assertType(node, LinkedListNode);
var newNode;
if (value instanceof LinkedListNode) {
newNode = value;
this.insertNodeBefore(node._next, newNode);
}
else {
newNode = new LinkedListNode(value);
this.addAfter(node, newNode);
}
return newNode;
} | [
"function",
"(",
"node",
",",
"value",
")",
"{",
"assertType",
"(",
"node",
",",
"LinkedListNode",
")",
";",
"var",
"newNode",
";",
"if",
"(",
"value",
"instanceof",
"LinkedListNode",
")",
"{",
"newNode",
"=",
"value",
";",
"this",
".",
"insertNodeBefore",... | Adds the specified new node after the specified existing node in the LinkedList.
@param {LinkedListNode} node The LinkedListNode after which to insert newNode.
@param {LinkedListNode|Object} value The value or the LinkedListNode to add to the LinkedList.
@returns {LinkedListNode} | [
"Adds",
"the",
"specified",
"new",
"node",
"after",
"the",
"specified",
"existing",
"node",
"in",
"the",
"LinkedList",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/linked-list.js#L94-L109 | |
32,074 | multiplex/multiplex.js | src/lib/collections/linked-list.js | function (node, value) {
assertType(node, LinkedListNode);
var newNode;
if (value instanceof LinkedListNode) {
newNode = value;
this.insertNodeBefore(node, newNode);
if (node === this.head) {
this.head = newNode;
}
}
else {
newNode = new LinkedListNode(value);
this.addBefore(node, newNode);
}
return newNode;
} | javascript | function (node, value) {
assertType(node, LinkedListNode);
var newNode;
if (value instanceof LinkedListNode) {
newNode = value;
this.insertNodeBefore(node, newNode);
if (node === this.head) {
this.head = newNode;
}
}
else {
newNode = new LinkedListNode(value);
this.addBefore(node, newNode);
}
return newNode;
} | [
"function",
"(",
"node",
",",
"value",
")",
"{",
"assertType",
"(",
"node",
",",
"LinkedListNode",
")",
";",
"var",
"newNode",
";",
"if",
"(",
"value",
"instanceof",
"LinkedListNode",
")",
"{",
"newNode",
"=",
"value",
";",
"this",
".",
"insertNodeBefore",... | Adds the specified new node before the specified existing node in the LinkedList.
@param {LinkedListNode} node The LinkedListNode before which to insert newNode.
@param {LinkedListNode|Object} value The value or the LinkedListNode to add to the LinkedList.
@returns {LinkedListNode} | [
"Adds",
"the",
"specified",
"new",
"node",
"before",
"the",
"specified",
"existing",
"node",
"in",
"the",
"LinkedList",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/linked-list.js#L117-L135 | |
32,075 | multiplex/multiplex.js | src/lib/collections/linked-list.js | function (value) {
var node;
if (value instanceof LinkedListNode) {
node = value;
validateNode(node, null);
if (this.head === null) {
this.insertNodeToEmptyList(node);
}
else {
this.insertNodeBefore(this.head, node);
this.head = node;
}
}
else {
node = new LinkedListNode(value);
this.addFirst(node);
}
return node;
} | javascript | function (value) {
var node;
if (value instanceof LinkedListNode) {
node = value;
validateNode(node, null);
if (this.head === null) {
this.insertNodeToEmptyList(node);
}
else {
this.insertNodeBefore(this.head, node);
this.head = node;
}
}
else {
node = new LinkedListNode(value);
this.addFirst(node);
}
return node;
} | [
"function",
"(",
"value",
")",
"{",
"var",
"node",
";",
"if",
"(",
"value",
"instanceof",
"LinkedListNode",
")",
"{",
"node",
"=",
"value",
";",
"validateNode",
"(",
"node",
",",
"null",
")",
";",
"if",
"(",
"this",
".",
"head",
"===",
"null",
")",
... | Adds the specified new node at the start of the LinkedList.
@param {LinkedListNode|Object} value The value or the LinkedListNode to add at the start of the LinkedList.
@returns {LinkedListNode} | [
"Adds",
"the",
"specified",
"new",
"node",
"at",
"the",
"start",
"of",
"the",
"LinkedList",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/linked-list.js#L142-L163 | |
32,076 | multiplex/multiplex.js | src/lib/collections/linked-list.js | function (value) {
var node = this.head;
if (node !== null) {
if (value !== null) {
do {
if (runtimeEquals(node._value, value)) {
return node;
}
node = node._next;
}
while (node !== this.head);
}
else {
do {
if (node._value === null) {
return node;
}
node = node._next;
}
while (node !== this.head);
}
}
return null;
} | javascript | function (value) {
var node = this.head;
if (node !== null) {
if (value !== null) {
do {
if (runtimeEquals(node._value, value)) {
return node;
}
node = node._next;
}
while (node !== this.head);
}
else {
do {
if (node._value === null) {
return node;
}
node = node._next;
}
while (node !== this.head);
}
}
return null;
} | [
"function",
"(",
"value",
")",
"{",
"var",
"node",
"=",
"this",
".",
"head",
";",
"if",
"(",
"node",
"!==",
"null",
")",
"{",
"if",
"(",
"value",
"!==",
"null",
")",
"{",
"do",
"{",
"if",
"(",
"runtimeEquals",
"(",
"node",
".",
"_value",
",",
"... | Finds the first node that contains the specified value.
@param {Object} value The value to locate in the LinkedList.
@returns {LinkedListNode} | [
"Finds",
"the",
"first",
"node",
"that",
"contains",
"the",
"specified",
"value",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/linked-list.js#L197-L223 | |
32,077 | multiplex/multiplex.js | src/lib/collections/linked-list.js | function (value) {
if (this.head === null) {
return null;
}
var last = this.head._prev,
node = last;
if (node !== null) {
if (value !== null) {
do {
if (runtimeEquals(node._value, value)) {
return node;
}
node = node._prev;
}
while (node !== last);
}
else {
do {
if (node._value === null) {
return node;
}
node = node._prev;
}
while (node !== last);
}
}
return null;
} | javascript | function (value) {
if (this.head === null) {
return null;
}
var last = this.head._prev,
node = last;
if (node !== null) {
if (value !== null) {
do {
if (runtimeEquals(node._value, value)) {
return node;
}
node = node._prev;
}
while (node !== last);
}
else {
do {
if (node._value === null) {
return node;
}
node = node._prev;
}
while (node !== last);
}
}
return null;
} | [
"function",
"(",
"value",
")",
"{",
"if",
"(",
"this",
".",
"head",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"var",
"last",
"=",
"this",
".",
"head",
".",
"_prev",
",",
"node",
"=",
"last",
";",
"if",
"(",
"node",
"!==",
"null",
")"... | Finds the last node that contains the specified value.
@param {Object} value The value to locate in the LinkedList.
@returns {LinkedListNode} | [
"Finds",
"the",
"last",
"node",
"that",
"contains",
"the",
"specified",
"value",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/linked-list.js#L230-L262 | |
32,078 | multiplex/multiplex.js | src/lib/collections/linked-list.js | function (value) {
var node;
if (value instanceof LinkedListNode) {
node = value;
validateNode(node, this);
if (node._next === node) {
this.head = null;
}
else {
node._next._prev = node._prev;
node._prev._next = node._next;
if (this.head === node) {
this.head = node._next;
}
}
node._list = null;
node._next = null;
node._prev = null;
this.size--;
return true;
}
else {
if ((node = this.find(value)) !== null) {
this.remove(node);
return true;
}
return false;
}
} | javascript | function (value) {
var node;
if (value instanceof LinkedListNode) {
node = value;
validateNode(node, this);
if (node._next === node) {
this.head = null;
}
else {
node._next._prev = node._prev;
node._prev._next = node._next;
if (this.head === node) {
this.head = node._next;
}
}
node._list = null;
node._next = null;
node._prev = null;
this.size--;
return true;
}
else {
if ((node = this.find(value)) !== null) {
this.remove(node);
return true;
}
return false;
}
} | [
"function",
"(",
"value",
")",
"{",
"var",
"node",
";",
"if",
"(",
"value",
"instanceof",
"LinkedListNode",
")",
"{",
"node",
"=",
"value",
";",
"validateNode",
"(",
"node",
",",
"this",
")",
";",
"if",
"(",
"node",
".",
"_next",
"===",
"node",
")",
... | Removes Removes the specified node or the first occurrence of the specified value from the LinkedList.
@param {LinkedListNode|Object} value The LinkedListNode or the value to remove from the LinkedList.
@returns {Boolean} | [
"Removes",
"Removes",
"the",
"specified",
"node",
"or",
"the",
"first",
"occurrence",
"of",
"the",
"specified",
"value",
"from",
"the",
"LinkedList",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/linked-list.js#L269-L301 | |
32,079 | multiplex/multiplex.js | tasks/build.js | transpile | function transpile() {
return rollup.rollup({
entry: path.join(dirs.source, files.main)
}).then(function (bundle) {
return bundle.write({
// output format - 'amd', 'cjs', 'es6', 'iife', 'umd'
format: 'umd',
dest: path.join(dirs.build, files.main),
sourceMap: false,
banner: grunt.config('banner'),
intro: 'mx.version = \'' + grunt.config('pkg').version + '\';\n',
footer: '\n',
moduleName: 'mx'
});
});
} | javascript | function transpile() {
return rollup.rollup({
entry: path.join(dirs.source, files.main)
}).then(function (bundle) {
return bundle.write({
// output format - 'amd', 'cjs', 'es6', 'iife', 'umd'
format: 'umd',
dest: path.join(dirs.build, files.main),
sourceMap: false,
banner: grunt.config('banner'),
intro: 'mx.version = \'' + grunt.config('pkg').version + '\';\n',
footer: '\n',
moduleName: 'mx'
});
});
} | [
"function",
"transpile",
"(",
")",
"{",
"return",
"rollup",
".",
"rollup",
"(",
"{",
"entry",
":",
"path",
".",
"join",
"(",
"dirs",
".",
"source",
",",
"files",
".",
"main",
")",
"}",
")",
".",
"then",
"(",
"function",
"(",
"bundle",
")",
"{",
"... | transpile es6 modules | [
"transpile",
"es6",
"modules"
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/tasks/build.js#L21-L36 |
32,080 | multiplex/multiplex.js | external/qunit/qunit.js | function( name, testEnvironment, executeNow ) {
var module, moduleFns;
var currentModule = config.currentModule;
if ( arguments.length === 2 ) {
if ( objectType( testEnvironment ) === "function" ) {
executeNow = testEnvironment;
testEnvironment = undefined;
}
}
module = createModule();
if ( testEnvironment && ( testEnvironment.setup || testEnvironment.teardown ) ) {
console.warn(
"Module's `setup` and `teardown` are not hooks anymore on QUnit 2.0, use " +
"`beforeEach` and `afterEach` instead\n" +
"Details in our upgrade guide at https://qunitjs.com/upgrade-guide-2.x/"
);
}
moduleFns = {
before: setHook( module, "before" ),
beforeEach: setHook( module, "beforeEach" ),
afterEach: setHook( module, "afterEach" ),
after: setHook( module, "after" )
};
if ( objectType( executeNow ) === "function" ) {
config.moduleStack.push( module );
setCurrentModule( module );
executeNow.call( module.testEnvironment, moduleFns );
config.moduleStack.pop();
module = module.parentModule || currentModule;
}
setCurrentModule( module );
function createModule() {
var parentModule = config.moduleStack.length ?
config.moduleStack.slice( -1 )[ 0 ] : null;
var moduleName = parentModule !== null ?
[ parentModule.name, name ].join( " > " ) : name;
var module = {
name: moduleName,
parentModule: parentModule,
tests: [],
moduleId: generateHash( moduleName ),
testsRun: 0
};
var env = {};
if ( parentModule ) {
parentModule.childModule = module;
extend( env, parentModule.testEnvironment );
delete env.beforeEach;
delete env.afterEach;
}
extend( env, testEnvironment );
module.testEnvironment = env;
config.modules.push( module );
return module;
}
function setCurrentModule( module ) {
config.currentModule = module;
}
} | javascript | function( name, testEnvironment, executeNow ) {
var module, moduleFns;
var currentModule = config.currentModule;
if ( arguments.length === 2 ) {
if ( objectType( testEnvironment ) === "function" ) {
executeNow = testEnvironment;
testEnvironment = undefined;
}
}
module = createModule();
if ( testEnvironment && ( testEnvironment.setup || testEnvironment.teardown ) ) {
console.warn(
"Module's `setup` and `teardown` are not hooks anymore on QUnit 2.0, use " +
"`beforeEach` and `afterEach` instead\n" +
"Details in our upgrade guide at https://qunitjs.com/upgrade-guide-2.x/"
);
}
moduleFns = {
before: setHook( module, "before" ),
beforeEach: setHook( module, "beforeEach" ),
afterEach: setHook( module, "afterEach" ),
after: setHook( module, "after" )
};
if ( objectType( executeNow ) === "function" ) {
config.moduleStack.push( module );
setCurrentModule( module );
executeNow.call( module.testEnvironment, moduleFns );
config.moduleStack.pop();
module = module.parentModule || currentModule;
}
setCurrentModule( module );
function createModule() {
var parentModule = config.moduleStack.length ?
config.moduleStack.slice( -1 )[ 0 ] : null;
var moduleName = parentModule !== null ?
[ parentModule.name, name ].join( " > " ) : name;
var module = {
name: moduleName,
parentModule: parentModule,
tests: [],
moduleId: generateHash( moduleName ),
testsRun: 0
};
var env = {};
if ( parentModule ) {
parentModule.childModule = module;
extend( env, parentModule.testEnvironment );
delete env.beforeEach;
delete env.afterEach;
}
extend( env, testEnvironment );
module.testEnvironment = env;
config.modules.push( module );
return module;
}
function setCurrentModule( module ) {
config.currentModule = module;
}
} | [
"function",
"(",
"name",
",",
"testEnvironment",
",",
"executeNow",
")",
"{",
"var",
"module",
",",
"moduleFns",
";",
"var",
"currentModule",
"=",
"config",
".",
"currentModule",
";",
"if",
"(",
"arguments",
".",
"length",
"===",
"2",
")",
"{",
"if",
"("... | Call on start of module test to prepend name to all tests | [
"Call",
"on",
"start",
"of",
"module",
"test",
"to",
"prepend",
"name",
"to",
"all",
"tests"
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/external/qunit/qunit.js#L342-L411 | |
32,081 | multiplex/multiplex.js | external/qunit/qunit.js | skip | function skip( testName ) {
if ( focused ) { return; }
var test = new Test( {
testName: testName,
skip: true
} );
test.queue();
} | javascript | function skip( testName ) {
if ( focused ) { return; }
var test = new Test( {
testName: testName,
skip: true
} );
test.queue();
} | [
"function",
"skip",
"(",
"testName",
")",
"{",
"if",
"(",
"focused",
")",
"{",
"return",
";",
"}",
"var",
"test",
"=",
"new",
"Test",
"(",
"{",
"testName",
":",
"testName",
",",
"skip",
":",
"true",
"}",
")",
";",
"test",
".",
"queue",
"(",
")",
... | Will be exposed as QUnit.skip | [
"Will",
"be",
"exposed",
"as",
"QUnit",
".",
"skip"
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/external/qunit/qunit.js#L1222-L1231 |
32,082 | multiplex/multiplex.js | external/qunit/qunit.js | selectionChange | function selectionChange( evt ) {
var i,
checkbox = evt && evt.target || allCheckbox,
modulesList = dropDownList.getElementsByTagName( "input" ),
selectedNames = [];
toggleClass( checkbox.parentNode, "checked", checkbox.checked );
dirty = false;
if ( checkbox.checked && checkbox !== allCheckbox ) {
allCheckbox.checked = false;
removeClass( allCheckbox.parentNode, "checked" );
}
for ( i = 0; i < modulesList.length; i++ ) {
if ( !evt ) {
toggleClass( modulesList[ i ].parentNode, "checked", modulesList[ i ].checked );
} else if ( checkbox === allCheckbox && checkbox.checked ) {
modulesList[ i ].checked = false;
removeClass( modulesList[ i ].parentNode, "checked" );
}
dirty = dirty || ( checkbox.checked !== checkbox.defaultChecked );
if ( modulesList[ i ].checked ) {
selectedNames.push( modulesList[ i ].parentNode.textContent );
}
}
commit.style.display = reset.style.display = dirty ? "" : "none";
moduleSearch.placeholder = selectedNames.join( ", " ) || allCheckbox.parentNode.textContent;
moduleSearch.title = "Type to filter list. Current selection:\n" +
( selectedNames.join( "\n" ) || allCheckbox.parentNode.textContent );
} | javascript | function selectionChange( evt ) {
var i,
checkbox = evt && evt.target || allCheckbox,
modulesList = dropDownList.getElementsByTagName( "input" ),
selectedNames = [];
toggleClass( checkbox.parentNode, "checked", checkbox.checked );
dirty = false;
if ( checkbox.checked && checkbox !== allCheckbox ) {
allCheckbox.checked = false;
removeClass( allCheckbox.parentNode, "checked" );
}
for ( i = 0; i < modulesList.length; i++ ) {
if ( !evt ) {
toggleClass( modulesList[ i ].parentNode, "checked", modulesList[ i ].checked );
} else if ( checkbox === allCheckbox && checkbox.checked ) {
modulesList[ i ].checked = false;
removeClass( modulesList[ i ].parentNode, "checked" );
}
dirty = dirty || ( checkbox.checked !== checkbox.defaultChecked );
if ( modulesList[ i ].checked ) {
selectedNames.push( modulesList[ i ].parentNode.textContent );
}
}
commit.style.display = reset.style.display = dirty ? "" : "none";
moduleSearch.placeholder = selectedNames.join( ", " ) || allCheckbox.parentNode.textContent;
moduleSearch.title = "Type to filter list. Current selection:\n" +
( selectedNames.join( "\n" ) || allCheckbox.parentNode.textContent );
} | [
"function",
"selectionChange",
"(",
"evt",
")",
"{",
"var",
"i",
",",
"checkbox",
"=",
"evt",
"&&",
"evt",
".",
"target",
"||",
"allCheckbox",
",",
"modulesList",
"=",
"dropDownList",
".",
"getElementsByTagName",
"(",
"\"input\"",
")",
",",
"selectedNames",
... | Processes selection changes | [
"Processes",
"selection",
"changes"
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/external/qunit/qunit.js#L2786-L2816 |
32,083 | multiplex/multiplex.js | src/lib/collections/comparer.js | function (value) {
if (value === null || value === undefined || value === defaultComparer) {
return defaultComparer;
}
else if (value instanceof Comparer) {
return value;
}
else if (isFunction(value)) {
return new Comparer(value);
}
else if (isFunction(value.compare)) {
return new Comparer(value.compare);
}
else {
return defaultComparer;
}
} | javascript | function (value) {
if (value === null || value === undefined || value === defaultComparer) {
return defaultComparer;
}
else if (value instanceof Comparer) {
return value;
}
else if (isFunction(value)) {
return new Comparer(value);
}
else if (isFunction(value.compare)) {
return new Comparer(value.compare);
}
else {
return defaultComparer;
}
} | [
"function",
"(",
"value",
")",
"{",
"if",
"(",
"value",
"===",
"null",
"||",
"value",
"===",
"undefined",
"||",
"value",
"===",
"defaultComparer",
")",
"{",
"return",
"defaultComparer",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"Comparer",
")",
... | Gets or creates a new Comparer object.
@param {Comparer|Object} value A Comparer object.
@returns {Comparer} | [
"Gets",
"or",
"creates",
"a",
"new",
"Comparer",
"object",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/comparer.js#L48-L68 | |
32,084 | multiplex/multiplex.js | src/lib/collections/equality-comparer.js | function (value) {
if (value === null || value === undefined || value === defaultEqualityComparer) {
return defaultEqualityComparer;
}
else if (value instanceof EqualityComparer) {
return value;
}
else if (isFunction(value.hash) && isFunction(value.equals)) {
return new EqualityComparer(value.hash, value.equals);
}
return defaultEqualityComparer;
} | javascript | function (value) {
if (value === null || value === undefined || value === defaultEqualityComparer) {
return defaultEqualityComparer;
}
else if (value instanceof EqualityComparer) {
return value;
}
else if (isFunction(value.hash) && isFunction(value.equals)) {
return new EqualityComparer(value.hash, value.equals);
}
return defaultEqualityComparer;
} | [
"function",
"(",
"value",
")",
"{",
"if",
"(",
"value",
"===",
"null",
"||",
"value",
"===",
"undefined",
"||",
"value",
"===",
"defaultEqualityComparer",
")",
"{",
"return",
"defaultEqualityComparer",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"Equ... | Gets or creates a new EqualityComparer object.
@param {EqualityComparer|Object} value An EqualityComparer object.
@returns {EqualityComparer} | [
"Gets",
"or",
"creates",
"a",
"new",
"EqualityComparer",
"object",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/equality-comparer.js#L54-L68 | |
32,085 | multiplex/multiplex.js | src/lib/collections/sorted-list.js | function (key, value) {
assertNotNull(key);
var index = binarySearch(this.slot.keys, 0, this.slot.size, key, this.slot.comparer.compare);
if (index >= 0) {
error(ERROR_DUPLICATE_KEY);
}
this.insert(~index, key, value);
} | javascript | function (key, value) {
assertNotNull(key);
var index = binarySearch(this.slot.keys, 0, this.slot.size, key, this.slot.comparer.compare);
if (index >= 0) {
error(ERROR_DUPLICATE_KEY);
}
this.insert(~index, key, value);
} | [
"function",
"(",
"key",
",",
"value",
")",
"{",
"assertNotNull",
"(",
"key",
")",
";",
"var",
"index",
"=",
"binarySearch",
"(",
"this",
".",
"slot",
".",
"keys",
",",
"0",
",",
"this",
".",
"slot",
".",
"size",
",",
"key",
",",
"this",
".",
"slo... | Adds an element with the specified key and value into the SortedList.
@param {Object} key The key of the element to add.
@param {Object} value The value of the element to add. | [
"Adds",
"an",
"element",
"with",
"the",
"specified",
"key",
"and",
"value",
"into",
"the",
"SortedList",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/sorted-list.js#L51-L61 | |
32,086 | multiplex/multiplex.js | src/lib/collections/sorted-list.js | function (value) {
if (value === null || value === undefined) {
return this.slot.keys.length;
} else {
assertType(value, Number);
if (value !== this.slot.keys.length) {
if (value < this.slot.size) {
error(ERROR_ARGUMENT_OUT_OF_RANGE);
}
this.slot.keys.length = value;
this.slot.values.length = value;
}
}
} | javascript | function (value) {
if (value === null || value === undefined) {
return this.slot.keys.length;
} else {
assertType(value, Number);
if (value !== this.slot.keys.length) {
if (value < this.slot.size) {
error(ERROR_ARGUMENT_OUT_OF_RANGE);
}
this.slot.keys.length = value;
this.slot.values.length = value;
}
}
} | [
"function",
"(",
"value",
")",
"{",
"if",
"(",
"value",
"===",
"null",
"||",
"value",
"===",
"undefined",
")",
"{",
"return",
"this",
".",
"slot",
".",
"keys",
".",
"length",
";",
"}",
"else",
"{",
"assertType",
"(",
"value",
",",
"Number",
")",
";... | Gets or sets the number of elements that the SortedList can contain.
@param {Number} value The number of elements that the SortedList can contain.
@returns {Number} | [
"Gets",
"or",
"sets",
"the",
"number",
"of",
"elements",
"that",
"the",
"SortedList",
"can",
"contain",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/sorted-list.js#L68-L83 | |
32,087 | multiplex/multiplex.js | src/lib/collections/sorted-list.js | function (key) {
assertNotNull(key);
return binarySearch(this.slot.keys, 0, this.slot.size, key, this.slot.comparer.compare);
} | javascript | function (key) {
assertNotNull(key);
return binarySearch(this.slot.keys, 0, this.slot.size, key, this.slot.comparer.compare);
} | [
"function",
"(",
"key",
")",
"{",
"assertNotNull",
"(",
"key",
")",
";",
"return",
"binarySearch",
"(",
"this",
".",
"slot",
".",
"keys",
",",
"0",
",",
"this",
".",
"slot",
".",
"size",
",",
"key",
",",
"this",
".",
"slot",
".",
"comparer",
".",
... | Searches for the specified key and returns the zero-based index within the entire SortedList.
@param {Object} key The key to locate in the SortedList.
@returns {Number} | [
"Searches",
"for",
"the",
"specified",
"key",
"and",
"returns",
"the",
"zero",
"-",
"based",
"index",
"within",
"the",
"entire",
"SortedList",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/sorted-list.js#L171-L174 | |
32,088 | multiplex/multiplex.js | src/lib/collections/sorted-list.js | function (index) {
assertType(index, Number);
if (index < 0 || index >= this.slot.size) {
error(ERROR_ARGUMENT_OUT_OF_RANGE);
}
this.slot.size--;
this.slot.keys.splice(index, 1);
this.slot.values.splice(index, 1);
this.slot.keys.length++;
this.slot.values.length++;
} | javascript | function (index) {
assertType(index, Number);
if (index < 0 || index >= this.slot.size) {
error(ERROR_ARGUMENT_OUT_OF_RANGE);
}
this.slot.size--;
this.slot.keys.splice(index, 1);
this.slot.values.splice(index, 1);
this.slot.keys.length++;
this.slot.values.length++;
} | [
"function",
"(",
"index",
")",
"{",
"assertType",
"(",
"index",
",",
"Number",
")",
";",
"if",
"(",
"index",
"<",
"0",
"||",
"index",
">=",
"this",
".",
"slot",
".",
"size",
")",
"{",
"error",
"(",
"ERROR_ARGUMENT_OUT_OF_RANGE",
")",
";",
"}",
"this"... | Removes the element at the specified index of the SortedList.
@param {Number} index The zero-based index of the element to remove. | [
"Removes",
"the",
"element",
"at",
"the",
"specified",
"index",
"of",
"the",
"SortedList",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/sorted-list.js#L206-L218 | |
32,089 | multiplex/multiplex.js | src/lib/collections/sorted-list.js | function (key, value) {
var index = this.indexOfKey(key);
if (index >= 0) {
this.slot.values[index] = value;
return;
}
this.insert(~index, key, value);
} | javascript | function (key, value) {
var index = this.indexOfKey(key);
if (index >= 0) {
this.slot.values[index] = value;
return;
}
this.insert(~index, key, value);
} | [
"function",
"(",
"key",
",",
"value",
")",
"{",
"var",
"index",
"=",
"this",
".",
"indexOfKey",
"(",
"key",
")",
";",
"if",
"(",
"index",
">=",
"0",
")",
"{",
"this",
".",
"slot",
".",
"values",
"[",
"index",
"]",
"=",
"value",
";",
"return",
"... | Sets the value associated with the specified key.
@param {Object} key The key whose value to get or set.
@param {Object} value The value associated with the specified key. | [
"Sets",
"the",
"value",
"associated",
"with",
"the",
"specified",
"key",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/sorted-list.js#L225-L234 | |
32,090 | multiplex/multiplex.js | src/lib/collections/sorted-list.js | function () {
var threshold = this.slot.keys.length * 0.9;
if (this.slot.size < threshold) {
this.capacity(this.slot.size);
}
} | javascript | function () {
var threshold = this.slot.keys.length * 0.9;
if (this.slot.size < threshold) {
this.capacity(this.slot.size);
}
} | [
"function",
"(",
")",
"{",
"var",
"threshold",
"=",
"this",
".",
"slot",
".",
"keys",
".",
"length",
"*",
"0.9",
";",
"if",
"(",
"this",
".",
"slot",
".",
"size",
"<",
"threshold",
")",
"{",
"this",
".",
"capacity",
"(",
"this",
".",
"slot",
".",... | Sets the capacity to the actual number of elements in the SortedList, if that number is less than 90 percent of current capacity. | [
"Sets",
"the",
"capacity",
"to",
"the",
"actual",
"number",
"of",
"elements",
"in",
"the",
"SortedList",
"if",
"that",
"number",
"is",
"less",
"than",
"90",
"percent",
"of",
"current",
"capacity",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/sorted-list.js#L239-L245 | |
32,091 | multiplex/multiplex.js | src/lib/collections/hash-set.js | function (other) {
assertNotNull(other);
if (this.count() === 0) {
return;
}
else if (other === this) {
this.clear();
return;
}
var table = this.table;
forOf(other, function (element) {
table.remove(element);
});
} | javascript | function (other) {
assertNotNull(other);
if (this.count() === 0) {
return;
}
else if (other === this) {
this.clear();
return;
}
var table = this.table;
forOf(other, function (element) {
table.remove(element);
});
} | [
"function",
"(",
"other",
")",
"{",
"assertNotNull",
"(",
"other",
")",
";",
"if",
"(",
"this",
".",
"count",
"(",
")",
"===",
"0",
")",
"{",
"return",
";",
"}",
"else",
"if",
"(",
"other",
"===",
"this",
")",
"{",
"this",
".",
"clear",
"(",
")... | Removes all elements in the specified collection from the current set.
@param {Iterable} other The collection of items to remove from the set. | [
"Removes",
"all",
"elements",
"in",
"the",
"specified",
"collection",
"from",
"the",
"current",
"set",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/hash-set.js#L74-L90 | |
32,092 | multiplex/multiplex.js | src/lib/collections/hash-set.js | function (other) {
assertNotNull(other);
// intersection of anything with empty set is empty set, so return if count is 0
if (this.count() === 0) {
return;
}
var c = collectionCount(other);
if (c !== -1) {
if (c === 0) {
this.clear();
return;
}
// If other is a HashSet, it has unique elements according to its equality comparer,
// but if they're using different equality comparers, then assumption of uniqueness
// will fail. So first check if other is a hashset using the same equality comparer;
// intersect is a lot faster if we can assume uniqueness.
if (areEqualityComparersEqual(this, other)) {
var arr = this.table.entries(true),
item;
c = this.count();
while (c-- > 0) {
item = arr[c];
if (!other.contains(item)) {
this.table.remove(item);
}
}
return;
}
}
this.intersectWith(new HashSet(other, this.compare));
} | javascript | function (other) {
assertNotNull(other);
// intersection of anything with empty set is empty set, so return if count is 0
if (this.count() === 0) {
return;
}
var c = collectionCount(other);
if (c !== -1) {
if (c === 0) {
this.clear();
return;
}
// If other is a HashSet, it has unique elements according to its equality comparer,
// but if they're using different equality comparers, then assumption of uniqueness
// will fail. So first check if other is a hashset using the same equality comparer;
// intersect is a lot faster if we can assume uniqueness.
if (areEqualityComparersEqual(this, other)) {
var arr = this.table.entries(true),
item;
c = this.count();
while (c-- > 0) {
item = arr[c];
if (!other.contains(item)) {
this.table.remove(item);
}
}
return;
}
}
this.intersectWith(new HashSet(other, this.compare));
} | [
"function",
"(",
"other",
")",
"{",
"assertNotNull",
"(",
"other",
")",
";",
"// intersection of anything with empty set is empty set, so return if count is 0",
"if",
"(",
"this",
".",
"count",
"(",
")",
"===",
"0",
")",
"{",
"return",
";",
"}",
"var",
"c",
"=",... | Modifies the current set so that it contains only elements that are also in a specified collection.
@param {Iterable} other The collection to compare to the current set. | [
"Modifies",
"the",
"current",
"set",
"so",
"that",
"it",
"contains",
"only",
"elements",
"that",
"are",
"also",
"in",
"a",
"specified",
"collection",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/hash-set.js#L96-L135 | |
32,093 | multiplex/multiplex.js | src/lib/collections/hash-set.js | function (other) {
assertNotNull(other);
var c = collectionCount(other);
if (c !== -1) {
// if other is the empty set then this is a superset
if (c === 0) {
return true;
}
else if (areEqualityComparersEqual(this, other)) {
if (c > this.count()) {
return false;
}
}
}
return containsAllElements(this, other);
} | javascript | function (other) {
assertNotNull(other);
var c = collectionCount(other);
if (c !== -1) {
// if other is the empty set then this is a superset
if (c === 0) {
return true;
}
else if (areEqualityComparersEqual(this, other)) {
if (c > this.count()) {
return false;
}
}
}
return containsAllElements(this, other);
} | [
"function",
"(",
"other",
")",
"{",
"assertNotNull",
"(",
"other",
")",
";",
"var",
"c",
"=",
"collectionCount",
"(",
"other",
")",
";",
"if",
"(",
"c",
"!==",
"-",
"1",
")",
"{",
"// if other is the empty set then this is a superset",
"if",
"(",
"c",
"===... | Determines whether the current set is a superset of a specified collection.
@param {Iterable} other The collection to compare to the current set.
@returns {Boolean} | [
"Determines",
"whether",
"the",
"current",
"set",
"is",
"a",
"superset",
"of",
"a",
"specified",
"collection",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/hash-set.js#L239-L258 | |
32,094 | multiplex/multiplex.js | src/lib/collections/hash-set.js | function (other) {
assertNotNull(other);
if (this.count() === 0) {
return false;
}
var table = this.table,
res = false;
forOf(other, function (element) {
if (table.contains(element)) {
res = true;
return res;
}
});
return res;
} | javascript | function (other) {
assertNotNull(other);
if (this.count() === 0) {
return false;
}
var table = this.table,
res = false;
forOf(other, function (element) {
if (table.contains(element)) {
res = true;
return res;
}
});
return res;
} | [
"function",
"(",
"other",
")",
"{",
"assertNotNull",
"(",
"other",
")",
";",
"if",
"(",
"this",
".",
"count",
"(",
")",
"===",
"0",
")",
"{",
"return",
"false",
";",
"}",
"var",
"table",
"=",
"this",
".",
"table",
",",
"res",
"=",
"false",
";",
... | Determines whether the current set overlaps with the specified collection.
@param {Iterable} other The collection to compare to the current set.
@returns {Boolean} | [
"Determines",
"whether",
"the",
"current",
"set",
"overlaps",
"with",
"the",
"specified",
"collection",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/hash-set.js#L265-L283 | |
32,095 | multiplex/multiplex.js | src/lib/collections/hash-set.js | function (match) {
assertType(match, Function);
var len = this.count(),
arr = this.table.entries(true),
removed = 0,
item;
while (len-- > 0) {
item = arr[len];
if (match(item) && this.table.remove(item)) {
removed++;
}
}
return removed;
} | javascript | function (match) {
assertType(match, Function);
var len = this.count(),
arr = this.table.entries(true),
removed = 0,
item;
while (len-- > 0) {
item = arr[len];
if (match(item) && this.table.remove(item)) {
removed++;
}
}
return removed;
} | [
"function",
"(",
"match",
")",
"{",
"assertType",
"(",
"match",
",",
"Function",
")",
";",
"var",
"len",
"=",
"this",
".",
"count",
"(",
")",
",",
"arr",
"=",
"this",
".",
"table",
".",
"entries",
"(",
"true",
")",
",",
"removed",
"=",
"0",
",",
... | Removes all elements that match the conditions defined by the specified predicate from a HashSet collection.
@param {Function} match The predicate function that defines the conditions of the elements to remove. eg. function(item)
@returns {Number} | [
"Removes",
"all",
"elements",
"that",
"match",
"the",
"conditions",
"defined",
"by",
"the",
"specified",
"predicate",
"from",
"a",
"HashSet",
"collection",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/hash-set.js#L299-L317 | |
32,096 | multiplex/multiplex.js | src/lib/collections/hash-set.js | function (other) {
assertNotNull(other);
if (this.count() === 0) {
this.unionWith(other);
return;
}
else if (other === this) {
this.clear();
return;
}
// If other is a HashSet, it has unique elements according to its equality comparer,
// but if they're using different equality comparers, then assumption of uniqueness
// will fail. So first check if other is a hashset using the same equality comparer;
// symmetric except is a lot faster if we can assume uniqueness
if (areEqualityComparersEqual(this, other)) {
var table = this.table;
forOf(other, function (element) {
if (!table.remove(element)) {
table.add(element, null);
}
});
}
else {
this.symmetricExceptWith(new HashSet(other, this.comparer));
}
} | javascript | function (other) {
assertNotNull(other);
if (this.count() === 0) {
this.unionWith(other);
return;
}
else if (other === this) {
this.clear();
return;
}
// If other is a HashSet, it has unique elements according to its equality comparer,
// but if they're using different equality comparers, then assumption of uniqueness
// will fail. So first check if other is a hashset using the same equality comparer;
// symmetric except is a lot faster if we can assume uniqueness
if (areEqualityComparersEqual(this, other)) {
var table = this.table;
forOf(other, function (element) {
if (!table.remove(element)) {
table.add(element, null);
}
});
}
else {
this.symmetricExceptWith(new HashSet(other, this.comparer));
}
} | [
"function",
"(",
"other",
")",
"{",
"assertNotNull",
"(",
"other",
")",
";",
"if",
"(",
"this",
".",
"count",
"(",
")",
"===",
"0",
")",
"{",
"this",
".",
"unionWith",
"(",
"other",
")",
";",
"return",
";",
"}",
"else",
"if",
"(",
"other",
"===",... | Modifies the current set so that it contains only elements that are present
either in the current set or in the specified collection, but not both.
@param {Iterable} other The collection to compare to the current set. | [
"Modifies",
"the",
"current",
"set",
"so",
"that",
"it",
"contains",
"only",
"elements",
"that",
"are",
"present",
"either",
"in",
"the",
"current",
"set",
"or",
"in",
"the",
"specified",
"collection",
"but",
"not",
"both",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/hash-set.js#L356-L386 | |
32,097 | multiplex/multiplex.js | src/lib/collections/hash-set.js | function (other) {
assertNotNull(other);
var table = this.table;
forOf(other, function (element) {
table.add(element);
});
} | javascript | function (other) {
assertNotNull(other);
var table = this.table;
forOf(other, function (element) {
table.add(element);
});
} | [
"function",
"(",
"other",
")",
"{",
"assertNotNull",
"(",
"other",
")",
";",
"var",
"table",
"=",
"this",
".",
"table",
";",
"forOf",
"(",
"other",
",",
"function",
"(",
"element",
")",
"{",
"table",
".",
"add",
"(",
"element",
")",
";",
"}",
")",
... | Modifies the current set so that it contains all elements that are present
in either the current set or the specified collection.
@param {Iterable} other The collection to compare to the current set. | [
"Modifies",
"the",
"current",
"set",
"so",
"that",
"it",
"contains",
"all",
"elements",
"that",
"are",
"present",
"in",
"either",
"the",
"current",
"set",
"or",
"the",
"specified",
"collection",
"."
] | 1e2f7df5726bdbbe6e8309066a03140ecbddb224 | https://github.com/multiplex/multiplex.js/blob/1e2f7df5726bdbbe6e8309066a03140ecbddb224/src/lib/collections/hash-set.js#L393-L401 | |
32,098 | parasyte/node-capstone | lib/capstone.js | function (insn, arch) {
this.arch = arch;
// Convert arch number to string
var archStr = archs.toString(arch);
Object.defineProperty(this, "_nativeInsn", {
"configurable" : true,
"value" : null,
});
/**
* Instruction id
* @name id
* @type {Number}
* @memberOf CsInsn
*/
this.id = insn.id;
/**
* Instruction address
* @name address
* @type {Number}
* @memberOf CsInsn
*/
this.address = insn.address;
/**
* Instruction bytes
* @name bytes
* @type {Array}
* @memberOf CsInsn
*/
this.bytes = insn.bytes.buffer.toJSON().data.slice(0, insn.size);
/**
* Instruction mnemonic string
* @name mnemonic
* @type {String}
* @memberOf CsInsn
*/
this.mnemonic = insn.mnemonic.buffer.readCString(0);
/**
* Instruction operand string
* @name op_str
* @type {String}
* @memberOf CsInsn
*/
this.op_str = insn.op_str.buffer.readCString(0);
if (insn.detail.address()) {
var detail = insn.detail.deref();
/**
* Instruction detailed information
*
* *NOTE: only valid when detail option is ON (OFF by default)*
*
* @name detail
* @type {Object}
* @memberOf CsInsn
*/
this.detail = {
/**
* Registers implicitly read by this instruction
* @name detail.regs_read
* @type {Array}
* @memberOf CsInsn
*/
"regs_read" : detail.regs_read.buffer.toJSON().data.slice(
0,
detail.regs_read_count
),
/**
* Registers implicitly modified by this instruction
* @name detail.regs_write
* @type {Array}
* @memberOf CsInsn
*/
"regs_write" : detail.regs_write.buffer.toJSON().data.slice(
0,
detail.regs_write_count
),
/**
* Groups this instruction belongs to
* @name detail.groups
* @type {Array}
* @memberOf CsInsn
*/
"groups" : detail.groups.buffer.toJSON().data.slice(
0,
detail.groups_count
),
};
var ArchDetail = exports[archStr]._Detail;
this.detail[archStr] = new ArchDetail(detail.arch[archStr]);
}
return this;
} | javascript | function (insn, arch) {
this.arch = arch;
// Convert arch number to string
var archStr = archs.toString(arch);
Object.defineProperty(this, "_nativeInsn", {
"configurable" : true,
"value" : null,
});
/**
* Instruction id
* @name id
* @type {Number}
* @memberOf CsInsn
*/
this.id = insn.id;
/**
* Instruction address
* @name address
* @type {Number}
* @memberOf CsInsn
*/
this.address = insn.address;
/**
* Instruction bytes
* @name bytes
* @type {Array}
* @memberOf CsInsn
*/
this.bytes = insn.bytes.buffer.toJSON().data.slice(0, insn.size);
/**
* Instruction mnemonic string
* @name mnemonic
* @type {String}
* @memberOf CsInsn
*/
this.mnemonic = insn.mnemonic.buffer.readCString(0);
/**
* Instruction operand string
* @name op_str
* @type {String}
* @memberOf CsInsn
*/
this.op_str = insn.op_str.buffer.readCString(0);
if (insn.detail.address()) {
var detail = insn.detail.deref();
/**
* Instruction detailed information
*
* *NOTE: only valid when detail option is ON (OFF by default)*
*
* @name detail
* @type {Object}
* @memberOf CsInsn
*/
this.detail = {
/**
* Registers implicitly read by this instruction
* @name detail.regs_read
* @type {Array}
* @memberOf CsInsn
*/
"regs_read" : detail.regs_read.buffer.toJSON().data.slice(
0,
detail.regs_read_count
),
/**
* Registers implicitly modified by this instruction
* @name detail.regs_write
* @type {Array}
* @memberOf CsInsn
*/
"regs_write" : detail.regs_write.buffer.toJSON().data.slice(
0,
detail.regs_write_count
),
/**
* Groups this instruction belongs to
* @name detail.groups
* @type {Array}
* @memberOf CsInsn
*/
"groups" : detail.groups.buffer.toJSON().data.slice(
0,
detail.groups_count
),
};
var ArchDetail = exports[archStr]._Detail;
this.detail[archStr] = new ArchDetail(detail.arch[archStr]);
}
return this;
} | [
"function",
"(",
"insn",
",",
"arch",
")",
"{",
"this",
".",
"arch",
"=",
"arch",
";",
"// Convert arch number to string",
"var",
"archStr",
"=",
"archs",
".",
"toString",
"(",
"arch",
")",
";",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"\"_native... | Disassembled instruction information represented as a JavaScript object.
@name CsInsn
@class
@private
@param {InsnType} insn Native instruction struct.
@param {ARCH} arch Architecture. | [
"Disassembled",
"instruction",
"information",
"represented",
"as",
"a",
"JavaScript",
"object",
"."
] | 02465c77e1652284a0f1806efff0649f5285dc80 | https://github.com/parasyte/node-capstone/blob/02465c77e1652284a0f1806efff0649f5285dc80/lib/capstone.js#L400-L502 | |
32,099 | parasyte/node-capstone | lib/capstone.js | option | function option(csh, type, value) {
var errno = capstone.cs_option(csh, type, value);
if (errno) {
throw "cs_option returned " + errno + ": " + exports.strerror(errno);
}
} | javascript | function option(csh, type, value) {
var errno = capstone.cs_option(csh, type, value);
if (errno) {
throw "cs_option returned " + errno + ": " + exports.strerror(errno);
}
} | [
"function",
"option",
"(",
"csh",
",",
"type",
",",
"value",
")",
"{",
"var",
"errno",
"=",
"capstone",
".",
"cs_option",
"(",
"csh",
",",
"type",
",",
"value",
")",
";",
"if",
"(",
"errno",
")",
"{",
"throw",
"\"cs_option returned \"",
"+",
"errno",
... | Set option for disassembly engine at runtime.
@ignore
@param {OPT_TYPE} type Option type
@param {OPT_VALUE|MODE} value Option value | [
"Set",
"option",
"for",
"disassembly",
"engine",
"at",
"runtime",
"."
] | 02465c77e1652284a0f1806efff0649f5285dc80 | https://github.com/parasyte/node-capstone/blob/02465c77e1652284a0f1806efff0649f5285dc80/lib/capstone.js#L719-L724 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.