repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
robojones/smart-promisify | index.js | promisify | function promisify(original, self = null) {
if (typeof original !== 'function') {
throw new TypeError('original must be a function')
}
/**
* Wrapped original function.
* @typedef {function} wrapper
* @param {...*} args - Arguments to apply to the original function.
* @returns {Promise.<*>} - Prom... | javascript | function promisify(original, self = null) {
if (typeof original !== 'function') {
throw new TypeError('original must be a function')
}
/**
* Wrapped original function.
* @typedef {function} wrapper
* @param {...*} args - Arguments to apply to the original function.
* @returns {Promise.<*>} - Prom... | [
"function",
"promisify",
"(",
"original",
",",
"self",
"=",
"null",
")",
"{",
"if",
"(",
"typeof",
"original",
"!==",
"'function'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'original must be a function'",
")",
"}",
"/**\n * Wrapped original function.\n * @ty... | Promisify the original function.
@param {original} original - Function that gets promisified.
@param {?Object} self - Object that gets applied as this-object when the original function is called.
@returns {wrapper} | [
"Promisify",
"the",
"original",
"function",
"."
] | b01c845f7539f99efd7bfabf940dd99035cfdb94 | https://github.com/robojones/smart-promisify/blob/b01c845f7539f99efd7bfabf940dd99035cfdb94/index.js#L7-L52 | train |
UXFoundry/hashdo | lib/card.js | generateCardDocument | function generateCardDocument(options, callback) {
var DB = require('../index').db,
elementId = Cuid();
// defaults
options = _.defaultsDeep(options, {
directory: '.',
css: true,
js: false,
clientStateSupport: false,
clientProxySupport: false,
clientAnalyticsSupport: false,
viewMo... | javascript | function generateCardDocument(options, callback) {
var DB = require('../index').db,
elementId = Cuid();
// defaults
options = _.defaultsDeep(options, {
directory: '.',
css: true,
js: false,
clientStateSupport: false,
clientProxySupport: false,
clientAnalyticsSupport: false,
viewMo... | [
"function",
"generateCardDocument",
"(",
"options",
",",
"callback",
")",
"{",
"var",
"DB",
"=",
"require",
"(",
"'../index'",
")",
".",
"db",
",",
"elementId",
"=",
"Cuid",
"(",
")",
";",
"// defaults",
"options",
"=",
"_",
".",
"defaultsDeep",
"(",
"op... | Generate the full HTML document to render a card.
The document will be optimized in a production environment.
@method generateCardDocument
@async
@param {Object} options Rendering options object.
directory: The directory where the pack and card can be found.
packName: The pack name.
cardName: The card name.
url... | [
"Generate",
"the",
"full",
"HTML",
"document",
"to",
"render",
"a",
"card",
".",
"The",
"document",
"will",
"be",
"optimized",
"in",
"a",
"production",
"environment",
"."
] | c2a0adcba0cca26d6ebe56bba17017b177609057 | https://github.com/UXFoundry/hashdo/blob/c2a0adcba0cca26d6ebe56bba17017b177609057/lib/card.js#L178-L260 | train |
UXFoundry/hashdo | lib/card.js | function (packName, cardName, inputValues, callback) {
var DB = require('../index').db;
// Go through the input values and base64 them if they aren't already.
var allBase64 = true;
_.each(_.keys(inputValues), function (key) {
if (!/^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za... | javascript | function (packName, cardName, inputValues, callback) {
var DB = require('../index').db;
// Go through the input values and base64 them if they aren't already.
var allBase64 = true;
_.each(_.keys(inputValues), function (key) {
if (!/^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za... | [
"function",
"(",
"packName",
",",
"cardName",
",",
"inputValues",
",",
"callback",
")",
"{",
"var",
"DB",
"=",
"require",
"(",
"'../index'",
")",
".",
"db",
";",
"// Go through the input values and base64 them if they aren't already.",
"var",
"allBase64",
"=",
"true... | Secure card inputs such as passwords and API keys sop they cannot be read by users.
@method secureInputs
@async
@param {String} packName The pack this data belongs to.
@param {String} cardName The card this data belongs to.
@param {Object} inputValues The values that you want to be secured.
@param {Func... | [
"Secure",
"card",
"inputs",
"such",
"as",
"passwords",
"and",
"API",
"keys",
"sop",
"they",
"cannot",
"be",
"read",
"by",
"users",
"."
] | c2a0adcba0cca26d6ebe56bba17017b177609057 | https://github.com/UXFoundry/hashdo/blob/c2a0adcba0cca26d6ebe56bba17017b177609057/lib/card.js#L273-L299 | train | |
UXFoundry/hashdo | lib/card.js | function (cb) {
// card key
var url = options.url.replace(/light=true/i, ''),
params = {
legacyCardKey: Utils.getLegacyCardKey(url, process.env.CARD_SECRET),
cardKey: Utils.getCardKey(url, process.env.CARD_SECRET)
... | javascript | function (cb) {
// card key
var url = options.url.replace(/light=true/i, ''),
params = {
legacyCardKey: Utils.getLegacyCardKey(url, process.env.CARD_SECRET),
cardKey: Utils.getCardKey(url, process.env.CARD_SECRET)
... | [
"function",
"(",
"cb",
")",
"{",
"// card key",
"var",
"url",
"=",
"options",
".",
"url",
".",
"replace",
"(",
"/",
"light=true",
"/",
"i",
",",
"''",
")",
",",
"params",
"=",
"{",
"legacyCardKey",
":",
"Utils",
".",
"getLegacyCardKey",
"(",
"url",
"... | get required params | [
"get",
"required",
"params"
] | c2a0adcba0cca26d6ebe56bba17017b177609057 | https://github.com/UXFoundry/hashdo/blob/c2a0adcba0cca26d6ebe56bba17017b177609057/lib/card.js#L354-L391 | train | |
UXFoundry/hashdo | lib/card.js | function (params, cb) {
// validate input requirements vs what came back in params
var errorMessage = null;
_.forEach(Card.inputs, function (input, key) {
if (input.required && !params[key]) {
if (!errorMessage) {
... | javascript | function (params, cb) {
// validate input requirements vs what came back in params
var errorMessage = null;
_.forEach(Card.inputs, function (input, key) {
if (input.required && !params[key]) {
if (!errorMessage) {
... | [
"function",
"(",
"params",
",",
"cb",
")",
"{",
"// validate input requirements vs what came back in params",
"var",
"errorMessage",
"=",
"null",
";",
"_",
".",
"forEach",
"(",
"Card",
".",
"inputs",
",",
"function",
"(",
"input",
",",
"key",
")",
"{",
"if",
... | check for input validation errors | [
"check",
"for",
"input",
"validation",
"errors"
] | c2a0adcba0cca26d6ebe56bba17017b177609057 | https://github.com/UXFoundry/hashdo/blob/c2a0adcba0cca26d6ebe56bba17017b177609057/lib/card.js#L394-L412 | train | |
UXFoundry/hashdo | lib/card.js | function (err, params) {
if (!err) {
callback && callback(null, params);
}
else {
callback && callback(err.message || err);
}
} | javascript | function (err, params) {
if (!err) {
callback && callback(null, params);
}
else {
callback && callback(err.message || err);
}
} | [
"function",
"(",
"err",
",",
"params",
")",
"{",
"if",
"(",
"!",
"err",
")",
"{",
"callback",
"&&",
"callback",
"(",
"null",
",",
"params",
")",
";",
"}",
"else",
"{",
"callback",
"&&",
"callback",
"(",
"err",
".",
"message",
"||",
"err",
")",
";... | done - respond with params | [
"done",
"-",
"respond",
"with",
"params"
] | c2a0adcba0cca26d6ebe56bba17017b177609057 | https://github.com/UXFoundry/hashdo/blob/c2a0adcba0cca26d6ebe56bba17017b177609057/lib/card.js#L416-L423 | train | |
UXFoundry/hashdo | lib/card.js | function (params, cb) {
DB.getCardState(params.cardKey, params.legacyCardKey, function (err, state) {
cb(null, params, state);
});
} | javascript | function (params, cb) {
DB.getCardState(params.cardKey, params.legacyCardKey, function (err, state) {
cb(null, params, state);
});
} | [
"function",
"(",
"params",
",",
"cb",
")",
"{",
"DB",
".",
"getCardState",
"(",
"params",
".",
"cardKey",
",",
"params",
".",
"legacyCardKey",
",",
"function",
"(",
"err",
",",
"state",
")",
"{",
"cb",
"(",
"null",
",",
"params",
",",
"state",
")",
... | load previously saved state | [
"load",
"previously",
"saved",
"state"
] | c2a0adcba0cca26d6ebe56bba17017b177609057 | https://github.com/UXFoundry/hashdo/blob/c2a0adcba0cca26d6ebe56bba17017b177609057/lib/card.js#L553-L557 | train | |
UXFoundry/hashdo | lib/card.js | function (params, state, cb) {
state = state || {};
if (Card.getCardData) {
Card.getCardData(params, state, function (err, viewModel, clientLocals) {
cb(err, params, state, viewModel, clientLocals);
});
... | javascript | function (params, state, cb) {
state = state || {};
if (Card.getCardData) {
Card.getCardData(params, state, function (err, viewModel, clientLocals) {
cb(err, params, state, viewModel, clientLocals);
});
... | [
"function",
"(",
"params",
",",
"state",
",",
"cb",
")",
"{",
"state",
"=",
"state",
"||",
"{",
"}",
";",
"if",
"(",
"Card",
".",
"getCardData",
")",
"{",
"Card",
".",
"getCardData",
"(",
"params",
",",
"state",
",",
"function",
"(",
"err",
",",
... | get view model data from the card | [
"get",
"view",
"model",
"data",
"from",
"the",
"card"
] | c2a0adcba0cca26d6ebe56bba17017b177609057 | https://github.com/UXFoundry/hashdo/blob/c2a0adcba0cca26d6ebe56bba17017b177609057/lib/card.js#L560-L571 | train | |
UXFoundry/hashdo | lib/card.js | function (params, state, viewModel, clientLocals, cb) {
// don't save if nothing came back, just forward the call
if (!_.isEmpty(state)) {
DB.saveCardState(params.cardKey, state, function (err) {
cb(err, params, viewModel, clientLocals);
... | javascript | function (params, state, viewModel, clientLocals, cb) {
// don't save if nothing came back, just forward the call
if (!_.isEmpty(state)) {
DB.saveCardState(params.cardKey, state, function (err) {
cb(err, params, viewModel, clientLocals);
... | [
"function",
"(",
"params",
",",
"state",
",",
"viewModel",
",",
"clientLocals",
",",
"cb",
")",
"{",
"// don't save if nothing came back, just forward the call",
"if",
"(",
"!",
"_",
".",
"isEmpty",
"(",
"state",
")",
")",
"{",
"DB",
".",
"saveCardState",
"(",... | save any state changes made during getCardData | [
"save",
"any",
"state",
"changes",
"made",
"during",
"getCardData"
] | c2a0adcba0cca26d6ebe56bba17017b177609057 | https://github.com/UXFoundry/hashdo/blob/c2a0adcba0cca26d6ebe56bba17017b177609057/lib/card.js#L574-L584 | train | |
UXFoundry/hashdo | lib/card.js | function (params, viewModel, clientLocals, cb) {
viewModel = viewModel || {};
clientLocals = clientLocals || {};
var generateOptions = {
directory: options.directory,
packName: options.packName,
cardName: ... | javascript | function (params, viewModel, clientLocals, cb) {
viewModel = viewModel || {};
clientLocals = clientLocals || {};
var generateOptions = {
directory: options.directory,
packName: options.packName,
cardName: ... | [
"function",
"(",
"params",
",",
"viewModel",
",",
"clientLocals",
",",
"cb",
")",
"{",
"viewModel",
"=",
"viewModel",
"||",
"{",
"}",
";",
"clientLocals",
"=",
"clientLocals",
"||",
"{",
"}",
";",
"var",
"generateOptions",
"=",
"{",
"directory",
":",
"op... | render the options | [
"render",
"the",
"options"
] | c2a0adcba0cca26d6ebe56bba17017b177609057 | https://github.com/UXFoundry/hashdo/blob/c2a0adcba0cca26d6ebe56bba17017b177609057/lib/card.js#L587-L611 | train | |
UXFoundry/hashdo | lib/card.js | function (err, html) {
if (!err) {
callback && callback(null, html);
}
else {
console.log('CARD: Error rendering HashDo card ' + options.packName + '-' + options.cardName + '.', err);
callback && callback(err.message |... | javascript | function (err, html) {
if (!err) {
callback && callback(null, html);
}
else {
console.log('CARD: Error rendering HashDo card ' + options.packName + '-' + options.cardName + '.', err);
callback && callback(err.message |... | [
"function",
"(",
"err",
",",
"html",
")",
"{",
"if",
"(",
"!",
"err",
")",
"{",
"callback",
"&&",
"callback",
"(",
"null",
",",
"html",
")",
";",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"'CARD: Error rendering HashDo card '",
"+",
"options",
".",... | done - respond with HTML | [
"done",
"-",
"respond",
"with",
"HTML"
] | c2a0adcba0cca26d6ebe56bba17017b177609057 | https://github.com/UXFoundry/hashdo/blob/c2a0adcba0cca26d6ebe56bba17017b177609057/lib/card.js#L615-L623 | train | |
UXFoundry/hashdo | lib/card.js | function (options, callback) {
if (!options) {
throw new Error('You must provide an options object to .');
}
if (!options.packName) {
throw new Error('You must provide a pack name the card belongs to.');
}
if (!options.cardName) {
throw new Error('You must provide a card ... | javascript | function (options, callback) {
if (!options) {
throw new Error('You must provide an options object to .');
}
if (!options.packName) {
throw new Error('You must provide a pack name the card belongs to.');
}
if (!options.cardName) {
throw new Error('You must provide a card ... | [
"function",
"(",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"options",
")",
"{",
"throw",
"new",
"Error",
"(",
"'You must provide an options object to .'",
")",
";",
"}",
"if",
"(",
"!",
"options",
".",
"packName",
")",
"{",
"throw",
"new",
"E... | Provides the functionality to call a card's web hook functionality and save the state.
@method webHook
@async
@param {Object} options Hooking options object.
directory: The directory where the pack and card code can be found.
packName: The pack name.
cardName: The card name.
payload: The values necessary to cre... | [
"Provides",
"the",
"functionality",
"to",
"call",
"a",
"card",
"s",
"web",
"hook",
"functionality",
"and",
"save",
"the",
"state",
"."
] | c2a0adcba0cca26d6ebe56bba17017b177609057 | https://github.com/UXFoundry/hashdo/blob/c2a0adcba0cca26d6ebe56bba17017b177609057/lib/card.js#L652-L721 | train | |
commenthol/connect-composer | lib/compose.js | nextTick | function nextTick (next, err) {
return process.nextTick(function () {
try {
next(err)
} catch (e) {
// istanbul ignore next
next(e)
}
})
} | javascript | function nextTick (next, err) {
return process.nextTick(function () {
try {
next(err)
} catch (e) {
// istanbul ignore next
next(e)
}
})
} | [
"function",
"nextTick",
"(",
"next",
",",
"err",
")",
"{",
"return",
"process",
".",
"nextTick",
"(",
"function",
"(",
")",
"{",
"try",
"{",
"next",
"(",
"err",
")",
"}",
"catch",
"(",
"e",
")",
"{",
"// istanbul ignore next",
"next",
"(",
"e",
")",
... | Safety wrapper around nextTick
@api private
@param {Function} next - next function on the stack
@param {Object} [err] - error value from previous middleware | [
"Safety",
"wrapper",
"around",
"nextTick"
] | 810dbd1c7d3095598ec4a4fa771b9d55e037fb57 | https://github.com/commenthol/connect-composer/blob/810dbd1c7d3095598ec4a4fa771b9d55e037fb57/lib/compose.js#L14-L23 | train |
commenthol/connect-composer | lib/compose.js | compose | function compose () {
// the function required by the server
function middlewareF (req, res, end) {
var index = 0
// inject stats middleware
if (middlewareF.options && middlewareF.options.stats) {
middlewareF.stack = middlewareF.stack.map(function (mw) {
var fn
if (typeof mw === '... | javascript | function compose () {
// the function required by the server
function middlewareF (req, res, end) {
var index = 0
// inject stats middleware
if (middlewareF.options && middlewareF.options.stats) {
middlewareF.stack = middlewareF.stack.map(function (mw) {
var fn
if (typeof mw === '... | [
"function",
"compose",
"(",
")",
"{",
"// the function required by the server",
"function",
"middlewareF",
"(",
"req",
",",
"res",
",",
"end",
")",
"{",
"var",
"index",
"=",
"0",
"// inject stats middleware",
"if",
"(",
"middlewareF",
".",
"options",
"&&",
"midd... | compose a new middleware function from multiple middlewares
@param {Function|Array|Object}
@return {Function} middleware function | [
"compose",
"a",
"new",
"middleware",
"function",
"from",
"multiple",
"middlewares"
] | 810dbd1c7d3095598ec4a4fa771b9d55e037fb57 | https://github.com/commenthol/connect-composer/blob/810dbd1c7d3095598ec4a4fa771b9d55e037fb57/lib/compose.js#L31-L125 | train |
commenthol/connect-composer | lib/compose.js | middlewareF | function middlewareF (req, res, end) {
var index = 0
// inject stats middleware
if (middlewareF.options && middlewareF.options.stats) {
middlewareF.stack = middlewareF.stack.map(function (mw) {
var fn
if (typeof mw === 'object') {
var key = Object.keys(mw)[0]
if (!... | javascript | function middlewareF (req, res, end) {
var index = 0
// inject stats middleware
if (middlewareF.options && middlewareF.options.stats) {
middlewareF.stack = middlewareF.stack.map(function (mw) {
var fn
if (typeof mw === 'object') {
var key = Object.keys(mw)[0]
if (!... | [
"function",
"middlewareF",
"(",
"req",
",",
"res",
",",
"end",
")",
"{",
"var",
"index",
"=",
"0",
"// inject stats middleware",
"if",
"(",
"middlewareF",
".",
"options",
"&&",
"middlewareF",
".",
"options",
".",
"stats",
")",
"{",
"middlewareF",
".",
"sta... | the function required by the server | [
"the",
"function",
"required",
"by",
"the",
"server"
] | 810dbd1c7d3095598ec4a4fa771b9d55e037fb57 | https://github.com/commenthol/connect-composer/blob/810dbd1c7d3095598ec4a4fa771b9d55e037fb57/lib/compose.js#L33-L104 | train |
okramolis/dirio | lib/dirio.js | _write | function _write(dest, source, callback) {
var itemPath = path.join(dest, source.name);
// switch according to type of the current root item
switch(source.type) {
case TYPE_FILE:
if (source.data instanceof stream.Readable) {
// stream data => pipe it to destination stream
source.data.pipe... | javascript | function _write(dest, source, callback) {
var itemPath = path.join(dest, source.name);
// switch according to type of the current root item
switch(source.type) {
case TYPE_FILE:
if (source.data instanceof stream.Readable) {
// stream data => pipe it to destination stream
source.data.pipe... | [
"function",
"_write",
"(",
"dest",
",",
"source",
",",
"callback",
")",
"{",
"var",
"itemPath",
"=",
"path",
".",
"join",
"(",
"dest",
",",
"source",
".",
"name",
")",
";",
"// switch according to type of the current root item",
"switch",
"(",
"source",
".",
... | Writes fs structure according to provided source object.
@param {String} dest - Path to destination location on file system.
@param {Object} source - Description of the structure to be created.
@param {Function} callback - Callback that expects only a possible
error. | [
"Writes",
"fs",
"structure",
"according",
"to",
"provided",
"source",
"object",
"."
] | fe2419e6b0a4e9116f4ae028959b6f0e3a514d21 | https://github.com/okramolis/dirio/blob/fe2419e6b0a4e9116f4ae028959b6f0e3a514d21/lib/dirio.js#L30-L55 | train |
okramolis/dirio | lib/dirio.js | _folderWritten | function _folderWritten(dest, source, callback, err) {
if (err) return callback(err);
async.each(source.children, _write.bind(null, dest), callback);
} | javascript | function _folderWritten(dest, source, callback, err) {
if (err) return callback(err);
async.each(source.children, _write.bind(null, dest), callback);
} | [
"function",
"_folderWritten",
"(",
"dest",
",",
"source",
",",
"callback",
",",
"err",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"async",
".",
"each",
"(",
"source",
".",
"children",
",",
"_write",
".",
"bind",
"(",... | Ensures each child of source object may write its data.
@param {String} dest - Path of current directory from the child's
point of view.
@param {Object} source - Description of the current structure to
be created.
@param {Function} callback - Callback that expects only a possible
error.
@param {*} err - Possible error ... | [
"Ensures",
"each",
"child",
"of",
"source",
"object",
"may",
"write",
"its",
"data",
"."
] | fe2419e6b0a4e9116f4ae028959b6f0e3a514d21 | https://github.com/okramolis/dirio/blob/fe2419e6b0a4e9116f4ae028959b6f0e3a514d21/lib/dirio.js#L67-L70 | train |
okramolis/dirio | lib/dirio.js | _read | function _read(stat, source, callback) {
stat(source, _pathStated.bind(null, {}, stat, source, callback));
} | javascript | function _read(stat, source, callback) {
stat(source, _pathStated.bind(null, {}, stat, source, callback));
} | [
"function",
"_read",
"(",
"stat",
",",
"source",
",",
"callback",
")",
"{",
"stat",
"(",
"source",
",",
"_pathStated",
".",
"bind",
"(",
"null",
",",
"{",
"}",
",",
"stat",
",",
"source",
",",
"callback",
")",
")",
";",
"}"
] | Reads path and builds json-comaptible object representing content
of the path.
@param {Function} stat - Function of fs module fs.stat or fs.lstat.
@param {String} source - Path to source location on file system.
@param {Function} callback - Callback that expects a possible error
and the result. | [
"Reads",
"path",
"and",
"builds",
"json",
"-",
"comaptible",
"object",
"representing",
"content",
"of",
"the",
"path",
"."
] | fe2419e6b0a4e9116f4ae028959b6f0e3a514d21 | https://github.com/okramolis/dirio/blob/fe2419e6b0a4e9116f4ae028959b6f0e3a514d21/lib/dirio.js#L80-L82 | train |
okramolis/dirio | lib/dirio.js | _pathStated | function _pathStated(item, stat, stated, callback, err, stats) {
if (err) return callback(err);
item.name = path.basename(stated);
if (stats.isFile()) {
item.type = TYPE_FILE;
// TODO set encoding according to the read file content or user preferences
return fs.readFile(stated, {encoding: 'utf8'}, _... | javascript | function _pathStated(item, stat, stated, callback, err, stats) {
if (err) return callback(err);
item.name = path.basename(stated);
if (stats.isFile()) {
item.type = TYPE_FILE;
// TODO set encoding according to the read file content or user preferences
return fs.readFile(stated, {encoding: 'utf8'}, _... | [
"function",
"_pathStated",
"(",
"item",
",",
"stat",
",",
"stated",
",",
"callback",
",",
"err",
",",
"stats",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"item",
".",
"name",
"=",
"path",
".",
"basename",
"(",
"sta... | Investigates stats of a path and continues according to stats type.
Supported types are file, directory, symbolic link.
@param {Object} item - Object that is supposed to be updated with
discovered data.
@param {Function} stat - Function of fs module fs.stat or fs.lstat.
@param {String} stated - The investigated path on... | [
"Investigates",
"stats",
"of",
"a",
"path",
"and",
"continues",
"according",
"to",
"stats",
"type",
".",
"Supported",
"types",
"are",
"file",
"directory",
"symbolic",
"link",
"."
] | fe2419e6b0a4e9116f4ae028959b6f0e3a514d21 | https://github.com/okramolis/dirio/blob/fe2419e6b0a4e9116f4ae028959b6f0e3a514d21/lib/dirio.js#L96-L117 | train |
okramolis/dirio | lib/dirio.js | _fileRead | function _fileRead(item, callback, err, data) {
if (err) return callback(err);
item.data = data;
callback(null, item);
} | javascript | function _fileRead(item, callback, err, data) {
if (err) return callback(err);
item.data = data;
callback(null, item);
} | [
"function",
"_fileRead",
"(",
"item",
",",
"callback",
",",
"err",
",",
"data",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"item",
".",
"data",
"=",
"data",
";",
"callback",
"(",
"null",
",",
"item",
")",
";",
"}... | Updates the item with content of the file.
@param {Object} item - Object representing investigated file.
@param {Function} callback - Callback that expects a possible
error and the item.
@param {*} err - Possible error passed by caller.
@param {Buffer} file - Content of the file. | [
"Updates",
"the",
"item",
"with",
"content",
"of",
"the",
"file",
"."
] | fe2419e6b0a4e9116f4ae028959b6f0e3a514d21 | https://github.com/okramolis/dirio/blob/fe2419e6b0a4e9116f4ae028959b6f0e3a514d21/lib/dirio.js#L127-L131 | train |
okramolis/dirio | lib/dirio.js | _folderRead | function _folderRead(item, stat, dirpath, callback, err, files) {
if (err) return callback(err);
async.map(
files,
_readChild.bind(null, stat, dirpath),
_childrenRead.bind(null, item, callback)
);
} | javascript | function _folderRead(item, stat, dirpath, callback, err, files) {
if (err) return callback(err);
async.map(
files,
_readChild.bind(null, stat, dirpath),
_childrenRead.bind(null, item, callback)
);
} | [
"function",
"_folderRead",
"(",
"item",
",",
"stat",
",",
"dirpath",
",",
"callback",
",",
"err",
",",
"files",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"async",
".",
"map",
"(",
"files",
",",
"_readChild",
".",
... | Ensures each child of the read directory may provide its data.
@param {Object} item - Object that is supposed to be updated with
discovered data.
@param {Function} stat - Function of fs module fs.stat or fs.lstat.
@param {String} dirpath - Path of the read directory on file system.
@param {Function} callback - Callback... | [
"Ensures",
"each",
"child",
"of",
"the",
"read",
"directory",
"may",
"provide",
"its",
"data",
"."
] | fe2419e6b0a4e9116f4ae028959b6f0e3a514d21 | https://github.com/okramolis/dirio/blob/fe2419e6b0a4e9116f4ae028959b6f0e3a514d21/lib/dirio.js#L145-L152 | train |
okramolis/dirio | lib/dirio.js | _readChild | function _readChild(stat, dirpath, name, callback) {
_read(stat, path.join(dirpath, name), callback);
} | javascript | function _readChild(stat, dirpath, name, callback) {
_read(stat, path.join(dirpath, name), callback);
} | [
"function",
"_readChild",
"(",
"stat",
",",
"dirpath",
",",
"name",
",",
"callback",
")",
"{",
"_read",
"(",
"stat",
",",
"path",
".",
"join",
"(",
"dirpath",
",",
"name",
")",
",",
"callback",
")",
";",
"}"
] | Ensures the child of the parent directory may provide its data.
@param {Function} stat - Function of fs module fs.stat or fs.lstat.
@param {String} dirpath - Path of the parent directory on file system.
@param {String} name - File name of the child.
@param {Function} callback - Callback that expects a possible error
an... | [
"Ensures",
"the",
"child",
"of",
"the",
"parent",
"directory",
"may",
"provide",
"its",
"data",
"."
] | fe2419e6b0a4e9116f4ae028959b6f0e3a514d21 | https://github.com/okramolis/dirio/blob/fe2419e6b0a4e9116f4ae028959b6f0e3a514d21/lib/dirio.js#L162-L164 | train |
okramolis/dirio | lib/dirio.js | _aliasRead | function _aliasRead(item, callback, err, orig) {
if (err) return callback(err);
item.orig = orig;
callback(null, item);
} | javascript | function _aliasRead(item, callback, err, orig) {
if (err) return callback(err);
item.orig = orig;
callback(null, item);
} | [
"function",
"_aliasRead",
"(",
"item",
",",
"callback",
",",
"err",
",",
"orig",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"item",
".",
"orig",
"=",
"orig",
";",
"callback",
"(",
"null",
",",
"item",
")",
";",
"... | Updates the item with path to its original file.
@param {Object} item - Object representing investigated symbolic link.
@param {Function} callback - Callback that expects a possible error
and the item.
@param {*} err - Possible error passed by caller.
@param {String} orig - Content of the symbolic link. | [
"Updates",
"the",
"item",
"with",
"path",
"to",
"its",
"original",
"file",
"."
] | fe2419e6b0a4e9116f4ae028959b6f0e3a514d21 | https://github.com/okramolis/dirio/blob/fe2419e6b0a4e9116f4ae028959b6f0e3a514d21/lib/dirio.js#L188-L192 | train |
okramolis/dirio | lib/dirio.js | _store | function _store(dest, source, callback) {
fs.writeFile(dest, JSON.stringify(source), callback);
} | javascript | function _store(dest, source, callback) {
fs.writeFile(dest, JSON.stringify(source), callback);
} | [
"function",
"_store",
"(",
"dest",
",",
"source",
",",
"callback",
")",
"{",
"fs",
".",
"writeFile",
"(",
"dest",
",",
"JSON",
".",
"stringify",
"(",
"source",
")",
",",
"callback",
")",
";",
"}"
] | Stores json-compatible object on file system at provided path as
a json file.
@param {String} dest - File system path of the new file.
@param {Object} source - The object to be stored.
@param {Function} callback - Callback that expects only a possible error. | [
"Stores",
"json",
"-",
"compatible",
"object",
"on",
"file",
"system",
"at",
"provided",
"path",
"as",
"a",
"json",
"file",
"."
] | fe2419e6b0a4e9116f4ae028959b6f0e3a514d21 | https://github.com/okramolis/dirio/blob/fe2419e6b0a4e9116f4ae028959b6f0e3a514d21/lib/dirio.js#L201-L203 | train |
okramolis/dirio | lib/dirio.js | _load | function _load(source, callback) {
fs.readFile(source, {encoding: 'utf8'}, _jsonLoaded.bind(null, callback));
} | javascript | function _load(source, callback) {
fs.readFile(source, {encoding: 'utf8'}, _jsonLoaded.bind(null, callback));
} | [
"function",
"_load",
"(",
"source",
",",
"callback",
")",
"{",
"fs",
".",
"readFile",
"(",
"source",
",",
"{",
"encoding",
":",
"'utf8'",
"}",
",",
"_jsonLoaded",
".",
"bind",
"(",
"null",
",",
"callback",
")",
")",
";",
"}"
] | Reads json file and parses its data.
@param {String} source - File system path of the source json file.
@param {Function} callback - Callback that expects a possible error
and the result. | [
"Reads",
"json",
"file",
"and",
"parses",
"its",
"data",
"."
] | fe2419e6b0a4e9116f4ae028959b6f0e3a514d21 | https://github.com/okramolis/dirio/blob/fe2419e6b0a4e9116f4ae028959b6f0e3a514d21/lib/dirio.js#L211-L213 | train |
okramolis/dirio | lib/dirio.js | _jsonLoaded | function _jsonLoaded(callback, err, data) {
if (err) return callback(err);
var parsed;
try {
parsed = JSON.parse(data);
} catch(jerr) {
return callback(jerr);
}
callback(null, parsed);
} | javascript | function _jsonLoaded(callback, err, data) {
if (err) return callback(err);
var parsed;
try {
parsed = JSON.parse(data);
} catch(jerr) {
return callback(jerr);
}
callback(null, parsed);
} | [
"function",
"_jsonLoaded",
"(",
"callback",
",",
"err",
",",
"data",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"var",
"parsed",
";",
"try",
"{",
"parsed",
"=",
"JSON",
".",
"parse",
"(",
"data",
")",
";",
"}",
"... | Parses content of a json file.
@param {Function} callback - Callback that expects a possible error
and the result.
@param {*} err - Possible error passed by caller.
@param {String} data - Content of the file. | [
"Parses",
"content",
"of",
"a",
"json",
"file",
"."
] | fe2419e6b0a4e9116f4ae028959b6f0e3a514d21 | https://github.com/okramolis/dirio/blob/fe2419e6b0a4e9116f4ae028959b6f0e3a514d21/lib/dirio.js#L222-L231 | train |
okramolis/dirio | lib/dirio.js | _load2write | function _load2write(dest, source, callback) {
_load(source, _pipe.bind(null, _write.bind(null, dest), callback));
} | javascript | function _load2write(dest, source, callback) {
_load(source, _pipe.bind(null, _write.bind(null, dest), callback));
} | [
"function",
"_load2write",
"(",
"dest",
",",
"source",
",",
"callback",
")",
"{",
"_load",
"(",
"source",
",",
"_pipe",
".",
"bind",
"(",
"null",
",",
"_write",
".",
"bind",
"(",
"null",
",",
"dest",
")",
",",
"callback",
")",
")",
";",
"}"
] | Loads json source file and creates fs structure according to the
loaded data.
This is high level utility. It pipes result of _load to _write.
@param {String} dest - Path to destination location on file system.
@param {String} source - File system path of the source json file.
@param {Function} callback - Callback that ... | [
"Loads",
"json",
"source",
"file",
"and",
"creates",
"fs",
"structure",
"according",
"to",
"the",
"loaded",
"data",
".",
"This",
"is",
"high",
"level",
"utility",
".",
"It",
"pipes",
"result",
"of",
"_load",
"to",
"_write",
"."
] | fe2419e6b0a4e9116f4ae028959b6f0e3a514d21 | https://github.com/okramolis/dirio/blob/fe2419e6b0a4e9116f4ae028959b6f0e3a514d21/lib/dirio.js#L242-L244 | train |
okramolis/dirio | lib/dirio.js | _read2store | function _read2store(stat, dest, source, callback) {
_read(stat, source, _pipe.bind(null, _store.bind(null, dest), callback));
} | javascript | function _read2store(stat, dest, source, callback) {
_read(stat, source, _pipe.bind(null, _store.bind(null, dest), callback));
} | [
"function",
"_read2store",
"(",
"stat",
",",
"dest",
",",
"source",
",",
"callback",
")",
"{",
"_read",
"(",
"stat",
",",
"source",
",",
"_pipe",
".",
"bind",
"(",
"null",
",",
"_store",
".",
"bind",
"(",
"null",
",",
"dest",
")",
",",
"callback",
... | Analyzes fs structure and stores the data in json file.
This is high level utility. It pipes result of _read to _store.
@param {Function} stat - Function of fs module fs.stat or fs.lstat.
@param {String} dest - File system path of the new file.
@param {String} source - Path to source location on file system.
@param {Fu... | [
"Analyzes",
"fs",
"structure",
"and",
"stores",
"the",
"data",
"in",
"json",
"file",
".",
"This",
"is",
"high",
"level",
"utility",
".",
"It",
"pipes",
"result",
"of",
"_read",
"to",
"_store",
"."
] | fe2419e6b0a4e9116f4ae028959b6f0e3a514d21 | https://github.com/okramolis/dirio/blob/fe2419e6b0a4e9116f4ae028959b6f0e3a514d21/lib/dirio.js#L255-L257 | train |
okramolis/dirio | lib/dirio.js | _pipe | function _pipe(out, callback, err, iresult) {
if (err) return callback(err);
out(iresult, callback);
} | javascript | function _pipe(out, callback, err, iresult) {
if (err) return callback(err);
out(iresult, callback);
} | [
"function",
"_pipe",
"(",
"out",
",",
"callback",
",",
"err",
",",
"iresult",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"out",
"(",
"iresult",
",",
"callback",
")",
";",
"}"
] | Used to pipe input operation to output operation.
@param {Function} out - Output operation.
@param {Function} callback - Callback that expects only
a possible error.
@param {*} err - Possible error passed by caller.
@param {Object} iresult - Result of the input operation. | [
"Used",
"to",
"pipe",
"input",
"operation",
"to",
"output",
"operation",
"."
] | fe2419e6b0a4e9116f4ae028959b6f0e3a514d21 | https://github.com/okramolis/dirio/blob/fe2419e6b0a4e9116f4ae028959b6f0e3a514d21/lib/dirio.js#L267-L270 | train |
okramolis/dirio | lib/dirio.js | _handleConvert | function _handleConvert(stat, dest, source, callback) {
// "dest" arg is optional
if (typeof source === 'function') {
callback = source;
source = dest;
dest = null;
}
// assert input params
assert.ok(
dest === null || typeof dest === 'string',
'Invalid type of argument "dest", expected "n... | javascript | function _handleConvert(stat, dest, source, callback) {
// "dest" arg is optional
if (typeof source === 'function') {
callback = source;
source = dest;
dest = null;
}
// assert input params
assert.ok(
dest === null || typeof dest === 'string',
'Invalid type of argument "dest", expected "n... | [
"function",
"_handleConvert",
"(",
"stat",
",",
"dest",
",",
"source",
",",
"callback",
")",
"{",
"// \"dest\" arg is optional",
"if",
"(",
"typeof",
"source",
"===",
"'function'",
")",
"{",
"callback",
"=",
"source",
";",
"source",
"=",
"dest",
";",
"dest",... | Asserts user input and calls appropriate lower level function to
complete the desired task.
@param {Function} stat - Function of fs module fs.stat or fs.lstat.
@param {String} [dest] - Path to destination location on file system.
@param {String | Object} source - Path to source location on file system
or object directl... | [
"Asserts",
"user",
"input",
"and",
"calls",
"appropriate",
"lower",
"level",
"function",
"to",
"complete",
"the",
"desired",
"task",
"."
] | fe2419e6b0a4e9116f4ae028959b6f0e3a514d21 | https://github.com/okramolis/dirio/blob/fe2419e6b0a4e9116f4ae028959b6f0e3a514d21/lib/dirio.js#L292-L349 | train |
deniszatsepin/rotor-entity | lib/entity.js | Entity | function Entity(param) {
EventEmitter2.apply(this, arguments);
Entity.prototype.init.apply(this, arguments);
} | javascript | function Entity(param) {
EventEmitter2.apply(this, arguments);
Entity.prototype.init.apply(this, arguments);
} | [
"function",
"Entity",
"(",
"param",
")",
"{",
"EventEmitter2",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"Entity",
".",
"prototype",
".",
"init",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}"
] | Entity, basic element in rotor-web engine.
@param {object} param
@param {string} param.name - Entity name. If undefined, name will be 'Entity:id'
@constructor | [
"Entity",
"basic",
"element",
"in",
"rotor",
"-",
"web",
"engine",
"."
] | ec48b4b459452d7361f91042a420c144225788b4 | https://github.com/deniszatsepin/rotor-entity/blob/ec48b4b459452d7361f91042a420c144225788b4/lib/entity.js#L10-L13 | train |
tether/isokay | index.js | validator | function validator (data, schema) {
const result = Object.assign({}, data)
Object.keys(schema).map(key => {
let value = schema[key]
const type = typeof value
if (type !== 'object') {
value = {
transform: value
}
}
validate(value, result, key)
})
return result
} | javascript | function validator (data, schema) {
const result = Object.assign({}, data)
Object.keys(schema).map(key => {
let value = schema[key]
const type = typeof value
if (type !== 'object') {
value = {
transform: value
}
}
validate(value, result, key)
})
return result
} | [
"function",
"validator",
"(",
"data",
",",
"schema",
")",
"{",
"const",
"result",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"data",
")",
"Object",
".",
"keys",
"(",
"schema",
")",
".",
"map",
"(",
"key",
"=>",
"{",
"let",
"value",
"=",
"s... | Validate object against schema.
@param {Object} data
@param {Object} schema
@return {Object}
@api public | [
"Validate",
"object",
"against",
"schema",
"."
] | 3d40832806712267a213c489db3efde57f21f588 | https://github.com/tether/isokay/blob/3d40832806712267a213c489db3efde57f21f588/index.js#L26-L39 | train |
tether/isokay | index.js | coerce | function coerce (type, field, value) {
let result
if (type === 'string') {
result = String(value).trim()
} else if (type === 'number') {
result = Number(value)
if (isNaN(result)) throw new Error(`field ${field} can not be converted to a number`)
} else if (type === 'array') {
result = [].concat(... | javascript | function coerce (type, field, value) {
let result
if (type === 'string') {
result = String(value).trim()
} else if (type === 'number') {
result = Number(value)
if (isNaN(result)) throw new Error(`field ${field} can not be converted to a number`)
} else if (type === 'array') {
result = [].concat(... | [
"function",
"coerce",
"(",
"type",
",",
"field",
",",
"value",
")",
"{",
"let",
"result",
"if",
"(",
"type",
"===",
"'string'",
")",
"{",
"result",
"=",
"String",
"(",
"value",
")",
".",
"trim",
"(",
")",
"}",
"else",
"if",
"(",
"type",
"===",
"'... | Coerce value.
Trigger
@param {String} type
@param {String} field name
@param {Any} value
@api private | [
"Coerce",
"value",
"."
] | 3d40832806712267a213c489db3efde57f21f588 | https://github.com/tether/isokay/blob/3d40832806712267a213c489db3efde57f21f588/index.js#L109-L128 | train |
commenthol/streamss | lib/splitline.js | SplitLine | function SplitLine (options) {
if (!(this instanceof SplitLine)) {
return new SplitLine(options)
}
this.options = options || {}
Transform.call(this, _omit(this.options, ['matcher', 'chomp']))
this.offset = 0
this.options.matcher = (typeof this.options.matcher === 'string'
? this.options.matcher.ch... | javascript | function SplitLine (options) {
if (!(this instanceof SplitLine)) {
return new SplitLine(options)
}
this.options = options || {}
Transform.call(this, _omit(this.options, ['matcher', 'chomp']))
this.offset = 0
this.options.matcher = (typeof this.options.matcher === 'string'
? this.options.matcher.ch... | [
"function",
"SplitLine",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"SplitLine",
")",
")",
"{",
"return",
"new",
"SplitLine",
"(",
"options",
")",
"}",
"this",
".",
"options",
"=",
"options",
"||",
"{",
"}",
"Transform",
".",
... | Split a stream by a single char
@constructor
@param {Object} [options] - Stream Options `{encoding, highWaterMark, decodeStrings, ...}`
@param {Boolean} options.chomp - Do not emit the matching char. Default=false
@param {String} options.matcher - String use for splitting up the stream. Default=0x0a
@return {Transform... | [
"Split",
"a",
"stream",
"by",
"a",
"single",
"char"
] | cfef5d0ed30c7efe002018886e2e843c91d3558f | https://github.com/commenthol/streamss/blob/cfef5d0ed30c7efe002018886e2e843c91d3558f/lib/splitline.js#L21-L37 | train |
brianloveswords/gogo | lib/migration.js | lookup | function lookup(version, migrations) {
var regex = RegExp('^' + version + '.*$');
for (var m in migrations)
if (migrations.hasOwnProperty(m) && m.match(regex)) return m;
return null;
} | javascript | function lookup(version, migrations) {
var regex = RegExp('^' + version + '.*$');
for (var m in migrations)
if (migrations.hasOwnProperty(m) && m.match(regex)) return m;
return null;
} | [
"function",
"lookup",
"(",
"version",
",",
"migrations",
")",
"{",
"var",
"regex",
"=",
"RegExp",
"(",
"'^'",
"+",
"version",
"+",
"'.*$'",
")",
";",
"for",
"(",
"var",
"m",
"in",
"migrations",
")",
"if",
"(",
"migrations",
".",
"hasOwnProperty",
"(",
... | We need to be able to look up migrations by their numeric identifier without concerning ourselves with the description. | [
"We",
"need",
"to",
"be",
"able",
"to",
"look",
"up",
"migrations",
"by",
"their",
"numeric",
"identifier",
"without",
"concerning",
"ourselves",
"with",
"the",
"description",
"."
] | f17ee794e0439ed961907f52b91bcb74dcca351a | https://github.com/brianloveswords/gogo/blob/f17ee794e0439ed961907f52b91bcb74dcca351a/lib/migration.js#L12-L17 | train |
jkroso/rel-svg-path | index.js | relative | function relative(path){
var startX = 0
var startY = 0
var x = 0
var y = 0
return path.map(function(seg){
seg = seg.slice()
var type = seg[0]
var command = type.toLowerCase()
// is absolute
if (type != command) {
seg[0] = command
switch (type) {
case 'A':
se... | javascript | function relative(path){
var startX = 0
var startY = 0
var x = 0
var y = 0
return path.map(function(seg){
seg = seg.slice()
var type = seg[0]
var command = type.toLowerCase()
// is absolute
if (type != command) {
seg[0] = command
switch (type) {
case 'A':
se... | [
"function",
"relative",
"(",
"path",
")",
"{",
"var",
"startX",
"=",
"0",
"var",
"startY",
"=",
"0",
"var",
"x",
"=",
"0",
"var",
"y",
"=",
"0",
"return",
"path",
".",
"map",
"(",
"function",
"(",
"seg",
")",
"{",
"seg",
"=",
"seg",
".",
"slice... | define `path` using relative points
@param {Array} path
@return {Array} | [
"define",
"path",
"using",
"relative",
"points"
] | faf6f268f31ecd9177191c918634fd8096bb4845 | https://github.com/jkroso/rel-svg-path/blob/faf6f268f31ecd9177191c918634fd8096bb4845/index.js#L11-L69 | train |
shinuza/captain-core | lib/models/posts_tags.js | postGetTags | function postGetTags(id, cb) {
var q =
'SELECT * FROM tags t ' +
'JOIN posts_tags pt ON t.id = pt.tag_id AND pt.post_id = $1';
db.getClient(function(err, client, done) {
client.query(q, [id], function(err, r) {
if(err) {
cb(err);
done(err);
} else {
cb(null, r.row... | javascript | function postGetTags(id, cb) {
var q =
'SELECT * FROM tags t ' +
'JOIN posts_tags pt ON t.id = pt.tag_id AND pt.post_id = $1';
db.getClient(function(err, client, done) {
client.query(q, [id], function(err, r) {
if(err) {
cb(err);
done(err);
} else {
cb(null, r.row... | [
"function",
"postGetTags",
"(",
"id",
",",
"cb",
")",
"{",
"var",
"q",
"=",
"'SELECT * FROM tags t '",
"+",
"'JOIN posts_tags pt ON t.id = pt.tag_id AND pt.post_id = $1'",
";",
"db",
".",
"getClient",
"(",
"function",
"(",
"err",
",",
"client",
",",
"done",
")",
... | Gets tags associated with posts with id `id`
@param {Number} id
@param {Function} cb | [
"Gets",
"tags",
"associated",
"with",
"posts",
"with",
"id",
"id"
] | 02f3a404cdfca608e8726bbacc33e32fec484b21 | https://github.com/shinuza/captain-core/blob/02f3a404cdfca608e8726bbacc33e32fec484b21/lib/models/posts_tags.js#L106-L122 | train |
shinuza/captain-core | lib/models/posts_tags.js | postSetTags | function postSetTags(post_id, tags, cb) {
var ids = _.pluck(tags, 'id')
, q1 = 'DELETE FROM posts_tags WHERE post_id = $1'
, q2 = 'INSERT INTO posts_tags (post_id, tag_id) VALUES ' +
ids.map(function(id) {
return '(' + post_id + ',' + id + ')';
}).join(', ');
db.getClient(function(err, client... | javascript | function postSetTags(post_id, tags, cb) {
var ids = _.pluck(tags, 'id')
, q1 = 'DELETE FROM posts_tags WHERE post_id = $1'
, q2 = 'INSERT INTO posts_tags (post_id, tag_id) VALUES ' +
ids.map(function(id) {
return '(' + post_id + ',' + id + ')';
}).join(', ');
db.getClient(function(err, client... | [
"function",
"postSetTags",
"(",
"post_id",
",",
"tags",
",",
"cb",
")",
"{",
"var",
"ids",
"=",
"_",
".",
"pluck",
"(",
"tags",
",",
"'id'",
")",
",",
"q1",
"=",
"'DELETE FROM posts_tags WHERE post_id = $1'",
",",
"q2",
"=",
"'INSERT INTO posts_tags (post_id, ... | Removes existing association and associates `tags` with post with id `post_id`
@param {Number} post_id
@param {Array} tags
@param {Function} cb | [
"Removes",
"existing",
"association",
"and",
"associates",
"tags",
"with",
"post",
"with",
"id",
"post_id"
] | 02f3a404cdfca608e8726bbacc33e32fec484b21 | https://github.com/shinuza/captain-core/blob/02f3a404cdfca608e8726bbacc33e32fec484b21/lib/models/posts_tags.js#L133-L155 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/magicline/plugin.js | checkMouse | function checkMouse( mouse ) {
that.debug.groupStart( 'CheckMouse' ); // %REMOVE_LINE%
that.debug.startTimer(); // %REMOVE_LINE%
that.mouse = mouse;
that.trigger = null;
checkMouseTimer = null;
updateWindowSize( that );
if ( checkMouseTimeoutPending // -> There must be a... | javascript | function checkMouse( mouse ) {
that.debug.groupStart( 'CheckMouse' ); // %REMOVE_LINE%
that.debug.startTimer(); // %REMOVE_LINE%
that.mouse = mouse;
that.trigger = null;
checkMouseTimer = null;
updateWindowSize( that );
if ( checkMouseTimeoutPending // -> There must be a... | [
"function",
"checkMouse",
"(",
"mouse",
")",
"{",
"that",
".",
"debug",
".",
"groupStart",
"(",
"'CheckMouse'",
")",
";",
"// %REMOVE_LINE%\r",
"that",
".",
"debug",
".",
"startTimer",
"(",
")",
";",
"// %REMOVE_LINE%\r",
"that",
".",
"mouse",
"=",
"mouse",
... | This method handles mousemove mouse for box toggling. It uses mouse position to determine underlying element, then it tries to use different trigger type in order to place the box in correct place. The following procedure is executed periodically. | [
"This",
"method",
"handles",
"mousemove",
"mouse",
"for",
"box",
"toggling",
".",
"It",
"uses",
"mouse",
"position",
"to",
"determine",
"underlying",
"element",
"then",
"it",
"tries",
"to",
"use",
"different",
"trigger",
"type",
"in",
"order",
"to",
"place",
... | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/magicline/plugin.js#L304-L341 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/magicline/plugin.js | boxTrigger | function boxTrigger( triggerSetup ) {
this.upper = triggerSetup[ 0 ];
this.lower = triggerSetup[ 1 ];
this.set.apply( this, triggerSetup.slice( 2 ) );
} | javascript | function boxTrigger( triggerSetup ) {
this.upper = triggerSetup[ 0 ];
this.lower = triggerSetup[ 1 ];
this.set.apply( this, triggerSetup.slice( 2 ) );
} | [
"function",
"boxTrigger",
"(",
"triggerSetup",
")",
"{",
"this",
".",
"upper",
"=",
"triggerSetup",
"[",
"0",
"]",
";",
"this",
".",
"lower",
"=",
"triggerSetup",
"[",
"1",
"]",
";",
"this",
".",
"set",
".",
"apply",
"(",
"this",
",",
"triggerSetup",
... | boxTrigger is an abstract type which describes the relationship between elements that may result in showing the box. The following type is used by numerous methods to share information about the hypothetical box placement and look by referring to boxTrigger properties. | [
"boxTrigger",
"is",
"an",
"abstract",
"type",
"which",
"describes",
"the",
"relationship",
"between",
"elements",
"that",
"may",
"result",
"in",
"showing",
"the",
"box",
".",
"The",
"following",
"type",
"is",
"used",
"by",
"numerous",
"methods",
"to",
"share",... | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/magicline/plugin.js#L412-L416 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/magicline/plugin.js | getAscendantTrigger | function getAscendantTrigger( that ) {
var node = that.element,
trigger;
if ( node && isHtml( node ) ) {
trigger = node.getAscendant( that.triggers, true );
// If trigger is an element, neither editable nor editable's ascendant.
if ( trigger && that.editable.contains( trigger ) ) {
// Che... | javascript | function getAscendantTrigger( that ) {
var node = that.element,
trigger;
if ( node && isHtml( node ) ) {
trigger = node.getAscendant( that.triggers, true );
// If trigger is an element, neither editable nor editable's ascendant.
if ( trigger && that.editable.contains( trigger ) ) {
// Che... | [
"function",
"getAscendantTrigger",
"(",
"that",
")",
"{",
"var",
"node",
"=",
"that",
".",
"element",
",",
"trigger",
";",
"if",
"(",
"node",
"&&",
"isHtml",
"(",
"node",
")",
")",
"{",
"trigger",
"=",
"node",
".",
"getAscendant",
"(",
"that",
".",
"... | Gets the closest parent node that belongs to triggers group. | [
"Gets",
"the",
"closest",
"parent",
"node",
"that",
"belongs",
"to",
"triggers",
"group",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/magicline/plugin.js#L478-L506 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/magicline/plugin.js | function() {
that.debug.groupStart( 'mouseNear' ); // %REMOVE_LINE%
updateSize( that, this );
var offset = that.holdDistance,
size = this.size;
// Determine neighborhood by element dimensions and offsets.
if ( size && inBetween( that.mouse.y, size.top - offset, size.bottom + offset ) ... | javascript | function() {
that.debug.groupStart( 'mouseNear' ); // %REMOVE_LINE%
updateSize( that, this );
var offset = that.holdDistance,
size = this.size;
// Determine neighborhood by element dimensions and offsets.
if ( size && inBetween( that.mouse.y, size.top - offset, size.bottom + offset ) ... | [
"function",
"(",
")",
"{",
"that",
".",
"debug",
".",
"groupStart",
"(",
"'mouseNear'",
")",
";",
"// %REMOVE_LINE%\r",
"updateSize",
"(",
"that",
",",
"this",
")",
";",
"var",
"offset",
"=",
"that",
".",
"holdDistance",
",",
"size",
"=",
"this",
".",
... | Checks whether mouseY is around an element by comparing boundaries and considering an offset distance. | [
"Checks",
"whether",
"mouseY",
"is",
"around",
"an",
"element",
"by",
"comparing",
"boundaries",
"and",
"considering",
"an",
"offset",
"distance",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/magicline/plugin.js#L632-L647 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/magicline/plugin.js | isChildBetweenPointerAndEdge | function isChildBetweenPointerAndEdge( that, parent, edgeBottom ) {
var edgeChild = parent[ edgeBottom ? 'getLast' : 'getFirst' ]( function( node ) {
return that.isRelevant( node ) && !node.is( DTD_TABLECONTENT );
} );
if ( !edgeChild )
return false;
updateSize( that, edgeChild );
return ed... | javascript | function isChildBetweenPointerAndEdge( that, parent, edgeBottom ) {
var edgeChild = parent[ edgeBottom ? 'getLast' : 'getFirst' ]( function( node ) {
return that.isRelevant( node ) && !node.is( DTD_TABLECONTENT );
} );
if ( !edgeChild )
return false;
updateSize( that, edgeChild );
return ed... | [
"function",
"isChildBetweenPointerAndEdge",
"(",
"that",
",",
"parent",
",",
"edgeBottom",
")",
"{",
"var",
"edgeChild",
"=",
"parent",
"[",
"edgeBottom",
"?",
"'getLast'",
":",
"'getFirst'",
"]",
"(",
"function",
"(",
"node",
")",
"{",
"return",
"that",
"."... | This function checks vertically is there's a relevant child between element's edge and the pointer. \-> Table contents are omitted. | [
"This",
"function",
"checks",
"vertically",
"is",
"there",
"s",
"a",
"relevant",
"child",
"between",
"element",
"s",
"edge",
"and",
"the",
"pointer",
".",
"\\",
"-",
">",
"Table",
"contents",
"are",
"omitted",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/magicline/plugin.js#L1077-L1088 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/magicline/plugin.js | expandSelector | function expandSelector( that, node ) {
return !( isTextNode( node )
|| isComment( node )
|| isFlowBreaker( node )
|| isLine( that, node )
|| ( node.type == CKEDITOR.NODE_ELEMENT && node.$ && node.is( 'br' ) ) );
} | javascript | function expandSelector( that, node ) {
return !( isTextNode( node )
|| isComment( node )
|| isFlowBreaker( node )
|| isLine( that, node )
|| ( node.type == CKEDITOR.NODE_ELEMENT && node.$ && node.is( 'br' ) ) );
} | [
"function",
"expandSelector",
"(",
"that",
",",
"node",
")",
"{",
"return",
"!",
"(",
"isTextNode",
"(",
"node",
")",
"||",
"isComment",
"(",
"node",
")",
"||",
"isFlowBreaker",
"(",
"node",
")",
"||",
"isLine",
"(",
"that",
",",
"node",
")",
"||",
"... | This is default element selector used by the engine. | [
"This",
"is",
"default",
"element",
"selector",
"used",
"by",
"the",
"engine",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/magicline/plugin.js#L1537-L1543 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/magicline/plugin.js | expandFilter | function expandFilter( that, trigger ) {
that.debug.groupStart( 'expandFilter' ); // %REMOVE_LINE%
var upper = trigger.upper,
lower = trigger.lower;
if ( !upper || !lower // NOT: EDGE_MIDDLE trigger ALWAYS has two elements.
|| isFlowBreaker( lower ) || isFlowBreaker( upper ) // NO... | javascript | function expandFilter( that, trigger ) {
that.debug.groupStart( 'expandFilter' ); // %REMOVE_LINE%
var upper = trigger.upper,
lower = trigger.lower;
if ( !upper || !lower // NOT: EDGE_MIDDLE trigger ALWAYS has two elements.
|| isFlowBreaker( lower ) || isFlowBreaker( upper ) // NO... | [
"function",
"expandFilter",
"(",
"that",
",",
"trigger",
")",
"{",
"that",
".",
"debug",
".",
"groupStart",
"(",
"'expandFilter'",
")",
";",
"// %REMOVE_LINE%\r",
"var",
"upper",
"=",
"trigger",
".",
"upper",
",",
"lower",
"=",
"trigger",
".",
"lower",
";"... | A method for trigger filtering. Accepts or rejects trigger pairs by their location in DOM etc. | [
"A",
"method",
"for",
"trigger",
"filtering",
".",
"Accepts",
"or",
"rejects",
"trigger",
"pairs",
"by",
"their",
"location",
"in",
"DOM",
"etc",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/magicline/plugin.js#L1571-L1598 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/magicline/plugin.js | verticalSearch | function verticalSearch( that, stopCondition, selectCriterion, startElement ) {
var upper = startElement,
lower = startElement,
mouseStep = 0,
upperFound = false,
lowerFound = false,
viewPaneHeight = that.view.pane.height,
mouse = that.mouse;
while ( mouse.y + mouseStep < viewPaneHeight ... | javascript | function verticalSearch( that, stopCondition, selectCriterion, startElement ) {
var upper = startElement,
lower = startElement,
mouseStep = 0,
upperFound = false,
lowerFound = false,
viewPaneHeight = that.view.pane.height,
mouse = that.mouse;
while ( mouse.y + mouseStep < viewPaneHeight ... | [
"function",
"verticalSearch",
"(",
"that",
",",
"stopCondition",
",",
"selectCriterion",
",",
"startElement",
")",
"{",
"var",
"upper",
"=",
"startElement",
",",
"lower",
"=",
"startElement",
",",
"mouseStep",
"=",
"0",
",",
"upperFound",
"=",
"false",
",",
... | This method searches document vertically using given select criterion until stop criterion is fulfilled. | [
"This",
"method",
"searches",
"document",
"vertically",
"using",
"given",
"select",
"criterion",
"until",
"stop",
"criterion",
"is",
"fulfilled",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/magicline/plugin.js#L1731-L1763 | train |
Pocketbrain/native-ads-web-ad-library | src/events.js | addListener | function addListener(event, callback) {
checkEventValid(event);
if (listeners[event]) {
listeners[event].push(callback);
} else {
listeners[event] = [callback];
}
} | javascript | function addListener(event, callback) {
checkEventValid(event);
if (listeners[event]) {
listeners[event].push(callback);
} else {
listeners[event] = [callback];
}
} | [
"function",
"addListener",
"(",
"event",
",",
"callback",
")",
"{",
"checkEventValid",
"(",
"event",
")",
";",
"if",
"(",
"listeners",
"[",
"event",
"]",
")",
"{",
"listeners",
"[",
"event",
"]",
".",
"push",
"(",
"callback",
")",
";",
"}",
"else",
"... | Add a new event listener
@param {events} event - The name of the event listener to add an event for
@param {function} callback - The callback to invoke when the event is called | [
"Add",
"a",
"new",
"event",
"listener"
] | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/events.js#L31-L39 | train |
Pocketbrain/native-ads-web-ad-library | src/events.js | removeListener | function removeListener(event, eventHandler) {
checkEventValid(event);
if (listeners[event] && listeners[event].length) {
var indexOfListener = listeners[event].indexOf(eventHandler);
if (indexOfListener > -1) {
listeners[event].splice(indexOfListener, 1);
}
}
} | javascript | function removeListener(event, eventHandler) {
checkEventValid(event);
if (listeners[event] && listeners[event].length) {
var indexOfListener = listeners[event].indexOf(eventHandler);
if (indexOfListener > -1) {
listeners[event].splice(indexOfListener, 1);
}
}
} | [
"function",
"removeListener",
"(",
"event",
",",
"eventHandler",
")",
"{",
"checkEventValid",
"(",
"event",
")",
";",
"if",
"(",
"listeners",
"[",
"event",
"]",
"&&",
"listeners",
"[",
"event",
"]",
".",
"length",
")",
"{",
"var",
"indexOfListener",
"=",
... | Remove a certain event listener
@param {events} event - The name of the event to listen to
@param {function} eventHandler - The eventHandler that is bound to this listener and should be removed | [
"Remove",
"a",
"certain",
"event",
"listener"
] | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/events.js#L46-L55 | train |
JrSchild/grunt-retinafy | tasks/retinafy.js | processSize | function processSize(targetSize, origSize) {
var match = (targetSize.match(r_percentage) || [])[1];
if (match /= 100) {
return {
width: origSize.width * match,
height: 0
};
} else {
return {
width: (targetSize.match(r_width) || [])[1] || 0,
height: (targetSize.match(r_height) || [])[1] |... | javascript | function processSize(targetSize, origSize) {
var match = (targetSize.match(r_percentage) || [])[1];
if (match /= 100) {
return {
width: origSize.width * match,
height: 0
};
} else {
return {
width: (targetSize.match(r_width) || [])[1] || 0,
height: (targetSize.match(r_height) || [])[1] |... | [
"function",
"processSize",
"(",
"targetSize",
",",
"origSize",
")",
"{",
"var",
"match",
"=",
"(",
"targetSize",
".",
"match",
"(",
"r_percentage",
")",
"||",
"[",
"]",
")",
"[",
"1",
"]",
";",
"if",
"(",
"match",
"/=",
"100",
")",
"{",
"return",
"... | Height matching.
Process the size, return object of new size.
Currently only test percentages. | [
"Height",
"matching",
".",
"Process",
"the",
"size",
"return",
"object",
"of",
"new",
"size",
".",
"Currently",
"only",
"test",
"percentages",
"."
] | 85ae8bf7c17bfdcf3a860448848be0e3fe4b1f0e | https://github.com/JrSchild/grunt-retinafy/blob/85ae8bf7c17bfdcf3a860448848be0e3fe4b1f0e/tasks/retinafy.js#L26-L40 | train |
JrSchild/grunt-retinafy | tasks/retinafy.js | convertSizes | function convertSizes(sizes) {
var tmp = [];
for (var size in sizes) {
tmp.push({
size: size,
settings: _.extend({suffix: '', prefix: ''}, sizes[size])
});
}
return tmp;
} | javascript | function convertSizes(sizes) {
var tmp = [];
for (var size in sizes) {
tmp.push({
size: size,
settings: _.extend({suffix: '', prefix: ''}, sizes[size])
});
}
return tmp;
} | [
"function",
"convertSizes",
"(",
"sizes",
")",
"{",
"var",
"tmp",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"size",
"in",
"sizes",
")",
"{",
"tmp",
".",
"push",
"(",
"{",
"size",
":",
"size",
",",
"settings",
":",
"_",
".",
"extend",
"(",
"{",
"su... | In order to do async.each we have to iterate over an array
Turn the sizes-object into an array of objects.
@param {Object} sizes
@return {Object} | [
"In",
"order",
"to",
"do",
"async",
".",
"each",
"we",
"have",
"to",
"iterate",
"over",
"an",
"array",
"Turn",
"the",
"sizes",
"-",
"object",
"into",
"an",
"array",
"of",
"objects",
"."
] | 85ae8bf7c17bfdcf3a860448848be0e3fe4b1f0e | https://github.com/JrSchild/grunt-retinafy/blob/85ae8bf7c17bfdcf3a860448848be0e3fe4b1f0e/tasks/retinafy.js#L48-L57 | train |
jakub-g/grunt-run-phantom-specs | tasks/grunt-run-phantom-specs.js | getPhantomExitCb | function getPhantomExitCb (specId, allSpecs, cfg, done) {
var spawnCb = function (error, result, code) {
if (error) {
ok = false;
if (cfg.debug) {
console.log("PhantomJS exited with code " + code);
}
}
var n... | javascript | function getPhantomExitCb (specId, allSpecs, cfg, done) {
var spawnCb = function (error, result, code) {
if (error) {
ok = false;
if (cfg.debug) {
console.log("PhantomJS exited with code " + code);
}
}
var n... | [
"function",
"getPhantomExitCb",
"(",
"specId",
",",
"allSpecs",
",",
"cfg",
",",
"done",
")",
"{",
"var",
"spawnCb",
"=",
"function",
"(",
"error",
",",
"result",
",",
"code",
")",
"{",
"if",
"(",
"error",
")",
"{",
"ok",
"=",
"false",
";",
"if",
"... | Factory of phantom exit callbacks. Created callback for n-th spec runs the n+1-st spec,
or finishes the grunt task for the last spec.
@return {Function} standard node process-exit callback | [
"Factory",
"of",
"phantom",
"exit",
"callbacks",
".",
"Created",
"callback",
"for",
"n",
"-",
"th",
"spec",
"runs",
"the",
"n",
"+",
"1",
"-",
"st",
"spec",
"or",
"finishes",
"the",
"grunt",
"task",
"for",
"the",
"last",
"spec",
"."
] | a3dc6a8f058bbd4edb161edca5234caa6b2fb27a | https://github.com/jakub-g/grunt-run-phantom-specs/blob/a3dc6a8f058bbd4edb161edca5234caa6b2fb27a/tasks/grunt-run-phantom-specs.js#L52-L68 | train |
jakub-g/grunt-run-phantom-specs | tasks/grunt-run-phantom-specs.js | startPhantom | function startPhantom (specPath, cfg, cb) {
var args = [specPath];
if (cfg.verbose) {
args.push("--verbose"); // custom, to be handled by spec runner
}
if (cfg.debug) {
args.push("--debug"); // custom, to be handled by spec runner
}
if (cfg.color) ... | javascript | function startPhantom (specPath, cfg, cb) {
var args = [specPath];
if (cfg.verbose) {
args.push("--verbose"); // custom, to be handled by spec runner
}
if (cfg.debug) {
args.push("--debug"); // custom, to be handled by spec runner
}
if (cfg.color) ... | [
"function",
"startPhantom",
"(",
"specPath",
",",
"cfg",
",",
"cb",
")",
"{",
"var",
"args",
"=",
"[",
"specPath",
"]",
";",
"if",
"(",
"cfg",
".",
"verbose",
")",
"{",
"args",
".",
"push",
"(",
"\"--verbose\"",
")",
";",
"// custom, to be handled by spe... | Boots phantomjs executable with `specPath` as a param, and executes
given callback `cb` when phantom process exits.
@param {String} specPath
@param {Object} cfg
@param {Function} cb | [
"Boots",
"phantomjs",
"executable",
"with",
"specPath",
"as",
"a",
"param",
"and",
"executes",
"given",
"callback",
"cb",
"when",
"phantom",
"process",
"exits",
"."
] | a3dc6a8f058bbd4edb161edca5234caa6b2fb27a | https://github.com/jakub-g/grunt-run-phantom-specs/blob/a3dc6a8f058bbd4edb161edca5234caa6b2fb27a/tasks/grunt-run-phantom-specs.js#L77-L97 | train |
jakub-g/grunt-run-phantom-specs | tasks/grunt-run-phantom-specs.js | startSpec | function startSpec (n, allSpecs, cfg, done) {
var printId = n + 1;
var specPath = allSpecs[n];
var nSpecs = allSpecs.length;
var msg = "Running spec file " + specPath + " [" + printId + "/" + nSpecs + "]";
var bar = Array(process.stdout.columns).join("*");
console.log("\... | javascript | function startSpec (n, allSpecs, cfg, done) {
var printId = n + 1;
var specPath = allSpecs[n];
var nSpecs = allSpecs.length;
var msg = "Running spec file " + specPath + " [" + printId + "/" + nSpecs + "]";
var bar = Array(process.stdout.columns).join("*");
console.log("\... | [
"function",
"startSpec",
"(",
"n",
",",
"allSpecs",
",",
"cfg",
",",
"done",
")",
"{",
"var",
"printId",
"=",
"n",
"+",
"1",
";",
"var",
"specPath",
"=",
"allSpecs",
"[",
"n",
"]",
";",
"var",
"nSpecs",
"=",
"allSpecs",
".",
"length",
";",
"var",
... | Prints some info and relays config to start the n-th spec
@param {Integer} n
@param {Array} allSpecs
@param {Object} cfg
@param {Function} done | [
"Prints",
"some",
"info",
"and",
"relays",
"config",
"to",
"start",
"the",
"n",
"-",
"th",
"spec"
] | a3dc6a8f058bbd4edb161edca5234caa6b2fb27a | https://github.com/jakub-g/grunt-run-phantom-specs/blob/a3dc6a8f058bbd4edb161edca5234caa6b2fb27a/tasks/grunt-run-phantom-specs.js#L106-L119 | train |
phated/grunt-enyo | tasks/init/enyo/root/enyo/source/touch/Scroller.js | function(inSender, e) {
// if a scroll event originated here, pass it to our strategy to handle
if (this.$.strategy.domScroll && e.originator == this) {
this.$.strategy.scroll(inSender, e);
}
this.doScroll(e);
return true;
} | javascript | function(inSender, e) {
// if a scroll event originated here, pass it to our strategy to handle
if (this.$.strategy.domScroll && e.originator == this) {
this.$.strategy.scroll(inSender, e);
}
this.doScroll(e);
return true;
} | [
"function",
"(",
"inSender",
",",
"e",
")",
"{",
"// if a scroll event originated here, pass it to our strategy to handle",
"if",
"(",
"this",
".",
"$",
".",
"strategy",
".",
"domScroll",
"&&",
"e",
".",
"originator",
"==",
"this",
")",
"{",
"this",
".",
"$",
... | Normalizes scroll event to onScroll. | [
"Normalizes",
"scroll",
"event",
"to",
"onScroll",
"."
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/touch/Scroller.js#L231-L238 | train | |
edinella/ploud | public/js/jquery.filedrop.js | function() {
var fileIndex;
if (stop_loop) {
return false;
}
// Check to see if are in queue mode
if (opts.queuefiles > 0 && processingQueue.length >= opts.queuefiles) {
return pause(opts.queuewait);
} else {
// Take first thing off work q... | javascript | function() {
var fileIndex;
if (stop_loop) {
return false;
}
// Check to see if are in queue mode
if (opts.queuefiles > 0 && processingQueue.length >= opts.queuefiles) {
return pause(opts.queuewait);
} else {
// Take first thing off work q... | [
"function",
"(",
")",
"{",
"var",
"fileIndex",
";",
"if",
"(",
"stop_loop",
")",
"{",
"return",
"false",
";",
"}",
"// Check to see if are in queue mode",
"if",
"(",
"opts",
".",
"queuefiles",
">",
"0",
"&&",
"processingQueue",
".",
"length",
">=",
"opts",
... | Process an upload, recursive | [
"Process",
"an",
"upload",
"recursive"
] | ccf01fd213482b320a0a804f100eaae007103b6d | https://github.com/edinella/ploud/blob/ccf01fd213482b320a0a804f100eaae007103b6d/public/js/jquery.filedrop.js#L224-L289 | train | |
Magneds/hapi-plugin-barcode | source/QR.js | ratio | function ratio(options) {
const { width, height } = options;
if ((width || height) && !(width && height)) {
if (width) {
options.height = width;
}
if (height) {
options.width = height;
}
}
return options;
} | javascript | function ratio(options) {
const { width, height } = options;
if ((width || height) && !(width && height)) {
if (width) {
options.height = width;
}
if (height) {
options.width = height;
}
}
return options;
} | [
"function",
"ratio",
"(",
"options",
")",
"{",
"const",
"{",
"width",
",",
"height",
"}",
"=",
"options",
";",
"if",
"(",
"(",
"width",
"||",
"height",
")",
"&&",
"!",
"(",
"width",
"&&",
"height",
")",
")",
"{",
"if",
"(",
"width",
")",
"{",
"... | Determine the correct "opposite" dimension in case only one of width or height is provided
@param {object} options
@returns {object} options | [
"Determine",
"the",
"correct",
"opposite",
"dimension",
"in",
"case",
"only",
"one",
"of",
"width",
"or",
"height",
"is",
"provided"
] | 4822bd2d1aa327a752a9573151396496c080424d | https://github.com/Magneds/hapi-plugin-barcode/blob/4822bd2d1aa327a752a9573151396496c080424d/source/QR.js#L18-L31 | train |
shinuza/captain-core | lib/util/index.js | loginRequired | function loginRequired(fn) {
return function(req, res, next) {
if(isLoggedIn(req)) {
fn(req, res, next);
} else {
next(new exceptions.PermissionRequired());
}
}
} | javascript | function loginRequired(fn) {
return function(req, res, next) {
if(isLoggedIn(req)) {
fn(req, res, next);
} else {
next(new exceptions.PermissionRequired());
}
}
} | [
"function",
"loginRequired",
"(",
"fn",
")",
"{",
"return",
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"if",
"(",
"isLoggedIn",
"(",
"req",
")",
")",
"{",
"fn",
"(",
"req",
",",
"res",
",",
"next",
")",
";",
"}",
"else",
"{",
"n... | Middleware indicating that the view `fn` requires login
@param fn
@returns {Function} | [
"Middleware",
"indicating",
"that",
"the",
"view",
"fn",
"requires",
"login"
] | 02f3a404cdfca608e8726bbacc33e32fec484b21 | https://github.com/shinuza/captain-core/blob/02f3a404cdfca608e8726bbacc33e32fec484b21/lib/util/index.js#L25-L33 | train |
bahmutov/jshint-solid | src/jshint-solid.js | settingsPercentage | function settingsPercentage(projectJshintSettings) {
verify.object(projectJshintSettings, 'expected jshint object');
//console.log('looking at jshint settings\n' +
// JSON.stringify(projectJshintSettings, null, 2));
var allSettings = getAllSettings();
verify.object(allSettings, 'could not get all jshint se... | javascript | function settingsPercentage(projectJshintSettings) {
verify.object(projectJshintSettings, 'expected jshint object');
//console.log('looking at jshint settings\n' +
// JSON.stringify(projectJshintSettings, null, 2));
var allSettings = getAllSettings();
verify.object(allSettings, 'could not get all jshint se... | [
"function",
"settingsPercentage",
"(",
"projectJshintSettings",
")",
"{",
"verify",
".",
"object",
"(",
"projectJshintSettings",
",",
"'expected jshint object'",
")",
";",
"//console.log('looking at jshint settings\\n' +",
"// JSON.stringify(projectJshintSettings, null, 2));",
"va... | returns percent 0 - no valid settings, 100 - all settings specified | [
"returns",
"percent",
"0",
"-",
"no",
"valid",
"settings",
"100",
"-",
"all",
"settings",
"specified"
] | 26f86494a9961cdc3cec566d2a6809daac8c2e29 | https://github.com/bahmutov/jshint-solid/blob/26f86494a9961cdc3cec566d2a6809daac8c2e29/src/jshint-solid.js#L17-L39 | train |
airbrite/muni | collection.js | function() {
var ret = Backbone.Collection.prototype.set.apply(this, arguments);
this.each(function(model) {
// Assign `db` to all models in the collection
if (this.db) {
model.db = this.db;
}
// Assign `user` to all models in the collection
if (this.user) {
model... | javascript | function() {
var ret = Backbone.Collection.prototype.set.apply(this, arguments);
this.each(function(model) {
// Assign `db` to all models in the collection
if (this.db) {
model.db = this.db;
}
// Assign `user` to all models in the collection
if (this.user) {
model... | [
"function",
"(",
")",
"{",
"var",
"ret",
"=",
"Backbone",
".",
"Collection",
".",
"prototype",
".",
"set",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"this",
".",
"each",
"(",
"function",
"(",
"model",
")",
"{",
"// Assign `db` to all models ... | Override to assign `db` and `user` to all models in the collection on `set`
Note that the prototype must be called first and returned at the end | [
"Override",
"to",
"assign",
"db",
"and",
"user",
"to",
"all",
"models",
"in",
"the",
"collection",
"on",
"set",
"Note",
"that",
"the",
"prototype",
"must",
"be",
"called",
"first",
"and",
"returned",
"at",
"the",
"end"
] | ea8b26aa94836514374907c325a0d79f28838e2e | https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/collection.js#L51-L67 | train | |
iAmNathanJ/file-pluck | index.js | writeJSON | function writeJSON(filename, obj) {
return new Promise(function (resolve, reject) {
if (!Object.is(obj)) resolve(new Error('writeJSON requires the second argument to be an object'));
_fs2['default'].writeFile(filename, JSON.stringify(obj, null, 2) + '\n', function (err) {
if (err) reject(err)... | javascript | function writeJSON(filename, obj) {
return new Promise(function (resolve, reject) {
if (!Object.is(obj)) resolve(new Error('writeJSON requires the second argument to be an object'));
_fs2['default'].writeFile(filename, JSON.stringify(obj, null, 2) + '\n', function (err) {
if (err) reject(err)... | [
"function",
"writeJSON",
"(",
"filename",
",",
"obj",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"if",
"(",
"!",
"Object",
".",
"is",
"(",
"obj",
")",
")",
"resolve",
"(",
"new",
"Error",
"(",
"'... | write json file, return promise | [
"write",
"json",
"file",
"return",
"promise"
] | bbdd91dd8afa21076108553676045a94c76922b3 | https://github.com/iAmNathanJ/file-pluck/blob/bbdd91dd8afa21076108553676045a94c76922b3/index.js#L68-L79 | train |
binocarlos/rationalnestedset | lib/rationalnestedset.js | encode | function encode(position_array){
if(!_.isArray(position_array) || position_array.length<=0){
throw new Error('Array of tree positions required');
}
var left_position_array = _.map(position_array, function(v){return v;});
var right_position_array = _.map(position_array, function(v){return v;});
// le... | javascript | function encode(position_array){
if(!_.isArray(position_array) || position_array.length<=0){
throw new Error('Array of tree positions required');
}
var left_position_array = _.map(position_array, function(v){return v;});
var right_position_array = _.map(position_array, function(v){return v;});
// le... | [
"function",
"encode",
"(",
"position_array",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isArray",
"(",
"position_array",
")",
"||",
"position_array",
".",
"length",
"<=",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Array of tree positions required'",
")",
";",
... | Uses calculate_encoding_from_tree_position to calculate the left and right encoding for a given node It simply adds 1 to the last position in the array to get the encodings for its next sibling | [
"Uses",
"calculate_encoding_from_tree_position",
"to",
"calculate",
"the",
"left",
"and",
"right",
"encoding",
"for",
"a",
"given",
"node",
"It",
"simply",
"adds",
"1",
"to",
"the",
"last",
"position",
"in",
"the",
"array",
"to",
"get",
"the",
"encodings",
"fo... | a91b420e5de0deb00541fc547ad7e0b1f94e7d70 | https://github.com/binocarlos/rationalnestedset/blob/a91b420e5de0deb00541fc547ad7e0b1f94e7d70/lib/rationalnestedset.js#L33-L53 | train |
binocarlos/rationalnestedset | lib/rationalnestedset.js | get_parsed_encodings | function get_parsed_encodings(data){
return {
numerator:data.numerator,
denominator:data.denominator,
encoding:get_big_division(data.numerator, data.denominator)
};
} | javascript | function get_parsed_encodings(data){
return {
numerator:data.numerator,
denominator:data.denominator,
encoding:get_big_division(data.numerator, data.denominator)
};
} | [
"function",
"get_parsed_encodings",
"(",
"data",
")",
"{",
"return",
"{",
"numerator",
":",
"data",
".",
"numerator",
",",
"denominator",
":",
"data",
".",
"denominator",
",",
"encoding",
":",
"get_big_division",
"(",
"data",
".",
"numerator",
",",
"data",
"... | uses GMP to divide the numerator by the denominator and convert all values to string
@access public
@param object $data containing GMP numerator and denominator resources
@return object $data containing refactored integer, numerator and denominator string properties | [
"uses",
"GMP",
"to",
"divide",
"the",
"numerator",
"by",
"the",
"denominator",
"and",
"convert",
"all",
"values",
"to",
"string"
] | a91b420e5de0deb00541fc547ad7e0b1f94e7d70 | https://github.com/binocarlos/rationalnestedset/blob/a91b420e5de0deb00541fc547ad7e0b1f94e7d70/lib/rationalnestedset.js#L62-L73 | train |
binocarlos/rationalnestedset | lib/rationalnestedset.js | calculate_encoding_from_tree_position | function calculate_encoding_from_tree_position(position_array){
// if we have only one position then it means we have a root element (i.e. one at the top of the tree)
// and this is an easy fraction to calculate (i.e. x / 1)
if(position_array.length==1){
return get_parsed_encodings({
// the numera... | javascript | function calculate_encoding_from_tree_position(position_array){
// if we have only one position then it means we have a root element (i.e. one at the top of the tree)
// and this is an easy fraction to calculate (i.e. x / 1)
if(position_array.length==1){
return get_parsed_encodings({
// the numera... | [
"function",
"calculate_encoding_from_tree_position",
"(",
"position_array",
")",
"{",
"// if we have only one position then it means we have a root element (i.e. one at the top of the tree)",
"// and this is an easy fraction to calculate (i.e. x / 1)",
"if",
"(",
"position_array",
".",
"leng... | Calculates a finite continued fraction encoding of tree position returning a numerator and denominator representing the encoding
The tree position is provided as an array of positions, so for example the 3rd element of the 7th element of the 2nd element is represented as:
// returns array('n' => 65, 'd' => 23)
// pas... | [
"Calculates",
"a",
"finite",
"continued",
"fraction",
"encoding",
"of",
"tree",
"position",
"returning",
"a",
"numerator",
"and",
"denominator",
"representing",
"the",
"encoding"
] | a91b420e5de0deb00541fc547ad7e0b1f94e7d70 | https://github.com/binocarlos/rationalnestedset/blob/a91b420e5de0deb00541fc547ad7e0b1f94e7d70/lib/rationalnestedset.js#L175-L232 | train |
AntouanK/consologger | dist/browser-consologger.js | builder | function builder() {
// make the arguments one string
var args = stringify.apply(null, arguments);
// make the final styles object
builder._curStyles.forEach(function (thisStyle) {
objectAssign(builder._curStyle, thisStyle);
});
loggerInstance._inputsBuffer.push({
arg: args,
... | javascript | function builder() {
// make the arguments one string
var args = stringify.apply(null, arguments);
// make the final styles object
builder._curStyles.forEach(function (thisStyle) {
objectAssign(builder._curStyle, thisStyle);
});
loggerInstance._inputsBuffer.push({
arg: args,
... | [
"function",
"builder",
"(",
")",
"{",
"// make the arguments one string",
"var",
"args",
"=",
"stringify",
".",
"apply",
"(",
"null",
",",
"arguments",
")",
";",
"// make the final styles object",
"builder",
".",
"_curStyles",
".",
"forEach",
"(",
"function",
"(... | the main builder function that's what we return, and all the presets are properties of this | [
"the",
"main",
"builder",
"function",
"that",
"s",
"what",
"we",
"return",
"and",
"all",
"the",
"presets",
"are",
"properties",
"of",
"this"
] | fb021a8bf3dda16f151ba9237124eb6f1c680ef1 | https://github.com/AntouanK/consologger/blob/fb021a8bf3dda16f151ba9237124eb6f1c680ef1/dist/browser-consologger.js#L122-L142 | train |
olizilla/grunt-asciify | tasks/asciify.js | trimToMaxWidth | function trimToMaxWidth (width, text) {
var truncated = text.split('\n').map(function (line) {
return line.substring(0, width);
});
return truncated.join('\n');
} | javascript | function trimToMaxWidth (width, text) {
var truncated = text.split('\n').map(function (line) {
return line.substring(0, width);
});
return truncated.join('\n');
} | [
"function",
"trimToMaxWidth",
"(",
"width",
",",
"text",
")",
"{",
"var",
"truncated",
"=",
"text",
".",
"split",
"(",
"'\\n'",
")",
".",
"map",
"(",
"function",
"(",
"line",
")",
"{",
"return",
"line",
".",
"substring",
"(",
"0",
",",
"width",
")",
... | truncate the ascii art to fit a thing | [
"truncate",
"the",
"ascii",
"art",
"to",
"fit",
"a",
"thing"
] | 0a72ed3451478334fae4e96b0f8e2cd58cfeee2a | https://github.com/olizilla/grunt-asciify/blob/0a72ed3451478334fae4e96b0f8e2cd58cfeee2a/tasks/asciify.js#L58-L63 | train |
mwyatt/feedback-queue | js/feedbackQueue.js | getContainer | function getContainer() {
if (container) {
return container;
}
body.insertAdjacentHTML('afterbegin', mustache.render(containerTemplate));
container = document.querySelector('.js-feedback-queue');
return container;
} | javascript | function getContainer() {
if (container) {
return container;
}
body.insertAdjacentHTML('afterbegin', mustache.render(containerTemplate));
container = document.querySelector('.js-feedback-queue');
return container;
} | [
"function",
"getContainer",
"(",
")",
"{",
"if",
"(",
"container",
")",
"{",
"return",
"container",
";",
"}",
"body",
".",
"insertAdjacentHTML",
"(",
"'afterbegin'",
",",
"mustache",
".",
"render",
"(",
"containerTemplate",
")",
")",
";",
"container",
"=",
... | create and or return dom node | [
"create",
"and",
"or",
"return",
"dom",
"node"
] | 25a7b13bd783db190dc85c6709db4616aa7e14b4 | https://github.com/mwyatt/feedback-queue/blob/25a7b13bd783db190dc85c6709db4616aa7e14b4/js/feedbackQueue.js#L13-L22 | train |
huafu/ember-dev-fixtures | private/adapters/dev-fixtures.js | function (store, type, record, addId) {
var json;
type = this._parseModelOrType(store, type);
json = record.serialize({includeId: true});
if (!json.id && addId) {
json.id = this.generateId(store, type);
}
type.eachRelationship(function (key, meta) {
var records;
if (!meta.async... | javascript | function (store, type, record, addId) {
var json;
type = this._parseModelOrType(store, type);
json = record.serialize({includeId: true});
if (!json.id && addId) {
json.id = this.generateId(store, type);
}
type.eachRelationship(function (key, meta) {
var records;
if (!meta.async... | [
"function",
"(",
"store",
",",
"type",
",",
"record",
",",
"addId",
")",
"{",
"var",
"json",
";",
"type",
"=",
"this",
".",
"_parseModelOrType",
"(",
"store",
",",
"type",
")",
";",
"json",
"=",
"record",
".",
"serialize",
"(",
"{",
"includeId",
":",... | Generate the JSON for a record
@method mockJSON
@param {DS.Store} store
@param {subclass of DS.Model|string} type
@param {DS.Model} record
@param {boolean} [addId=false]
@return {Object} | [
"Generate",
"the",
"JSON",
"for",
"a",
"record"
] | 811ed4d339c2dc840d5b297b5b244726cf1339ca | https://github.com/huafu/ember-dev-fixtures/blob/811ed4d339c2dc840d5b297b5b244726cf1339ca/private/adapters/dev-fixtures.js#L169-L183 | train | |
huafu/ember-dev-fixtures | private/adapters/dev-fixtures.js | function (store, type/*, record*/) {
var key, counters;
key = dasherize(this._parseModelOrType(store, type).typeKey);
counters = this.get('_generatedCounterId');
if (!counters[key]) {
counters[key] = 1;
}
return 'fixture-' + key + '-' + (counters[key]++);
} | javascript | function (store, type/*, record*/) {
var key, counters;
key = dasherize(this._parseModelOrType(store, type).typeKey);
counters = this.get('_generatedCounterId');
if (!counters[key]) {
counters[key] = 1;
}
return 'fixture-' + key + '-' + (counters[key]++);
} | [
"function",
"(",
"store",
",",
"type",
"/*, record*/",
")",
"{",
"var",
"key",
",",
"counters",
";",
"key",
"=",
"dasherize",
"(",
"this",
".",
"_parseModelOrType",
"(",
"store",
",",
"type",
")",
".",
"typeKey",
")",
";",
"counters",
"=",
"this",
".",... | Generates an ID for a record
@method generateId
@param {DS.Store} store
@param {subclass of DS.Model|string} type
@param {DS.Model} record
@return {String} id | [
"Generates",
"an",
"ID",
"for",
"a",
"record"
] | 811ed4d339c2dc840d5b297b5b244726cf1339ca | https://github.com/huafu/ember-dev-fixtures/blob/811ed4d339c2dc840d5b297b5b244726cf1339ca/private/adapters/dev-fixtures.js#L194-L202 | train | |
huafu/ember-dev-fixtures | private/adapters/dev-fixtures.js | function (store, type, id) {
id = coerceId(id);
return this.fixturesForType(store, type).find(function (record) {
return coerceId(record.id) === id;
});
} | javascript | function (store, type, id) {
id = coerceId(id);
return this.fixturesForType(store, type).find(function (record) {
return coerceId(record.id) === id;
});
} | [
"function",
"(",
"store",
",",
"type",
",",
"id",
")",
"{",
"id",
"=",
"coerceId",
"(",
"id",
")",
";",
"return",
"this",
".",
"fixturesForType",
"(",
"store",
",",
"type",
")",
".",
"find",
"(",
"function",
"(",
"record",
")",
"{",
"return",
"coer... | Get a fixture for a given type and ID
@method fixtureForId
@param {DS.Store} store
@param {DS.Model} type
@param {string|number} id
@return {Object} | [
"Get",
"a",
"fixture",
"for",
"a",
"given",
"type",
"and",
"ID"
] | 811ed4d339c2dc840d5b297b5b244726cf1339ca | https://github.com/huafu/ember-dev-fixtures/blob/811ed4d339c2dc840d5b297b5b244726cf1339ca/private/adapters/dev-fixtures.js#L323-L328 | train | |
huafu/ember-dev-fixtures | private/adapters/dev-fixtures.js | function (response, statusCode, statusText) {
var adapter = this, responseFunction, isOk, shouldCopy, isInvalid;
statusCode = statusCode || 200;
statusText = statusText || HTTP_STATUS_MESSAGES[statusCode];
isOk = Math.round(statusCode / 100) === 2;
if (typeof response === 'function') {
shouldC... | javascript | function (response, statusCode, statusText) {
var adapter = this, responseFunction, isOk, shouldCopy, isInvalid;
statusCode = statusCode || 200;
statusText = statusText || HTTP_STATUS_MESSAGES[statusCode];
isOk = Math.round(statusCode / 100) === 2;
if (typeof response === 'function') {
shouldC... | [
"function",
"(",
"response",
",",
"statusCode",
",",
"statusText",
")",
"{",
"var",
"adapter",
"=",
"this",
",",
"responseFunction",
",",
"isOk",
",",
"shouldCopy",
",",
"isInvalid",
";",
"statusCode",
"=",
"statusCode",
"||",
"200",
";",
"statusText",
"=",
... | Better method for simulating a remote call
@method simulateRemoteCall
@param {Object|Function} response
@param {number} [statusCode=200]
@param {string} [statusText]
@return {Promise} | [
"Better",
"method",
"for",
"simulating",
"a",
"remote",
"call"
] | 811ed4d339c2dc840d5b297b5b244726cf1339ca | https://github.com/huafu/ember-dev-fixtures/blob/811ed4d339c2dc840d5b297b5b244726cf1339ca/private/adapters/dev-fixtures.js#L340-L389 | train | |
huafu/ember-dev-fixtures | private/adapters/dev-fixtures.js | function (store, json) {
var handledRecords = [], key, records, handleRecord, Model;
handleRecord = function (record) {
this.completeJsonForRecord(store, record, Model, json, handledRecords);
};
for (key in json) {
if (json.hasOwnProperty(key)) {
records = json[key];
Model = ... | javascript | function (store, json) {
var handledRecords = [], key, records, handleRecord, Model;
handleRecord = function (record) {
this.completeJsonForRecord(store, record, Model, json, handledRecords);
};
for (key in json) {
if (json.hasOwnProperty(key)) {
records = json[key];
Model = ... | [
"function",
"(",
"store",
",",
"json",
")",
"{",
"var",
"handledRecords",
"=",
"[",
"]",
",",
"key",
",",
"records",
",",
"handleRecord",
",",
"Model",
";",
"handleRecord",
"=",
"function",
"(",
"record",
")",
"{",
"this",
".",
"completeJsonForRecord",
"... | Complete a JSON response to add linked records which are not async
@method completeJsonResponse
@param {DS.Store} store
@param {Object} json
@param {string|DS.Model|Object} [injections...] | [
"Complete",
"a",
"JSON",
"response",
"to",
"add",
"linked",
"records",
"which",
"are",
"not",
"async"
] | 811ed4d339c2dc840d5b297b5b244726cf1339ca | https://github.com/huafu/ember-dev-fixtures/blob/811ed4d339c2dc840d5b297b5b244726cf1339ca/private/adapters/dev-fixtures.js#L400-L413 | train | |
huafu/ember-dev-fixtures | private/adapters/dev-fixtures.js | function (store, record, Model, json, handledRecords) {
if (handledRecords.indexOf(record) === -1) {
handledRecords.push(record);
Model.eachRelationship(function (name, meta) {
var related, fixtures, relatedTypeKey, ids;
if (!meta.async && record[name]) {
fixtures = Ember.A(thi... | javascript | function (store, record, Model, json, handledRecords) {
if (handledRecords.indexOf(record) === -1) {
handledRecords.push(record);
Model.eachRelationship(function (name, meta) {
var related, fixtures, relatedTypeKey, ids;
if (!meta.async && record[name]) {
fixtures = Ember.A(thi... | [
"function",
"(",
"store",
",",
"record",
",",
"Model",
",",
"json",
",",
"handledRecords",
")",
"{",
"if",
"(",
"handledRecords",
".",
"indexOf",
"(",
"record",
")",
"===",
"-",
"1",
")",
"{",
"handledRecords",
".",
"push",
"(",
"record",
")",
";",
"... | Complete a record adding in the given json the related records which are not defined as async
@method completeJsonForRecord
@param {DS.Store} store
@param {DS.Model} record
@param {subclass of DS.Model} Model
@param {Object} json
@param {Array.<DS.Model>} handledRecords | [
"Complete",
"a",
"record",
"adding",
"in",
"the",
"given",
"json",
"the",
"related",
"records",
"which",
"are",
"not",
"defined",
"as",
"async"
] | 811ed4d339c2dc840d5b297b5b244726cf1339ca | https://github.com/huafu/ember-dev-fixtures/blob/811ed4d339c2dc840d5b297b5b244726cf1339ca/private/adapters/dev-fixtures.js#L425-L463 | train | |
huafu/ember-dev-fixtures | private/adapters/dev-fixtures.js | function (store, type, records) {
var json = {};
type = this._parseModelOrType(store, type);
json[pluralize(type.typeKey)] = records;
this._injectFixturesInResponse.apply(this, [store, json].concat(slice.call(arguments, 3)));
return this.completeJsonResponse(store, json);
} | javascript | function (store, type, records) {
var json = {};
type = this._parseModelOrType(store, type);
json[pluralize(type.typeKey)] = records;
this._injectFixturesInResponse.apply(this, [store, json].concat(slice.call(arguments, 3)));
return this.completeJsonResponse(store, json);
} | [
"function",
"(",
"store",
",",
"type",
",",
"records",
")",
"{",
"var",
"json",
"=",
"{",
"}",
";",
"type",
"=",
"this",
".",
"_parseModelOrType",
"(",
"store",
",",
"type",
")",
";",
"json",
"[",
"pluralize",
"(",
"type",
".",
"typeKey",
")",
"]",... | Creates a multi-records response for the given type and records array
@method createMultiRecordsResponse
@param {DS.Store} store
@param {DS.Model} type
@param {Array.<Object>} records
@return {Object} | [
"Creates",
"a",
"multi",
"-",
"records",
"response",
"for",
"the",
"given",
"type",
"and",
"records",
"array"
] | 811ed4d339c2dc840d5b297b5b244726cf1339ca | https://github.com/huafu/ember-dev-fixtures/blob/811ed4d339c2dc840d5b297b5b244726cf1339ca/private/adapters/dev-fixtures.js#L491-L497 | train | |
huafu/ember-dev-fixtures | private/adapters/dev-fixtures.js | function (errors) {
if (typeof errors === 'string' || errors instanceof Error) {
errors = {'*': '' + errors};
}
else if (errors == null) {
errors = {'*': 'Unknown error'};
}
return new DS.InvalidError(errors);
} | javascript | function (errors) {
if (typeof errors === 'string' || errors instanceof Error) {
errors = {'*': '' + errors};
}
else if (errors == null) {
errors = {'*': 'Unknown error'};
}
return new DS.InvalidError(errors);
} | [
"function",
"(",
"errors",
")",
"{",
"if",
"(",
"typeof",
"errors",
"===",
"'string'",
"||",
"errors",
"instanceof",
"Error",
")",
"{",
"errors",
"=",
"{",
"'*'",
":",
"''",
"+",
"errors",
"}",
";",
"}",
"else",
"if",
"(",
"errors",
"==",
"null",
"... | Creates an error response to be used with simulateResponseCall
@method createErrorResponse
@param {Object|Error|string} errors
@return {Object} | [
"Creates",
"an",
"error",
"response",
"to",
"be",
"used",
"with",
"simulateResponseCall"
] | 811ed4d339c2dc840d5b297b5b244726cf1339ca | https://github.com/huafu/ember-dev-fixtures/blob/811ed4d339c2dc840d5b297b5b244726cf1339ca/private/adapters/dev-fixtures.js#L519-L527 | train | |
huafu/ember-dev-fixtures | private/adapters/dev-fixtures.js | function (store, type, fixtureRecord) {
var fixture;
if (fixtureRecord.id) {
type = this._parseModelOrType(store, type);
// lookup for a fixture
fixture = this.fixtureForId(store, type, fixtureRecord.id);
if (fixture) {
Ember.merge(fixture, fixtureRecord);
this._touchDate... | javascript | function (store, type, fixtureRecord) {
var fixture;
if (fixtureRecord.id) {
type = this._parseModelOrType(store, type);
// lookup for a fixture
fixture = this.fixtureForId(store, type, fixtureRecord.id);
if (fixture) {
Ember.merge(fixture, fixtureRecord);
this._touchDate... | [
"function",
"(",
"store",
",",
"type",
",",
"fixtureRecord",
")",
"{",
"var",
"fixture",
";",
"if",
"(",
"fixtureRecord",
".",
"id",
")",
"{",
"type",
"=",
"this",
".",
"_parseModelOrType",
"(",
"store",
",",
"type",
")",
";",
"// lookup for a fixture",
... | Update the fixture for given type and fixture record
@method updateFixtures
@param {DS.Store} store
@param {DS.Model|string} type
@param {Object} fixtureRecord
@return {Object} | [
"Update",
"the",
"fixture",
"for",
"given",
"type",
"and",
"fixture",
"record"
] | 811ed4d339c2dc840d5b297b5b244726cf1339ca | https://github.com/huafu/ember-dev-fixtures/blob/811ed4d339c2dc840d5b297b5b244726cf1339ca/private/adapters/dev-fixtures.js#L538-L557 | train | |
huafu/ember-dev-fixtures | private/adapters/dev-fixtures.js | function (store, type, fixtureRecord) {
var fixture = fixtureRecord || {};
type = this._parseModelOrType(store, type);
if (!fixtureRecord.id) {
fixtureRecord.id = this.generateId(store, type);
}
if (this.fixtureForId(store, type, fixture.id)) {
throw new Error('Fixture `' + type.typeKey ... | javascript | function (store, type, fixtureRecord) {
var fixture = fixtureRecord || {};
type = this._parseModelOrType(store, type);
if (!fixtureRecord.id) {
fixtureRecord.id = this.generateId(store, type);
}
if (this.fixtureForId(store, type, fixture.id)) {
throw new Error('Fixture `' + type.typeKey ... | [
"function",
"(",
"store",
",",
"type",
",",
"fixtureRecord",
")",
"{",
"var",
"fixture",
"=",
"fixtureRecord",
"||",
"{",
"}",
";",
"type",
"=",
"this",
".",
"_parseModelOrType",
"(",
"store",
",",
"type",
")",
";",
"if",
"(",
"!",
"fixtureRecord",
"."... | Creates a new fixture record and update fixtures with it
@method createFixture
@param {DS.Store} store
@param {DS.Model|string} type
@param {Object} [fixtureRecord={}]
@return {Object} | [
"Creates",
"a",
"new",
"fixture",
"record",
"and",
"update",
"fixtures",
"with",
"it"
] | 811ed4d339c2dc840d5b297b5b244726cf1339ca | https://github.com/huafu/ember-dev-fixtures/blob/811ed4d339c2dc840d5b297b5b244726cf1339ca/private/adapters/dev-fixtures.js#L568-L578 | train | |
huafu/ember-dev-fixtures | private/adapters/dev-fixtures.js | function (store, type, fixtureRecord) {
var fixture, fixturesArray;
if (fixtureRecord.id) {
fixture = this.fixtureForId(store, type, fixtureRecord.id);
if (fixture) {
fixturesArray = this.fixturesForType(store, type);
fixturesArray.splice(fixturesArray.indexOf(fixtureRecord), 1);
... | javascript | function (store, type, fixtureRecord) {
var fixture, fixturesArray;
if (fixtureRecord.id) {
fixture = this.fixtureForId(store, type, fixtureRecord.id);
if (fixture) {
fixturesArray = this.fixturesForType(store, type);
fixturesArray.splice(fixturesArray.indexOf(fixtureRecord), 1);
... | [
"function",
"(",
"store",
",",
"type",
",",
"fixtureRecord",
")",
"{",
"var",
"fixture",
",",
"fixturesArray",
";",
"if",
"(",
"fixtureRecord",
".",
"id",
")",
"{",
"fixture",
"=",
"this",
".",
"fixtureForId",
"(",
"store",
",",
"type",
",",
"fixtureReco... | Deletes a fixture for given type and record
@method deleteLoadedFixture
@param {DS.Store} store
@param {DS.Model} type
@param {Object} fixtureRecord
@return {null} | [
"Deletes",
"a",
"fixture",
"for",
"given",
"type",
"and",
"record"
] | 811ed4d339c2dc840d5b297b5b244726cf1339ca | https://github.com/huafu/ember-dev-fixtures/blob/811ed4d339c2dc840d5b297b5b244726cf1339ca/private/adapters/dev-fixtures.js#L590-L603 | train | |
huafu/ember-dev-fixtures | private/adapters/dev-fixtures.js | function (store, json) {
var i, args = slice.call(arguments, 2), len = args.length, records, typeKey;
for (i = 0; i < len; i += 2) {
records = args[i + 1];
records = records ? (isArray(records) ? records.slice() : [records]) : [];
typeKey = pluralize(this._parseModelOrType(store, args[i]).type... | javascript | function (store, json) {
var i, args = slice.call(arguments, 2), len = args.length, records, typeKey;
for (i = 0; i < len; i += 2) {
records = args[i + 1];
records = records ? (isArray(records) ? records.slice() : [records]) : [];
typeKey = pluralize(this._parseModelOrType(store, args[i]).type... | [
"function",
"(",
"store",
",",
"json",
")",
"{",
"var",
"i",
",",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"2",
")",
",",
"len",
"=",
"args",
".",
"length",
",",
"records",
",",
"typeKey",
";",
"for",
"(",
"i",
"=",
"0",
";",
... | Inject fixtures into the given json
@method _injectFixturesInResponse
@param {DS.Store} store
@param {Object} json
@return {Object} | [
"Inject",
"fixtures",
"into",
"the",
"given",
"json"
] | 811ed4d339c2dc840d5b297b5b244726cf1339ca | https://github.com/huafu/ember-dev-fixtures/blob/811ed4d339c2dc840d5b297b5b244726cf1339ca/private/adapters/dev-fixtures.js#L614-L628 | train | |
ugate/pulses | lib/catheter.js | artery | function artery(pw, iv, meds) {
if (!iv.artery) iv.artery = new Artery();
plet.props(iv.artery, sprops, meds || iv, true);
iv.artery.count = iv.count;
iv.artery.data = iv.data;
iv.artery.passes = iv.passes;
iv.artery.pass = iv.pass;
return iv.artery;
} | javascript | function artery(pw, iv, meds) {
if (!iv.artery) iv.artery = new Artery();
plet.props(iv.artery, sprops, meds || iv, true);
iv.artery.count = iv.count;
iv.artery.data = iv.data;
iv.artery.passes = iv.passes;
iv.artery.pass = iv.pass;
return iv.artery;
} | [
"function",
"artery",
"(",
"pw",
",",
"iv",
",",
"meds",
")",
"{",
"if",
"(",
"!",
"iv",
".",
"artery",
")",
"iv",
".",
"artery",
"=",
"new",
"Artery",
"(",
")",
";",
"plet",
".",
"props",
"(",
"iv",
".",
"artery",
",",
"sprops",
",",
"meds",
... | Generates an artery or sets properties an artery when the I.V. artery already exists
@private
@arg {PulseEmitter} pw the pulse emitter
@arg {Array} iv the I.V. catheter
@arg {Array} meds the pulse events
@returns {Artery} the artery | [
"Generates",
"an",
"artery",
"or",
"sets",
"properties",
"an",
"artery",
"when",
"the",
"I",
".",
"V",
".",
"artery",
"already",
"exists"
] | 214b186e1b72bed9c99c0a7903c70de4eca3c259 | https://github.com/ugate/pulses/blob/214b186e1b72bed9c99c0a7903c70de4eca3c259/lib/catheter.js#L153-L161 | train |
ugate/pulses | lib/catheter.js | Pulse | function Pulse(pw, iv, drip) {
var pulse = this;
plet.merge(pulse, drip.pulse);
pulse.count = drip.cbCount + 1;
pulse.event = drip.pulse.event;
} | javascript | function Pulse(pw, iv, drip) {
var pulse = this;
plet.merge(pulse, drip.pulse);
pulse.count = drip.cbCount + 1;
pulse.event = drip.pulse.event;
} | [
"function",
"Pulse",
"(",
"pw",
",",
"iv",
",",
"drip",
")",
"{",
"var",
"pulse",
"=",
"this",
";",
"plet",
".",
"merge",
"(",
"pulse",
",",
"drip",
".",
"pulse",
")",
";",
"pulse",
".",
"count",
"=",
"drip",
".",
"cbCount",
"+",
"1",
";",
"pul... | Pulse event passed to listeners
@private
@class Pulse
@arg {PulseEmitter} pw the pulse emitter
@arg {Array} iv the I.V. catheter
@arg {Object} drip the drip | [
"Pulse",
"event",
"passed",
"to",
"listeners"
] | 214b186e1b72bed9c99c0a7903c70de4eca3c259 | https://github.com/ugate/pulses/blob/214b186e1b72bed9c99c0a7903c70de4eca3c259/lib/catheter.js#L172-L177 | train |
ugate/pulses | lib/catheter.js | assertlet | function assertlet(obj, other, objName, otherName) {
plet.props(obj, sprops, other, false, false, objName || '1st', otherName || '2nd');
} | javascript | function assertlet(obj, other, objName, otherName) {
plet.props(obj, sprops, other, false, false, objName || '1st', otherName || '2nd');
} | [
"function",
"assertlet",
"(",
"obj",
",",
"other",
",",
"objName",
",",
"otherName",
")",
"{",
"plet",
".",
"props",
"(",
"obj",
",",
"sprops",
",",
"other",
",",
"false",
",",
"false",
",",
"objName",
"||",
"'1st'",
",",
"otherName",
"||",
"'2nd'",
... | Asserts that all of the properties shared between arteries and pulses are equivalent between two arteries or pulses
@arg {Object} obj object that contains artery/pulse properties
@arg {Object} other another object that contains artery/pulse properties
@arg {String} [objName=1st] a name to use for the obj object when a... | [
"Asserts",
"that",
"all",
"of",
"the",
"properties",
"shared",
"between",
"arteries",
"and",
"pulses",
"are",
"equivalent",
"between",
"two",
"arteries",
"or",
"pulses"
] | 214b186e1b72bed9c99c0a7903c70de4eca3c259 | https://github.com/ugate/pulses/blob/214b186e1b72bed9c99c0a7903c70de4eca3c259/lib/catheter.js#L187-L189 | train |
ugate/pulses | lib/catheter.js | pulselet | function pulselet(artery, event, endEvent) {
return (new Drip(null, artery, event, endEvent)).pulse;
} | javascript | function pulselet(artery, event, endEvent) {
return (new Drip(null, artery, event, endEvent)).pulse;
} | [
"function",
"pulselet",
"(",
"artery",
",",
"event",
",",
"endEvent",
")",
"{",
"return",
"(",
"new",
"Drip",
"(",
"null",
",",
"artery",
",",
"event",
",",
"endEvent",
")",
")",
".",
"pulse",
";",
"}"
] | Adds or creates an object with pulse-like properties
@arg {Object} artery the artery object that will be used to inherit from for shared pulse property values that have not been set on the event
@arg {(Object | String)} event either an object that contains pulse properties or a string representing the event name
@arg ... | [
"Adds",
"or",
"creates",
"an",
"object",
"with",
"pulse",
"-",
"like",
"properties"
] | 214b186e1b72bed9c99c0a7903c70de4eca3c259 | https://github.com/ugate/pulses/blob/214b186e1b72bed9c99c0a7903c70de4eca3c259/lib/catheter.js#L209-L211 | train |
ugate/pulses | lib/catheter.js | emits | function emits(pw, iv, i) {
for (var ci = i, a; iv[ci] && (ci === i || iv[ci].cbCount < iv[ci].repeat); ci++) iv[ci].emit(pw, iv);
} | javascript | function emits(pw, iv, i) {
for (var ci = i, a; iv[ci] && (ci === i || iv[ci].cbCount < iv[ci].repeat); ci++) iv[ci].emit(pw, iv);
} | [
"function",
"emits",
"(",
"pw",
",",
"iv",
",",
"i",
")",
"{",
"for",
"(",
"var",
"ci",
"=",
"i",
",",
"a",
";",
"iv",
"[",
"ci",
"]",
"&&",
"(",
"ci",
"===",
"i",
"||",
"iv",
"[",
"ci",
"]",
".",
"cbCount",
"<",
"iv",
"[",
"ci",
"]",
"... | When the event at the specified index is not async and has not been called back, the event for the passed index will be emitted
Also, if the pulse event is async, events are consecutively emitted until a sync event is encountered
@private
@arg {PulseEmitter} pw the pulse emitter
@arg {Array} iv the I.V. catheter
@arg ... | [
"When",
"the",
"event",
"at",
"the",
"specified",
"index",
"is",
"not",
"async",
"and",
"has",
"not",
"been",
"called",
"back",
"the",
"event",
"for",
"the",
"passed",
"index",
"will",
"be",
"emitted",
"Also",
"if",
"the",
"pulse",
"event",
"is",
"async"... | 214b186e1b72bed9c99c0a7903c70de4eca3c259 | https://github.com/ugate/pulses/blob/214b186e1b72bed9c99c0a7903c70de4eca3c259/lib/catheter.js#L222-L224 | train |
ugate/pulses | lib/catheter.js | Drip | function Drip(pw, iv, evt, endEvent, emit) {
var ieo = typeof evt === 'object', eo = ieo ? evt : null, pulse = { event: ieo ? evt.event : evt };
if (!pulse.event) throw new Error('Event is required');
if (eo && eo.id) pulse.id = eo.id; // IDs are not inherited because iv/pulse IDs are non-transferable
t... | javascript | function Drip(pw, iv, evt, endEvent, emit) {
var ieo = typeof evt === 'object', eo = ieo ? evt : null, pulse = { event: ieo ? evt.event : evt };
if (!pulse.event) throw new Error('Event is required');
if (eo && eo.id) pulse.id = eo.id; // IDs are not inherited because iv/pulse IDs are non-transferable
t... | [
"function",
"Drip",
"(",
"pw",
",",
"iv",
",",
"evt",
",",
"endEvent",
",",
"emit",
")",
"{",
"var",
"ieo",
"=",
"typeof",
"evt",
"===",
"'object'",
",",
"eo",
"=",
"ieo",
"?",
"evt",
":",
"null",
",",
"pulse",
"=",
"{",
"event",
":",
"ieo",
"?... | Creates a drip for an I.V. catheter
@private
@class Drip
@arg {PulseEmitter} pw the pulse emitter
@arg {Array} iv the I.V. catheter
@arg {(String | Object)} evt the pulse event
@arg {String} endEvent the end event
@arg {Boolean} [emit] true to emit
@returns {Object} the drip / pulse | [
"Creates",
"a",
"drip",
"for",
"an",
"I",
".",
"V",
".",
"catheter"
] | 214b186e1b72bed9c99c0a7903c70de4eca3c259 | https://github.com/ugate/pulses/blob/214b186e1b72bed9c99c0a7903c70de4eca3c259/lib/catheter.js#L238-L245 | train |
ugate/pulses | lib/catheter.js | inlet | function inlet(pw, iv, drip) {
var ib = drip ? drip.pulse.inbound : iv.inbound;
if (!ib) return true;
var tgs = ib.selector && typeof iv.target.querySelectorAll === 'function' ? iv.target.querySelectorAll(ib.selector) : [iv.target];
var ttl = tgs.length;
var fn = function inboundListener() {
... | javascript | function inlet(pw, iv, drip) {
var ib = drip ? drip.pulse.inbound : iv.inbound;
if (!ib) return true;
var tgs = ib.selector && typeof iv.target.querySelectorAll === 'function' ? iv.target.querySelectorAll(ib.selector) : [iv.target];
var ttl = tgs.length;
var fn = function inboundListener() {
... | [
"function",
"inlet",
"(",
"pw",
",",
"iv",
",",
"drip",
")",
"{",
"var",
"ib",
"=",
"drip",
"?",
"drip",
".",
"pulse",
".",
"inbound",
":",
"iv",
".",
"inbound",
";",
"if",
"(",
"!",
"ib",
")",
"return",
"true",
";",
"var",
"tgs",
"=",
"ib",
... | Universal inlet for inbound event deferment
@arg {PulseEmitter} pw the pulse emitter
@arg {Array} iv the I.V. catheter
@arg {Drip} [drip] the drip to check/process the inbound deferment (omit to check/process the I.V. instead) | [
"Universal",
"inlet",
"for",
"inbound",
"event",
"deferment"
] | 214b186e1b72bed9c99c0a7903c70de4eca3c259 | https://github.com/ugate/pulses/blob/214b186e1b72bed9c99c0a7903c70de4eca3c259/lib/catheter.js#L283-L297 | train |
AVVS/node-errors | index.js | commonErrorHandler | function commonErrorHandler(err, req, res, next) { // jshint ignore:line
debug(err);
// if we got here without an error, it's a 404 case
if (!err) {
err = new NotFoundError();
}
// here we've got an error, it could be a different one than
// the one we've constructed, so provide defaults to be safe
... | javascript | function commonErrorHandler(err, req, res, next) { // jshint ignore:line
debug(err);
// if we got here without an error, it's a 404 case
if (!err) {
err = new NotFoundError();
}
// here we've got an error, it could be a different one than
// the one we've constructed, so provide defaults to be safe
... | [
"function",
"commonErrorHandler",
"(",
"err",
",",
"req",
",",
"res",
",",
"next",
")",
"{",
"// jshint ignore:line",
"debug",
"(",
"err",
")",
";",
"// if we got here without an error, it's a 404 case",
"if",
"(",
"!",
"err",
")",
"{",
"err",
"=",
"new",
"Not... | Middleware for sending errors based on passed error
@param {Error} err - error object
@param {Object} req - http request
@param {Object} res - http response
@param {Function} next - next | [
"Middleware",
"for",
"sending",
"errors",
"based",
"on",
"passed",
"error"
] | d3813792ee01abc6f0b590f840daa70fd6622d9e | https://github.com/AVVS/node-errors/blob/d3813792ee01abc6f0b590f840daa70fd6622d9e/index.js#L114-L131 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | function( newRules, featureName, overrideCustom ) {
// Check arguments and constraints. Clear cache.
if ( !beforeAddingRule( this, newRules, overrideCustom ) )
return false;
var i, ret;
if ( typeof newRules == 'string' )
newRules = parseRulesString( newRules );
else if ( newRules instanceof CKE... | javascript | function( newRules, featureName, overrideCustom ) {
// Check arguments and constraints. Clear cache.
if ( !beforeAddingRule( this, newRules, overrideCustom ) )
return false;
var i, ret;
if ( typeof newRules == 'string' )
newRules = parseRulesString( newRules );
else if ( newRules instanceof CKE... | [
"function",
"(",
"newRules",
",",
"featureName",
",",
"overrideCustom",
")",
"{",
"// Check arguments and constraints. Clear cache.",
"if",
"(",
"!",
"beforeAddingRule",
"(",
"this",
",",
"newRules",
",",
"overrideCustom",
")",
")",
"return",
"false",
";",
"var",
... | Adds allowed content rules to the filter.
Read about rules formats in [Allowed Content Rules guide](#!/guide/dev_allowed_content_rules).
// Add a basic rule for custom image feature (e.g. 'MyImage' button).
editor.filter.allow( 'img[!src,alt]', 'MyImage' );
// Add rules for two header styles allowed by 'HeadersCombo... | [
"Adds",
"allowed",
"content",
"rules",
"to",
"the",
"filter",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L231-L255 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | function( newRules ) {
// Check arguments and constraints. Clear cache.
// Note: we pass true in the 3rd argument, because disallow() should never
// be blocked by custom configuration.
if ( !beforeAddingRule( this, newRules, true ) )
return false;
if ( typeof newRules == 'string' )
newRules = p... | javascript | function( newRules ) {
// Check arguments and constraints. Clear cache.
// Note: we pass true in the 3rd argument, because disallow() should never
// be blocked by custom configuration.
if ( !beforeAddingRule( this, newRules, true ) )
return false;
if ( typeof newRules == 'string' )
newRules = p... | [
"function",
"(",
"newRules",
")",
"{",
"// Check arguments and constraints. Clear cache.",
"// Note: we pass true in the 3rd argument, because disallow() should never",
"// be blocked by custom configuration.",
"if",
"(",
"!",
"beforeAddingRule",
"(",
"this",
",",
"newRules",
",",
... | Adds disallowed content rules to the filter.
Read about rules formats in the [Allowed Content Rules guide](#!/guide/dev_allowed_content_rules).
// Disallow all styles on the image elements.
editor.filter.disallow( 'img{*}' );
// Disallow all span and div elements.
editor.filter.disallow( 'span div' );
@since 4.4
@p... | [
"Adds",
"disallowed",
"content",
"rules",
"to",
"the",
"filter",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L434-L447 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | function( feature ) {
if ( this.disabled )
return true;
if ( !feature )
return true;
// Some features may want to register other features.
// E.g. a button may return a command bound to it.
if ( feature.toFeature )
feature = feature.toFeature( this.editor );
// If default configuration ... | javascript | function( feature ) {
if ( this.disabled )
return true;
if ( !feature )
return true;
// Some features may want to register other features.
// E.g. a button may return a command bound to it.
if ( feature.toFeature )
feature = feature.toFeature( this.editor );
// If default configuration ... | [
"function",
"(",
"feature",
")",
"{",
"if",
"(",
"this",
".",
"disabled",
")",
"return",
"true",
";",
"if",
"(",
"!",
"feature",
")",
"return",
"true",
";",
"// Some features may want to register other features.",
"// E.g. a button may return a command bound to it.",
... | Checks whether a feature can be enabled for the HTML restrictions in place
for the current CKEditor instance, based on the HTML code the feature might
generate and the minimal HTML code the feature needs to be able to generate.
// TODO example
@param {CKEDITOR.feature} feature
@returns {Boolean} Whether this feature ... | [
"Checks",
"whether",
"a",
"feature",
"can",
"be",
"enabled",
"for",
"the",
"HTML",
"restrictions",
"in",
"place",
"for",
"the",
"current",
"CKEditor",
"instance",
"based",
"on",
"the",
"HTML",
"code",
"the",
"feature",
"might",
"generate",
"and",
"the",
"min... | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L540-L564 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | function( transformations ) {
if ( this.disabled )
return;
if ( !transformations )
return;
var optimized = this._.transformations,
group, i;
for ( i = 0; i < transformations.length; ++i ) {
group = optimizeTransformationsGroup( transformations[ i ] );
if ( !optimized[ group.name ] )
... | javascript | function( transformations ) {
if ( this.disabled )
return;
if ( !transformations )
return;
var optimized = this._.transformations,
group, i;
for ( i = 0; i < transformations.length; ++i ) {
group = optimizeTransformationsGroup( transformations[ i ] );
if ( !optimized[ group.name ] )
... | [
"function",
"(",
"transformations",
")",
"{",
"if",
"(",
"this",
".",
"disabled",
")",
"return",
";",
"if",
"(",
"!",
"transformations",
")",
"return",
";",
"var",
"optimized",
"=",
"this",
".",
"_",
".",
"transformations",
",",
"group",
",",
"i",
";",... | Adds an array of content transformation groups. One group
may contain many transformation rules, but only the first
matching rule in a group is executed.
A single transformation rule is an object with four properties:
* `check` (optional) – if set and {@link CKEDITOR.filter} does
not accept this {@link CKEDITOR... | [
"Adds",
"an",
"array",
"of",
"content",
"transformation",
"groups",
".",
"One",
"group",
"may",
"contain",
"many",
"transformation",
"rules",
"but",
"only",
"the",
"first",
"matching",
"rule",
"in",
"a",
"group",
"is",
"executed",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L651-L669 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | function( test, applyTransformations, strictCheck ) {
if ( this.disabled )
return true;
// If rules are an array, expand it and return the logical OR value of
// the rules.
if ( CKEDITOR.tools.isArray( test ) ) {
for ( var i = test.length ; i-- ; ) {
if ( this.check( test[ i ], applyTransforma... | javascript | function( test, applyTransformations, strictCheck ) {
if ( this.disabled )
return true;
// If rules are an array, expand it and return the logical OR value of
// the rules.
if ( CKEDITOR.tools.isArray( test ) ) {
for ( var i = test.length ; i-- ; ) {
if ( this.check( test[ i ], applyTransforma... | [
"function",
"(",
"test",
",",
"applyTransformations",
",",
"strictCheck",
")",
"{",
"if",
"(",
"this",
".",
"disabled",
")",
"return",
"true",
";",
"// If rules are an array, expand it and return the logical OR value of",
"// the rules.",
"if",
"(",
"CKEDITOR",
".",
"... | Checks whether the content defined in the `test` argument is allowed
by this filter.
If `strictCheck` is set to `false` (default value), this method checks
if all parts of the `test` (styles, attributes, and classes) are
accepted by the filter. If `strictCheck` is set to `true`, the test
must also contain the required... | [
"Checks",
"whether",
"the",
"content",
"defined",
"in",
"the",
"test",
"argument",
"is",
"allowed",
"by",
"this",
"filter",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L698-L767 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | applyAllowedRule | function applyAllowedRule( rule, element, status, skipRequired ) {
// This rule doesn't match this element - skip it.
if ( rule.match && !rule.match( element ) )
return;
// If element doesn't have all required styles/attrs/classes
// this rule doesn't match it.
if ( !skipRequired && !hasAllRequired( rule,... | javascript | function applyAllowedRule( rule, element, status, skipRequired ) {
// This rule doesn't match this element - skip it.
if ( rule.match && !rule.match( element ) )
return;
// If element doesn't have all required styles/attrs/classes
// this rule doesn't match it.
if ( !skipRequired && !hasAllRequired( rule,... | [
"function",
"applyAllowedRule",
"(",
"rule",
",",
"element",
",",
"status",
",",
"skipRequired",
")",
"{",
"// This rule doesn't match this element - skip it.",
"if",
"(",
"rule",
".",
"match",
"&&",
"!",
"rule",
".",
"match",
"(",
"element",
")",
")",
"return",... | Apply ACR to an element. @param rule @param element @param status Object containing status of element's filtering. @param {Boolean} skipRequired If true don't check if element has all required properties. | [
"Apply",
"ACR",
"to",
"an",
"element",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L863-L886 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | applyDisallowedRule | function applyDisallowedRule( rule, element, status ) {
// This rule doesn't match this element - skip it.
if ( rule.match && !rule.match( element ) )
return;
// No properties - it's an element only rule so it disallows entire element.
// Early return is handled in filterElement.
if ( rule.noProperties )
... | javascript | function applyDisallowedRule( rule, element, status ) {
// This rule doesn't match this element - skip it.
if ( rule.match && !rule.match( element ) )
return;
// No properties - it's an element only rule so it disallows entire element.
// Early return is handled in filterElement.
if ( rule.noProperties )
... | [
"function",
"applyDisallowedRule",
"(",
"rule",
",",
"element",
",",
"status",
")",
"{",
"// This rule doesn't match this element - skip it.",
"if",
"(",
"rule",
".",
"match",
"&&",
"!",
"rule",
".",
"match",
"(",
"element",
")",
")",
"return",
";",
"// No prope... | Apply DACR rule to an element. | [
"Apply",
"DACR",
"rule",
"to",
"an",
"element",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L924-L938 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | convertStyleToRules | function convertStyleToRules( style ) {
var styleDef = style.getDefinition(),
rules = {},
rule,
attrs = styleDef.attributes;
rules[ styleDef.element ] = rule = {
styles: styleDef.styles,
requiredStyles: styleDef.styles && CKEDITOR.tools.objectKeys( styleDef.styles )
};
if ( attrs ) {
attrs =... | javascript | function convertStyleToRules( style ) {
var styleDef = style.getDefinition(),
rules = {},
rule,
attrs = styleDef.attributes;
rules[ styleDef.element ] = rule = {
styles: styleDef.styles,
requiredStyles: styleDef.styles && CKEDITOR.tools.objectKeys( styleDef.styles )
};
if ( attrs ) {
attrs =... | [
"function",
"convertStyleToRules",
"(",
"style",
")",
"{",
"var",
"styleDef",
"=",
"style",
".",
"getDefinition",
"(",
")",
",",
"rules",
"=",
"{",
"}",
",",
"rule",
",",
"attrs",
"=",
"styleDef",
".",
"attributes",
";",
"rules",
"[",
"styleDef",
".",
... | Convert CKEDITOR.style to filter's rule. | [
"Convert",
"CKEDITOR",
".",
"style",
"to",
"filter",
"s",
"rule",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L996-L1017 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | filterElement | function filterElement( that, element, opts ) {
var name = element.name,
privObj = that._,
allowedRules = privObj.allowedRules.elements[ name ],
genericAllowedRules = privObj.allowedRules.generic,
disallowedRules = privObj.disallowedRules.elements[ name ],
genericDisallowedRules = privObj.disallowedRul... | javascript | function filterElement( that, element, opts ) {
var name = element.name,
privObj = that._,
allowedRules = privObj.allowedRules.elements[ name ],
genericAllowedRules = privObj.allowedRules.generic,
disallowedRules = privObj.disallowedRules.elements[ name ],
genericDisallowedRules = privObj.disallowedRul... | [
"function",
"filterElement",
"(",
"that",
",",
"element",
",",
"opts",
")",
"{",
"var",
"name",
"=",
"element",
".",
"name",
",",
"privObj",
"=",
"that",
".",
"_",
",",
"allowedRules",
"=",
"privObj",
".",
"allowedRules",
".",
"elements",
"[",
"name",
... | Does the actual filtering by appling allowed content rules to the element. @param {CKEDITOR.filter} that The context. @param {CKEDITOR.htmlParser.element} element @param {Object} opts The same as in processElement. | [
"Does",
"the",
"actual",
"filtering",
"by",
"appling",
"allowed",
"content",
"rules",
"to",
"the",
"element",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L1109-L1173 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | mockElementFromString | function mockElementFromString( str ) {
var element = parseRulesString( str ).$1,
styles = element.styles,
classes = element.classes;
element.name = element.elements;
element.classes = classes = ( classes ? classes.split( /\s*,\s*/ ) : [] );
element.styles = mockHash( styles );
element.attributes = moc... | javascript | function mockElementFromString( str ) {
var element = parseRulesString( str ).$1,
styles = element.styles,
classes = element.classes;
element.name = element.elements;
element.classes = classes = ( classes ? classes.split( /\s*,\s*/ ) : [] );
element.styles = mockHash( styles );
element.attributes = moc... | [
"function",
"mockElementFromString",
"(",
"str",
")",
"{",
"var",
"element",
"=",
"parseRulesString",
"(",
"str",
")",
".",
"$1",
",",
"styles",
"=",
"element",
".",
"styles",
",",
"classes",
"=",
"element",
".",
"classes",
";",
"element",
".",
"name",
"... | Create pseudo element that will be passed through filter to check if tested string is allowed. | [
"Create",
"pseudo",
"element",
"that",
"will",
"be",
"passed",
"through",
"filter",
"to",
"check",
"if",
"tested",
"string",
"is",
"allowed",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L1225-L1242 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | mockElementFromStyle | function mockElementFromStyle( style ) {
var styleDef = style.getDefinition(),
styles = styleDef.styles,
attrs = styleDef.attributes || {};
if ( styles ) {
styles = copy( styles );
attrs.style = CKEDITOR.tools.writeCssText( styles, true );
} else {
styles = {};
}
var el = {
name: styleDef.... | javascript | function mockElementFromStyle( style ) {
var styleDef = style.getDefinition(),
styles = styleDef.styles,
attrs = styleDef.attributes || {};
if ( styles ) {
styles = copy( styles );
attrs.style = CKEDITOR.tools.writeCssText( styles, true );
} else {
styles = {};
}
var el = {
name: styleDef.... | [
"function",
"mockElementFromStyle",
"(",
"style",
")",
"{",
"var",
"styleDef",
"=",
"style",
".",
"getDefinition",
"(",
")",
",",
"styles",
"=",
"styleDef",
".",
"styles",
",",
"attrs",
"=",
"styleDef",
".",
"attributes",
"||",
"{",
"}",
";",
"if",
"(",
... | Create pseudo element that will be passed through filter to check if tested style is allowed. | [
"Create",
"pseudo",
"element",
"that",
"will",
"be",
"passed",
"through",
"filter",
"to",
"check",
"if",
"tested",
"style",
"is",
"allowed",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L1246-L1267 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | optimizeRule | function optimizeRule( rule ) {
var validatorName,
requiredProperties,
i;
for ( validatorName in validators )
rule[ validatorName ] = validatorFunction( rule[ validatorName ] );
var nothingRequired = true;
for ( i in validatorsRequired ) {
validatorName = validatorsRequired[ i ];
requiredProper... | javascript | function optimizeRule( rule ) {
var validatorName,
requiredProperties,
i;
for ( validatorName in validators )
rule[ validatorName ] = validatorFunction( rule[ validatorName ] );
var nothingRequired = true;
for ( i in validatorsRequired ) {
validatorName = validatorsRequired[ i ];
requiredProper... | [
"function",
"optimizeRule",
"(",
"rule",
")",
"{",
"var",
"validatorName",
",",
"requiredProperties",
",",
"i",
";",
"for",
"(",
"validatorName",
"in",
"validators",
")",
"rule",
"[",
"validatorName",
"]",
"=",
"validatorFunction",
"(",
"rule",
"[",
"validator... | Optimize a rule by replacing validators with functions and rewriting requiredXXX validators to arrays. | [
"Optimize",
"a",
"rule",
"by",
"replacing",
"validators",
"with",
"functions",
"and",
"rewriting",
"requiredXXX",
"validators",
"to",
"arrays",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L1312-L1334 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | optimizeRules | function optimizeRules( optimizedRules, rules ) {
var elementsRules = optimizedRules.elements,
genericRules = optimizedRules.generic,
i, l, rule, element, priority;
for ( i = 0, l = rules.length; i < l; ++i ) {
// Shallow copy. Do not modify original rule.
rule = copy( rules[ i ] );
priority = rule.... | javascript | function optimizeRules( optimizedRules, rules ) {
var elementsRules = optimizedRules.elements,
genericRules = optimizedRules.generic,
i, l, rule, element, priority;
for ( i = 0, l = rules.length; i < l; ++i ) {
// Shallow copy. Do not modify original rule.
rule = copy( rules[ i ] );
priority = rule.... | [
"function",
"optimizeRules",
"(",
"optimizedRules",
",",
"rules",
")",
"{",
"var",
"elementsRules",
"=",
"optimizedRules",
".",
"elements",
",",
"genericRules",
"=",
"optimizedRules",
".",
"generic",
",",
"i",
",",
"l",
",",
"rule",
",",
"element",
",",
"pri... | Add optimized version of rule to optimizedRules object. | [
"Add",
"optimized",
"version",
"of",
"rule",
"to",
"optimizedRules",
"object",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L1337-L1370 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | processProtectedElement | function processProtectedElement( that, comment, protectedRegexs, filterOpts ) {
var source = decodeURIComponent( comment.value.replace( /^\{cke_protected\}/, '' ) ),
protectedFrag,
toBeRemoved = [],
node, i, match;
// Protected element's and protected source's comments look exactly the same.
// Check i... | javascript | function processProtectedElement( that, comment, protectedRegexs, filterOpts ) {
var source = decodeURIComponent( comment.value.replace( /^\{cke_protected\}/, '' ) ),
protectedFrag,
toBeRemoved = [],
node, i, match;
// Protected element's and protected source's comments look exactly the same.
// Check i... | [
"function",
"processProtectedElement",
"(",
"that",
",",
"comment",
",",
"protectedRegexs",
",",
"filterOpts",
")",
"{",
"var",
"source",
"=",
"decodeURIComponent",
"(",
"comment",
".",
"value",
".",
"replace",
"(",
"/",
"^\\{cke_protected\\}",
"/",
",",
"''",
... | Filter element protected with a comment. Returns true if protected content is ok, false otherwise. | [
"Filter",
"element",
"protected",
"with",
"a",
"comment",
".",
"Returns",
"true",
"if",
"protected",
"content",
"is",
"ok",
"false",
"otherwise",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L1435-L1461 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.