id int32 0 58k | repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1 value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 |
|---|---|---|---|---|---|---|---|---|---|---|---|
32,100 | brophdawg11/vue-themed-style-loader | index.js | genStyleSection | function genStyleSection(style, styles, options) {
if (shouldReplaceCurrentSection(style, styles, options)) {
replaceWithSpacer(style);
}
// Remove the 'id', theme' and 'replace' attributes from the output set of
// attributes since they're not really valid SFC <style> attributes
_.set(style, 'attrs', _.omit(style.attrs, 'id', 'theme', 'replace'));
return genSection('style', style);
} | javascript | function genStyleSection(style, styles, options) {
if (shouldReplaceCurrentSection(style, styles, options)) {
replaceWithSpacer(style);
}
// Remove the 'id', theme' and 'replace' attributes from the output set of
// attributes since they're not really valid SFC <style> attributes
_.set(style, 'attrs', _.omit(style.attrs, 'id', 'theme', 'replace'));
return genSection('style', style);
} | [
"function",
"genStyleSection",
"(",
"style",
",",
"styles",
",",
"options",
")",
"{",
"if",
"(",
"shouldReplaceCurrentSection",
"(",
"style",
",",
"styles",
",",
"options",
")",
")",
"{",
"replaceWithSpacer",
"(",
"style",
")",
";",
"}",
"// Remove the 'id', t... | Given a style section from vue-template-compiler, generate the resulting output style section, stripping inactive theme style blocks | [
"Given",
"a",
"style",
"section",
"from",
"vue",
"-",
"template",
"-",
"compiler",
"generate",
"the",
"resulting",
"output",
"style",
"section",
"stripping",
"inactive",
"theme",
"style",
"blocks"
] | 40a3ae1282c9569db015b5fbe467d02f101a37bc | https://github.com/brophdawg11/vue-themed-style-loader/blob/40a3ae1282c9569db015b5fbe467d02f101a37bc/index.js#L102-L112 |
32,101 | crystal-ball/svg-symbol-sprite-loader | src/icon-sprite-loader.js | iconSpriteLoader | function iconSpriteLoader({ customSpriteId, fetchOptions, useCache } = {}) {
const spriteId = customSpriteId || ICON_SPRITE_ID
if (
useCache &&
localStorage &&
localStorage.getItem &&
localStorage.getItem('ICON_SPRITE_ID') === spriteId
) {
// Current version is in localStorage, get it and inject it
document.body.insertAdjacentHTML(
'afterbegin',
localStorage.getItem('SVG_SPRITE_DATA')
)
} else {
fetch(spriteId, fetchOptions)
.then(res => {
if (!res.ok) throw new Error(res.statusText)
return res
})
.then(res => res.text())
.then(svgSprite => {
document.body.insertAdjacentHTML('afterbegin', svgSprite)
// Add version and data to localstorage for subsequent fetches 🎉
if (localStorage && localStorage.setItem) {
localStorage.setItem('ICON_SPRITE_ID', spriteId)
localStorage.setItem('SVG_SPRITE_DATA', svgSprite)
}
})
// eslint-disable-next-line
.catch(err => console.warn(`SVG sprite fetch failure: ${err.message}`))
}
} | javascript | function iconSpriteLoader({ customSpriteId, fetchOptions, useCache } = {}) {
const spriteId = customSpriteId || ICON_SPRITE_ID
if (
useCache &&
localStorage &&
localStorage.getItem &&
localStorage.getItem('ICON_SPRITE_ID') === spriteId
) {
// Current version is in localStorage, get it and inject it
document.body.insertAdjacentHTML(
'afterbegin',
localStorage.getItem('SVG_SPRITE_DATA')
)
} else {
fetch(spriteId, fetchOptions)
.then(res => {
if (!res.ok) throw new Error(res.statusText)
return res
})
.then(res => res.text())
.then(svgSprite => {
document.body.insertAdjacentHTML('afterbegin', svgSprite)
// Add version and data to localstorage for subsequent fetches 🎉
if (localStorage && localStorage.setItem) {
localStorage.setItem('ICON_SPRITE_ID', spriteId)
localStorage.setItem('SVG_SPRITE_DATA', svgSprite)
}
})
// eslint-disable-next-line
.catch(err => console.warn(`SVG sprite fetch failure: ${err.message}`))
}
} | [
"function",
"iconSpriteLoader",
"(",
"{",
"customSpriteId",
",",
"fetchOptions",
",",
"useCache",
"}",
"=",
"{",
"}",
")",
"{",
"const",
"spriteId",
"=",
"customSpriteId",
"||",
"ICON_SPRITE_ID",
"if",
"(",
"useCache",
"&&",
"localStorage",
"&&",
"localStorage",... | Function uses a sprite path as a unique identifier for fetching and caching an
SVG sprite in local storage.
ℹ️ The ICON_SPRITE_ID will be set on window by a script tag in head injected in
the build if the HTML webpack plugin is being used. If the HTML plugin is not
being used the sprite id matching the resource path MUST be passed to the
function.
⚠️ Note that this process assumes fetch is available, so be sure to polyfill it
with whatwg-fetch if you support older browsers! | [
"Function",
"uses",
"a",
"sprite",
"path",
"as",
"a",
"unique",
"identifier",
"for",
"fetching",
"and",
"caching",
"an",
"SVG",
"sprite",
"in",
"local",
"storage",
"."
] | 530f9ca6f54910448d6dea6c7a5002279de014f9 | https://github.com/crystal-ball/svg-symbol-sprite-loader/blob/530f9ca6f54910448d6dea6c7a5002279de014f9/src/icon-sprite-loader.js#L16-L48 |
32,102 | attekett/Surku | mutators.js | delimiterMutator | function delimiterMutator(input){
var delimiter=this.ra([' ','\n','<','>','\"','\'',',','.',';','|'])
// console.log('Delimiter: '+delimiter)
var chunks=input.split(delimiter)
var chunk=this.ra(chunks)
if(chunk.length>5 && chunk.length<300)
this.storage.storeKeyValuePair([delimiter,chunk],'delimiterMutator')
var oldChunk=this.storage.getValueForKey(delimiter,'delimiterMutator')
if(chunks.length<3 || chunks.length<input.length/300){
// console.log('Fail:'+ (chunks.length)+'<'+(input.length/300) )
return false
}
switch(this.rint(3)) {
case 0:
// console.log('Repeat')
return chunkRepeat.call(this,chunks,delimiter,oldChunk)
case 1:
// console.log('Swap')
return chunkSwap.call(this,chunks,delimiter,oldChunk)
case 2:
// console.log('Move')
return chunkMove.call(this,chunks,delimiter)
default:
console.log('WTF?')
}
} | javascript | function delimiterMutator(input){
var delimiter=this.ra([' ','\n','<','>','\"','\'',',','.',';','|'])
// console.log('Delimiter: '+delimiter)
var chunks=input.split(delimiter)
var chunk=this.ra(chunks)
if(chunk.length>5 && chunk.length<300)
this.storage.storeKeyValuePair([delimiter,chunk],'delimiterMutator')
var oldChunk=this.storage.getValueForKey(delimiter,'delimiterMutator')
if(chunks.length<3 || chunks.length<input.length/300){
// console.log('Fail:'+ (chunks.length)+'<'+(input.length/300) )
return false
}
switch(this.rint(3)) {
case 0:
// console.log('Repeat')
return chunkRepeat.call(this,chunks,delimiter,oldChunk)
case 1:
// console.log('Swap')
return chunkSwap.call(this,chunks,delimiter,oldChunk)
case 2:
// console.log('Move')
return chunkMove.call(this,chunks,delimiter)
default:
console.log('WTF?')
}
} | [
"function",
"delimiterMutator",
"(",
"input",
")",
"{",
"var",
"delimiter",
"=",
"this",
".",
"ra",
"(",
"[",
"' '",
",",
"'\\n'",
",",
"'<'",
",",
"'>'",
",",
"'\\\"'",
",",
"'\\''",
",",
"','",
",",
"'.'",
",",
"';'",
",",
"'|'",
"]",
")",
"//\... | String mutators Leaving in console.logs for now. Will remove them once this new mutator is tested properly. | [
"String",
"mutators",
"Leaving",
"in",
"console",
".",
"logs",
"for",
"now",
".",
"Will",
"remove",
"them",
"once",
"this",
"new",
"mutator",
"is",
"tested",
"properly",
"."
] | 7cb2c85bed8f0347674ba5d800c68d1b34139590 | https://github.com/attekett/Surku/blob/7cb2c85bed8f0347674ba5d800c68d1b34139590/mutators.js#L93-L119 |
32,103 | Xcraft-Inc/shellcraft.js | lib/option.js | Option | function Option(handler, options, desc) {
Option.super_.apply(this, [handler, options, desc]);
if (options.params && options.params.hasOwnProperty('optional')) {
throw new Error('optional parameter is not allowed for options');
}
} | javascript | function Option(handler, options, desc) {
Option.super_.apply(this, [handler, options, desc]);
if (options.params && options.params.hasOwnProperty('optional')) {
throw new Error('optional parameter is not allowed for options');
}
} | [
"function",
"Option",
"(",
"handler",
",",
"options",
",",
"desc",
")",
"{",
"Option",
".",
"super_",
".",
"apply",
"(",
"this",
",",
"[",
"handler",
",",
"options",
",",
"desc",
"]",
")",
";",
"if",
"(",
"options",
".",
"params",
"&&",
"options",
... | Option constructor. | [
"Option",
"constructor",
"."
] | ff23cf75212e871a18ec2f1791a6939af489e0fb | https://github.com/Xcraft-Inc/shellcraft.js/blob/ff23cf75212e871a18ec2f1791a6939af489e0fb/lib/option.js#L32-L38 |
32,104 | CyberAgent/beezlib | lib/image/index.js | function (path, options, callback) {
var self = this;
if (typeof options === 'function') {
callback = options;
options = undefined;
}
_.defaults(options || (options = {}), OPTIM_DEFAULT_OPTIONS);
var bucks = new Bucks();
bucks.empty();
if (REG_OPTIPNG_FILE.test(path) && options.optipng.use) { // optipng
bucks.add(function(err, res, next) {
self.optipng(path, options.optipng.options, function(err) {
if (err) {
logger.error('optipng error.', err);
next(err);
return;
}
logger.info('execute optipng:', path);
next();
});
});
}
if (REG_OPTIPNG_FILE.test(path) && options.pngquant.use) { // pngquant
bucks.add(function(err, res, next) {
self.pngquant(path, options.pngquant.options, function(err) { // pngquant
if (err) {
logger.error('pngquant error.', err);
next(err);
return;
}
logger.info('execute pngquant:', path);
next();
});
});
}
if (REG_JPEGOPTIM_FILE.test(path) && options.jpegoptim.use) { // jpegoptim
bucks.add(function(err, res, next) {
self.jpegoptim(path, options.jpegoptim.options, function(err) {
if (err) {
logger.error('jpegoptim error.', err);
next(err);
return;
}
logger.info('executejpegoptim:', path);
next();
});
});
}
if (bucks._tasks.length === 0) {
logger.info('no match extension. path: ' + path);
}
bucks.end(function(err, ress) {
callback && callback(err, path);
});
} | javascript | function (path, options, callback) {
var self = this;
if (typeof options === 'function') {
callback = options;
options = undefined;
}
_.defaults(options || (options = {}), OPTIM_DEFAULT_OPTIONS);
var bucks = new Bucks();
bucks.empty();
if (REG_OPTIPNG_FILE.test(path) && options.optipng.use) { // optipng
bucks.add(function(err, res, next) {
self.optipng(path, options.optipng.options, function(err) {
if (err) {
logger.error('optipng error.', err);
next(err);
return;
}
logger.info('execute optipng:', path);
next();
});
});
}
if (REG_OPTIPNG_FILE.test(path) && options.pngquant.use) { // pngquant
bucks.add(function(err, res, next) {
self.pngquant(path, options.pngquant.options, function(err) { // pngquant
if (err) {
logger.error('pngquant error.', err);
next(err);
return;
}
logger.info('execute pngquant:', path);
next();
});
});
}
if (REG_JPEGOPTIM_FILE.test(path) && options.jpegoptim.use) { // jpegoptim
bucks.add(function(err, res, next) {
self.jpegoptim(path, options.jpegoptim.options, function(err) {
if (err) {
logger.error('jpegoptim error.', err);
next(err);
return;
}
logger.info('executejpegoptim:', path);
next();
});
});
}
if (bucks._tasks.length === 0) {
logger.info('no match extension. path: ' + path);
}
bucks.end(function(err, ress) {
callback && callback(err, path);
});
} | [
"function",
"(",
"path",
",",
"options",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"undefined",
";",
"}",
"_",
".",
"def... | run the optipng and jpegoptim
@name optim
@memberof image
@method
@param {String} path JPEG|PNG file path.
@param {String} options options.
@param {function} callback
@example
var filepath = './test/image/logo.jpg';
var options = {
optipng: { use: true, options: "-o 2"},
jpegoptim: { use: true, options: "--strip-all"}
pngquant: { use: true, options: "--ext .png -f -v"}
} | [
"run",
"the",
"optipng",
"and",
"jpegoptim"
] | 1fda067ccc2d07e06ebc7ea7e500e94f21e0080f | https://github.com/CyberAgent/beezlib/blob/1fda067ccc2d07e06ebc7ea7e500e94f21e0080f/lib/image/index.js#L224-L293 | |
32,105 | CyberAgent/beezlib | lib/image/index.js | function (dirpath, options, callback) {
var self = this;
if (typeof options === 'function') {
callback = options;
options = undefined;
}
if (!fsys.isDirectorySync(dirpath)) {
logger.error('not a directory. path:', dirpath);
callback && callback(new Error('not a directory. path: ' + dirpath));
return;
}
var bucks = new Bucks();
bucks.empty();
var tasks = [];
fsys.walk(dirpath, function filefn(prefix, dir, file, stats) {
var src = path.join(dir, file);
tasks.push(function (err, res, next) {
self.optim(src, options, next);
});
});
var range = options.limit || 10;
var gtasks = [];
for(var i = 0; i < Math.ceil(tasks.length / range); i++) {
var j = i * range;
var p = tasks.slice(j, j + range);
gtasks.push(p);
}
logger.warn('tasks:', tasks.length); // all task num
for (var k = 0; k < gtasks.length; k++) {
bucks.parallel(gtasks[k]);
}
bucks.end(function(err, ress) {
callback && callback(err, ress);
});
} | javascript | function (dirpath, options, callback) {
var self = this;
if (typeof options === 'function') {
callback = options;
options = undefined;
}
if (!fsys.isDirectorySync(dirpath)) {
logger.error('not a directory. path:', dirpath);
callback && callback(new Error('not a directory. path: ' + dirpath));
return;
}
var bucks = new Bucks();
bucks.empty();
var tasks = [];
fsys.walk(dirpath, function filefn(prefix, dir, file, stats) {
var src = path.join(dir, file);
tasks.push(function (err, res, next) {
self.optim(src, options, next);
});
});
var range = options.limit || 10;
var gtasks = [];
for(var i = 0; i < Math.ceil(tasks.length / range); i++) {
var j = i * range;
var p = tasks.slice(j, j + range);
gtasks.push(p);
}
logger.warn('tasks:', tasks.length); // all task num
for (var k = 0; k < gtasks.length; k++) {
bucks.parallel(gtasks[k]);
}
bucks.end(function(err, ress) {
callback && callback(err, ress);
});
} | [
"function",
"(",
"dirpath",
",",
"options",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"undefined",
";",
"}",
"if",
"(",
... | run the recursive directory of optipng and jpegoptim
@name optimdir
@memberof image
@method
@param {String} dirpath directory root path
@param {String} options options.
@param {function} callback
@example
var filepath = './test/image/logo.jpg';
var options = {
optipng: { use: true, options: "-o 2"},
jpegoptim: { use: true, options: "--strip-all"}
pngquant: { use: true, options: "--ext .png -f -v"},
limit: 10
} | [
"run",
"the",
"recursive",
"directory",
"of",
"optipng",
"and",
"jpegoptim"
] | 1fda067ccc2d07e06ebc7ea7e500e94f21e0080f | https://github.com/CyberAgent/beezlib/blob/1fda067ccc2d07e06ebc7ea7e500e94f21e0080f/lib/image/index.js#L313-L359 | |
32,106 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/extras/editors.default.js | function(base) {
var node = $(base).children('img:first');
if (node.attr('src').substr(0, 5) !== 'data:') {
node.attr('src', imgBase64(node, this.file.mime));
}
} | javascript | function(base) {
var node = $(base).children('img:first');
if (node.attr('src').substr(0, 5) !== 'data:') {
node.attr('src', imgBase64(node, this.file.mime));
}
} | [
"function",
"(",
"base",
")",
"{",
"var",
"node",
"=",
"$",
"(",
"base",
")",
".",
"children",
"(",
"'img:first'",
")",
";",
"if",
"(",
"node",
".",
"attr",
"(",
"'src'",
")",
".",
"substr",
"(",
"0",
",",
"5",
")",
"!==",
"'data:'",
")",
"{",
... | Convert content url to data uri scheme to save content | [
"Convert",
"content",
"url",
"to",
"data",
"uri",
"scheme",
"to",
"save",
"content"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/extras/editors.default.js#L475-L480 | |
32,107 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/extras/editors.default.js | function(base) {
var dfd = $.Deferred(),
ab = 'about:blank';
base.src = ab;
setTimeout(function() {
var src;
try {
src = base.contentWindow.location.href;
} catch(e) {
src = null;
}
if (src === ab) {
dfd.resolve();
} else {
dfd.reject();
}
}, 100);
return dfd;
} | javascript | function(base) {
var dfd = $.Deferred(),
ab = 'about:blank';
base.src = ab;
setTimeout(function() {
var src;
try {
src = base.contentWindow.location.href;
} catch(e) {
src = null;
}
if (src === ab) {
dfd.resolve();
} else {
dfd.reject();
}
}, 100);
return dfd;
} | [
"function",
"(",
"base",
")",
"{",
"var",
"dfd",
"=",
"$",
".",
"Deferred",
"(",
")",
",",
"ab",
"=",
"'about:blank'",
";",
"base",
".",
"src",
"=",
"ab",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"var",
"src",
";",
"try",
"{",
"src",
... | Before dialog close | [
"Before",
"dialog",
"close"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/extras/editors.default.js#L2066-L2084 | |
32,108 | hammy2899/o | src/deepEqual.js | deepEqual | function deepEqual(object, ...compareWith) {
// check if object is an object
if (is(object)) {
// deflate the original object (easier then looping through the inner objects)
const ogObject = deflate(object);
// use reduce to compare all the objects with the original object
return compareWith.reduce((isEqual, currentObject) => {
// if isEqual already is false just skip
if (!isEqual) return false;
// deflate the current object (easier then looping through the inner objects)
return equal(ogObject, deflate(currentObject));
}, true);
}
// if the object isn't an object return false
return false;
} | javascript | function deepEqual(object, ...compareWith) {
// check if object is an object
if (is(object)) {
// deflate the original object (easier then looping through the inner objects)
const ogObject = deflate(object);
// use reduce to compare all the objects with the original object
return compareWith.reduce((isEqual, currentObject) => {
// if isEqual already is false just skip
if (!isEqual) return false;
// deflate the current object (easier then looping through the inner objects)
return equal(ogObject, deflate(currentObject));
}, true);
}
// if the object isn't an object return false
return false;
} | [
"function",
"deepEqual",
"(",
"object",
",",
"...",
"compareWith",
")",
"{",
"// check if object is an object",
"if",
"(",
"is",
"(",
"object",
")",
")",
"{",
"// deflate the original object (easier then looping through the inner objects)",
"const",
"ogObject",
"=",
"defl... | Check whether all the objects deeply equal each other
@example
const a = { a: { b: 1 } };
const b = { a: { b: 1 } };
deepEqual(a, b); // => true
const a = { a: { b: 1 } };
const b = { a: { b: 2 } };
deepEqual(a, b); // => false
@since 1.1.2
@version 1.1.2
@param {object} object The object to compare with
@param {...object} compareWith The objects to compare with the original
@returns {boolean} Whether all the objects deeply equal each other | [
"Check",
"whether",
"all",
"the",
"objects",
"deeply",
"equal",
"each",
"other"
] | 666c9faa36586c0bcdecc0f2a7e1f069a7a3ce54 | https://github.com/hammy2899/o/blob/666c9faa36586c0bcdecc0f2a7e1f069a7a3ce54/src/deepEqual.js#L26-L44 |
32,109 | AlienCreations/alien-node-api-utils | lib/methods/_makeJsonResponseBody.js | _makeJsonResponseBody | function _makeJsonResponseBody (statusCode, flash) {
const hasSession = !!R.path(['session', 'flash'], this);
return {
statusCode : statusCode,
flash : {
notice : hasSession ? flash.apply(this, ['notice']) : [],
error : hasSession ? flash.apply(this, ['error']) : []
}
};
} | javascript | function _makeJsonResponseBody (statusCode, flash) {
const hasSession = !!R.path(['session', 'flash'], this);
return {
statusCode : statusCode,
flash : {
notice : hasSession ? flash.apply(this, ['notice']) : [],
error : hasSession ? flash.apply(this, ['error']) : []
}
};
} | [
"function",
"_makeJsonResponseBody",
"(",
"statusCode",
",",
"flash",
")",
"{",
"const",
"hasSession",
"=",
"!",
"!",
"R",
".",
"path",
"(",
"[",
"'session'",
",",
"'flash'",
"]",
",",
"this",
")",
";",
"return",
"{",
"statusCode",
":",
"statusCode",
","... | Make a common JSON response body for either success or error.
The `data` property will be merged into this object by the respective
jsonResponseSuccess or jsonResponseError method.
@param {Number} statusCode
@param {Function} flash
@returns {{statusCode: Number, flash: {notice: *, error: *}}}
@see jsonResponseSuccess
@see jsonResponseError
@private | [
"Make",
"a",
"common",
"JSON",
"response",
"body",
"for",
"either",
"success",
"or",
"error",
".",
"The",
"data",
"property",
"will",
"be",
"merged",
"into",
"this",
"object",
"by",
"the",
"respective",
"jsonResponseSuccess",
"or",
"jsonResponseError",
"method",... | 83538337710c44a22625ffaeb34a6a45ded6da68 | https://github.com/AlienCreations/alien-node-api-utils/blob/83538337710c44a22625ffaeb34a6a45ded6da68/lib/methods/_makeJsonResponseBody.js#L16-L26 |
32,110 | CyberAgent/beezlib | lib/fsys/index.js | function (basedir, filefn, dirfn) {
filefn = filefn || function() {};
dirfn = dirfn || function() {};
var readdirSync = function(dir) {
var files = fs.readdirSync(dir);
for (var i = 0; i < files.length; i++) {
var file = dir+'/'+files[i];
//debug('before fs.statsSync:', file);
var stats = fs.statSync(file);
if (stats.isFile()) {
var prefix = dir.replace(basedir, '');
filefn(prefix, dir, files[i], stats);
} else if (stats.isDirectory()) {
var prefix = file.replace(basedir, '');
dirfn(prefix, stats);
readdirSync(file);
} else {
console.error('error:'.error, 'It is a file type that is not assumed. file:', file);
return;
}
}
};
readdirSync(basedir);
} | javascript | function (basedir, filefn, dirfn) {
filefn = filefn || function() {};
dirfn = dirfn || function() {};
var readdirSync = function(dir) {
var files = fs.readdirSync(dir);
for (var i = 0; i < files.length; i++) {
var file = dir+'/'+files[i];
//debug('before fs.statsSync:', file);
var stats = fs.statSync(file);
if (stats.isFile()) {
var prefix = dir.replace(basedir, '');
filefn(prefix, dir, files[i], stats);
} else if (stats.isDirectory()) {
var prefix = file.replace(basedir, '');
dirfn(prefix, stats);
readdirSync(file);
} else {
console.error('error:'.error, 'It is a file type that is not assumed. file:', file);
return;
}
}
};
readdirSync(basedir);
} | [
"function",
"(",
"basedir",
",",
"filefn",
",",
"dirfn",
")",
"{",
"filefn",
"=",
"filefn",
"||",
"function",
"(",
")",
"{",
"}",
";",
"dirfn",
"=",
"dirfn",
"||",
"function",
"(",
")",
"{",
"}",
";",
"var",
"readdirSync",
"=",
"function",
"(",
"di... | file system walk function
@name walk
@memberof fsys
@method
@param {String} basedir base path
@param {function} filefn Function to be executed when the file is found
@param {function} dirfnFunction to be executed when the directory is found | [
"file",
"system",
"walk",
"function"
] | 1fda067ccc2d07e06ebc7ea7e500e94f21e0080f | https://github.com/CyberAgent/beezlib/blob/1fda067ccc2d07e06ebc7ea7e500e94f21e0080f/lib/fsys/index.js#L171-L199 | |
32,111 | ViliamKopecky/Ristretto | client/ristretto.js | function(link, first_time) {
var char = (link.href.indexOf('?')>-1) ? '&' : '?';
link.href += (first_time === true) ? (char+(new Date()).getTime()) : char;
} | javascript | function(link, first_time) {
var char = (link.href.indexOf('?')>-1) ? '&' : '?';
link.href += (first_time === true) ? (char+(new Date()).getTime()) : char;
} | [
"function",
"(",
"link",
",",
"first_time",
")",
"{",
"var",
"char",
"=",
"(",
"link",
".",
"href",
".",
"indexOf",
"(",
"'?'",
")",
">",
"-",
"1",
")",
"?",
"'&'",
":",
"'?'",
";",
"link",
".",
"href",
"+=",
"(",
"first_time",
"===",
"true",
"... | clone link tag, and destroys origin when clone is loaded. | [
"clone",
"link",
"tag",
"and",
"destroys",
"origin",
"when",
"clone",
"is",
"loaded",
"."
] | 2a4255e7068032303c0edb458d6f9a19de5d42ee | https://github.com/ViliamKopecky/Ristretto/blob/2a4255e7068032303c0edb458d6f9a19de5d42ee/client/ristretto.js#L6-L9 | |
32,112 | ViliamKopecky/Ristretto | client/ristretto.js | function(first_time) {
var links = document.getElementsByTagName("link");
var link;
var replacing = [];
for(var i = 0; i < links.length; i++) {
link = links[i];
char = '?';
if(link.rel === "stylesheet") {
replacing.push(link);
}
}
var fn = is_touch_device() ? simple_swap_links : swap_links;
for(i=0; i < replacing.length; i++) {
fn(replacing[i], first_time);
}
} | javascript | function(first_time) {
var links = document.getElementsByTagName("link");
var link;
var replacing = [];
for(var i = 0; i < links.length; i++) {
link = links[i];
char = '?';
if(link.rel === "stylesheet") {
replacing.push(link);
}
}
var fn = is_touch_device() ? simple_swap_links : swap_links;
for(i=0; i < replacing.length; i++) {
fn(replacing[i], first_time);
}
} | [
"function",
"(",
"first_time",
")",
"{",
"var",
"links",
"=",
"document",
".",
"getElementsByTagName",
"(",
"\"link\"",
")",
";",
"var",
"link",
";",
"var",
"replacing",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"links",
... | finds all link elements, and reloads them. | [
"finds",
"all",
"link",
"elements",
"and",
"reloads",
"them",
"."
] | 2a4255e7068032303c0edb458d6f9a19de5d42ee | https://github.com/ViliamKopecky/Ristretto/blob/2a4255e7068032303c0edb458d6f9a19de5d42ee/client/ristretto.js#L27-L42 | |
32,113 | hammy2899/o | src/sort.js | sort | function sort(object, iterator, follow = false) {
// check if the object is an object and isn't empty
if (is(object) && !empty(object) && typeof iterator === 'function') {
// create empty object for result
let result = {};
// for each over the object keys and values
// follow is passed into each therefore the
// each function works out whether to follow
// the objects
each(object, (key, value) => {
// run the iterator function on the key and
// value and if it evaluates to true set
// the result object
if (iterator(key, value) === true) {
// set the key/value on the result object
result = set(result, key, value);
}
}, follow);
// return the result
return result;
}
// if the object isn't an object or is empty return
// an empty object this will keep the return immutable
return {};
} | javascript | function sort(object, iterator, follow = false) {
// check if the object is an object and isn't empty
if (is(object) && !empty(object) && typeof iterator === 'function') {
// create empty object for result
let result = {};
// for each over the object keys and values
// follow is passed into each therefore the
// each function works out whether to follow
// the objects
each(object, (key, value) => {
// run the iterator function on the key and
// value and if it evaluates to true set
// the result object
if (iterator(key, value) === true) {
// set the key/value on the result object
result = set(result, key, value);
}
}, follow);
// return the result
return result;
}
// if the object isn't an object or is empty return
// an empty object this will keep the return immutable
return {};
} | [
"function",
"sort",
"(",
"object",
",",
"iterator",
",",
"follow",
"=",
"false",
")",
"{",
"// check if the object is an object and isn't empty",
"if",
"(",
"is",
"(",
"object",
")",
"&&",
"!",
"empty",
"(",
"object",
")",
"&&",
"typeof",
"iterator",
"===",
... | Sort an object via the iterator evaluation
@example
const a = { a: 4, b: 7, c: 3 };
sort(a, (a, b) => {
if (a.value < b.value) return -1;
if (a.value > b.value) return 1;
return 0;
}); // => { c: 3, a: 4, b: 7 }
@since 1.0.0
@version 1.0.0
@param {object} object The object to sort
@param {function(a: object, b: object)} iterator The function to evaluate
@param {boolean} [follow=false] Whether to follow objects
@returns {object} The sorted object | [
"Sort",
"an",
"object",
"via",
"the",
"iterator",
"evaluation"
] | 666c9faa36586c0bcdecc0f2a7e1f069a7a3ce54 | https://github.com/hammy2899/o/blob/666c9faa36586c0bcdecc0f2a7e1f069a7a3ce54/src/sort.js#L27-L54 |
32,114 | CyberAgent/beezlib | lib/css/sprite.js | function (srcPath, options) {
_.defaults(options || (options = {}), DEFAULT_OPTIONS);
if(!this.isSpriteImage(srcPath, options)) {
logger.error('is not SpriteImage. srcPath:' + srcPath);
return [];
}
var separator = options.separator;
var ratios = options.ratios;
var group = this.getGroup(srcPath, options);
var head = this.getHead(srcPath, options);
var files = [];
files.push(head + separator + group + '.styl');
for (var i = 0; i < ratios.length; i++) {
files.push('sprite' + separator + group + '@' + (ratios[i] * 10) + 'x.png');
}
return files;
} | javascript | function (srcPath, options) {
_.defaults(options || (options = {}), DEFAULT_OPTIONS);
if(!this.isSpriteImage(srcPath, options)) {
logger.error('is not SpriteImage. srcPath:' + srcPath);
return [];
}
var separator = options.separator;
var ratios = options.ratios;
var group = this.getGroup(srcPath, options);
var head = this.getHead(srcPath, options);
var files = [];
files.push(head + separator + group + '.styl');
for (var i = 0; i < ratios.length; i++) {
files.push('sprite' + separator + group + '@' + (ratios[i] * 10) + 'x.png');
}
return files;
} | [
"function",
"(",
"srcPath",
",",
"options",
")",
"{",
"_",
".",
"defaults",
"(",
"options",
"||",
"(",
"options",
"=",
"{",
"}",
")",
",",
"DEFAULT_OPTIONS",
")",
";",
"if",
"(",
"!",
"this",
".",
"isSpriteImage",
"(",
"srcPath",
",",
"options",
")",... | After building, then to get the files that are created
@param {String} srcPath
@param {Object} options
@returns {Array}
var srcPath = 'test/image/sprite/sprite-logo-hoge.png'
var options = {
separator: '-',
ratios: [ 1, 2 ]
};
var out = getCreateFile(srcPath, options):
console.log(out);
> [ 'sprite-logo.styl', 'sprite-logo@10x.png', 'sprite-logo@20x.png' ] | [
"After",
"building",
"then",
"to",
"get",
"the",
"files",
"that",
"are",
"created"
] | 1fda067ccc2d07e06ebc7ea7e500e94f21e0080f | https://github.com/CyberAgent/beezlib/blob/1fda067ccc2d07e06ebc7ea7e500e94f21e0080f/lib/css/sprite.js#L206-L224 | |
32,115 | hammy2899/o | src/values.js | values | function values(object, follow) {
// check if object is an object
if (is(object) && !empty(object)) {
// create an empty array for the result
const result = [];
// if follow is true flatten the object keys so
// its easy to get the path to get the value
// if follow is false it will just be the base
// object therefore it will only need to base keys
const keysObject = follow
? deflate(object)
: object;
// loop over the keys of the object
Object.keys(keysObject).forEach((key) => {
// get the current key value
const value = keysObject[key];
// add it to the result array
result.push(value);
});
// return the result
return result;
}
// if the object isn't an object or is empty return
// an empty array because it won't contain any values
return [];
} | javascript | function values(object, follow) {
// check if object is an object
if (is(object) && !empty(object)) {
// create an empty array for the result
const result = [];
// if follow is true flatten the object keys so
// its easy to get the path to get the value
// if follow is false it will just be the base
// object therefore it will only need to base keys
const keysObject = follow
? deflate(object)
: object;
// loop over the keys of the object
Object.keys(keysObject).forEach((key) => {
// get the current key value
const value = keysObject[key];
// add it to the result array
result.push(value);
});
// return the result
return result;
}
// if the object isn't an object or is empty return
// an empty array because it won't contain any values
return [];
} | [
"function",
"values",
"(",
"object",
",",
"follow",
")",
"{",
"// check if object is an object",
"if",
"(",
"is",
"(",
"object",
")",
"&&",
"!",
"empty",
"(",
"object",
")",
")",
"{",
"// create an empty array for the result",
"const",
"result",
"=",
"[",
"]",... | Get an array of values from the specified object
@example
const a = { a: 1, b: 2, c: 3 };
values(a); // => [1, 2, 3]
@since 1.0.0
@version 1.0.0
@param {object} object The object to get the values from
@param {boolean} [follow=false] Whether to follow objects
@returns {array} An array of all the values from the object | [
"Get",
"an",
"array",
"of",
"values",
"from",
"the",
"specified",
"object"
] | 666c9faa36586c0bcdecc0f2a7e1f069a7a3ce54 | https://github.com/hammy2899/o/blob/666c9faa36586c0bcdecc0f2a7e1f069a7a3ce54/src/values.js#L21-L51 |
32,116 | CyberAgent/beezlib | lib/logger.js | function (prefix, preout, messages) {
if (prefix && this.LEVELS[prefix] < this.level) {
return;
}
var msg = "";
for (var i = 0; i < messages.length; i++) {
0 < i ? msg += ' ' + messages[i]: msg += messages[i];
}
var out = msg;
if (prefix) { out = preout + ' ' + msg; }
console.log(out);
} | javascript | function (prefix, preout, messages) {
if (prefix && this.LEVELS[prefix] < this.level) {
return;
}
var msg = "";
for (var i = 0; i < messages.length; i++) {
0 < i ? msg += ' ' + messages[i]: msg += messages[i];
}
var out = msg;
if (prefix) { out = preout + ' ' + msg; }
console.log(out);
} | [
"function",
"(",
"prefix",
",",
"preout",
",",
"messages",
")",
"{",
"if",
"(",
"prefix",
"&&",
"this",
".",
"LEVELS",
"[",
"prefix",
"]",
"<",
"this",
".",
"level",
")",
"{",
"return",
";",
"}",
"var",
"msg",
"=",
"\"\"",
";",
"for",
"(",
"var",... | colors setup flag
@name output
@memberof logger
@method
@param {String} prefix message prefix.
@param {Array} messages output messages
@private | [
"colors",
"setup",
"flag"
] | 1fda067ccc2d07e06ebc7ea7e500e94f21e0080f | https://github.com/CyberAgent/beezlib/blob/1fda067ccc2d07e06ebc7ea7e500e94f21e0080f/lib/logger.js#L41-L53 | |
32,117 | saneef/metalsmith-hyphenate | index.js | hyphenateText | function hyphenateText(dom, forceHyphenateAllChildren) {
if (dom.childNodes !== undefined) {
dom.childNodes.forEach(function(node) {
if (node.nodeName === '#text' && !isSkippable(node) && (forceHyphenateAllChildren || isPresent(options.elements, dom.tagName))) {
node.value = hypher.hyphenateText(node.value);
} else {
hyphenateText(node, isPresent(options.elements, dom.tagName));
}
});
}
return dom;
} | javascript | function hyphenateText(dom, forceHyphenateAllChildren) {
if (dom.childNodes !== undefined) {
dom.childNodes.forEach(function(node) {
if (node.nodeName === '#text' && !isSkippable(node) && (forceHyphenateAllChildren || isPresent(options.elements, dom.tagName))) {
node.value = hypher.hyphenateText(node.value);
} else {
hyphenateText(node, isPresent(options.elements, dom.tagName));
}
});
}
return dom;
} | [
"function",
"hyphenateText",
"(",
"dom",
",",
"forceHyphenateAllChildren",
")",
"{",
"if",
"(",
"dom",
".",
"childNodes",
"!==",
"undefined",
")",
"{",
"dom",
".",
"childNodes",
".",
"forEach",
"(",
"function",
"(",
"node",
")",
"{",
"if",
"(",
"node",
"... | Traverses throught parsed DOM, and hyphenate text nodes
@param {String} domString
@return {String} | [
"Traverses",
"throught",
"parsed",
"DOM",
"and",
"hyphenate",
"text",
"nodes"
] | e672f1027a25f97a0c3ddac126702add44d6f83b | https://github.com/saneef/metalsmith-hyphenate/blob/e672f1027a25f97a0c3ddac126702add44d6f83b/index.js#L76-L88 |
32,118 | saneef/metalsmith-hyphenate | index.js | isSkippable | function isSkippable(node) {
var result = false;
if (node && node.parentNode && node.parentNode.attrs && Array.isArray(node.parentNode.attrs)) {
node.parentNode.attrs.forEach(function(attr) {
if (attr.name && attr.value && attr.name === HYPHENATE_DATA_ATTR && attr.value === 'false') {
result = true;
}
});
}
return result;
} | javascript | function isSkippable(node) {
var result = false;
if (node && node.parentNode && node.parentNode.attrs && Array.isArray(node.parentNode.attrs)) {
node.parentNode.attrs.forEach(function(attr) {
if (attr.name && attr.value && attr.name === HYPHENATE_DATA_ATTR && attr.value === 'false') {
result = true;
}
});
}
return result;
} | [
"function",
"isSkippable",
"(",
"node",
")",
"{",
"var",
"result",
"=",
"false",
";",
"if",
"(",
"node",
"&&",
"node",
".",
"parentNode",
"&&",
"node",
".",
"parentNode",
".",
"attrs",
"&&",
"Array",
".",
"isArray",
"(",
"node",
".",
"parentNode",
".",... | Check if the node is marked for skip
@param {String} DOM node
@return {Boolean} | [
"Check",
"if",
"the",
"node",
"is",
"marked",
"for",
"skip"
] | e672f1027a25f97a0c3ddac126702add44d6f83b | https://github.com/saneef/metalsmith-hyphenate/blob/e672f1027a25f97a0c3ddac126702add44d6f83b/index.js#L96-L107 |
32,119 | saneef/metalsmith-hyphenate | index.js | isIgnoredFile | function isIgnoredFile(file) {
if (options.ignore !== undefined) {
var result = false;
options.ignore.forEach(function(pattern) {
if (minimatch(file, pattern)) {
result = true;
return false;
}
});
return result;
}
return false;
} | javascript | function isIgnoredFile(file) {
if (options.ignore !== undefined) {
var result = false;
options.ignore.forEach(function(pattern) {
if (minimatch(file, pattern)) {
result = true;
return false;
}
});
return result;
}
return false;
} | [
"function",
"isIgnoredFile",
"(",
"file",
")",
"{",
"if",
"(",
"options",
".",
"ignore",
"!==",
"undefined",
")",
"{",
"var",
"result",
"=",
"false",
";",
"options",
".",
"ignore",
".",
"forEach",
"(",
"function",
"(",
"pattern",
")",
"{",
"if",
"(",
... | Check if the file matches the ignore glob patterns
@param {String} file
@return {Boolean} | [
"Check",
"if",
"the",
"file",
"matches",
"the",
"ignore",
"glob",
"patterns"
] | e672f1027a25f97a0c3ddac126702add44d6f83b | https://github.com/saneef/metalsmith-hyphenate/blob/e672f1027a25f97a0c3ddac126702add44d6f83b/index.js#L115-L130 |
32,120 | hash-bang/tree-tools | dist/tree-tools.js | filter | function filter(tree, query, options) {
var compiledQuery = _.isFunction(query) ? query : _.matches(query);
var settings = _.defaults(options, {
childNode: ['children']
});
settings.childNode = _.castArray(settings.childNode);
var seekDown = function seekDown(tree) {
return tree.filter(function (branch, index) {
return compiledQuery(branch, index);
}).map(function (branch) {
settings.childNode.some(function (key) {
if (_.has(branch, key)) {
if (_.isArray(branch[key])) {
branch[key] = seekDown(branch[key]);
} else {
delete branch[key];
}
}
});
return branch;
});
};
if (_.isArray(tree)) {
return seekDown(tree, []) || [];
} else {
return seekDown([tree], [])[0] || {};
}
} | javascript | function filter(tree, query, options) {
var compiledQuery = _.isFunction(query) ? query : _.matches(query);
var settings = _.defaults(options, {
childNode: ['children']
});
settings.childNode = _.castArray(settings.childNode);
var seekDown = function seekDown(tree) {
return tree.filter(function (branch, index) {
return compiledQuery(branch, index);
}).map(function (branch) {
settings.childNode.some(function (key) {
if (_.has(branch, key)) {
if (_.isArray(branch[key])) {
branch[key] = seekDown(branch[key]);
} else {
delete branch[key];
}
}
});
return branch;
});
};
if (_.isArray(tree)) {
return seekDown(tree, []) || [];
} else {
return seekDown([tree], [])[0] || {};
}
} | [
"function",
"filter",
"(",
"tree",
",",
"query",
",",
"options",
")",
"{",
"var",
"compiledQuery",
"=",
"_",
".",
"isFunction",
"(",
"query",
")",
"?",
"query",
":",
"_",
".",
"matches",
"(",
"query",
")",
";",
"var",
"settings",
"=",
"_",
".",
"de... | Return a copy of the tree with all non-matching nodes removed
NOTE: This function seeks downwards, so any parent that does not match will also omit its child nodes
@param {Object|array} tree The tree structure to search (assumed to be a collection)
@param {Object|function} query A valid lodash query to run (anything valid via _.find()) or a matching function to be run on each node
@param {Object} [options] Options object
@param {array|string} [options.childNode="children"] Node or nodes to examine to discover the child elements | [
"Return",
"a",
"copy",
"of",
"the",
"tree",
"with",
"all",
"non",
"-",
"matching",
"nodes",
"removed"
] | 12544aebaaaa506cb34259f16da34e4b5364829d | https://github.com/hash-bang/tree-tools/blob/12544aebaaaa506cb34259f16da34e4b5364829d/dist/tree-tools.js#L39-L70 |
32,121 | hash-bang/tree-tools | dist/tree-tools.js | hasChildren | function hasChildren(branch, options) {
var settings = _.defaults(options, {
childNode: ['children']
});
return settings.childNode.some(function (key) {
return branch[key] && _.isArray(branch[key]) && branch[key].length;
});
} | javascript | function hasChildren(branch, options) {
var settings = _.defaults(options, {
childNode: ['children']
});
return settings.childNode.some(function (key) {
return branch[key] && _.isArray(branch[key]) && branch[key].length;
});
} | [
"function",
"hasChildren",
"(",
"branch",
",",
"options",
")",
"{",
"var",
"settings",
"=",
"_",
".",
"defaults",
"(",
"options",
",",
"{",
"childNode",
":",
"[",
"'children'",
"]",
"}",
")",
";",
"return",
"settings",
".",
"childNode",
".",
"some",
"(... | Utility function to determines whether a given node has children
@param {Object|array} branch The tree structure to search (assumed to be a collection)
@param {Object} [options] Optional options object
@param {array|string} [options.childNode="children"] Node or nodes to examine to discover the child elements
@return {array} An array of all child elements under that item | [
"Utility",
"function",
"to",
"determines",
"whether",
"a",
"given",
"node",
"has",
"children"
] | 12544aebaaaa506cb34259f16da34e4b5364829d | https://github.com/hash-bang/tree-tools/blob/12544aebaaaa506cb34259f16da34e4b5364829d/dist/tree-tools.js#L190-L198 |
32,122 | hash-bang/tree-tools | dist/tree-tools.js | attemptNext | function attemptNext() {
if (--settings.attempts > 0 && dirty) {
dirty = false; // Mark sweep as clean - will get dirty if resolver sees a function return
resolver(base, []).then(attemptNext);
} else {
resolve();
}
} | javascript | function attemptNext() {
if (--settings.attempts > 0 && dirty) {
dirty = false; // Mark sweep as clean - will get dirty if resolver sees a function return
resolver(base, []).then(attemptNext);
} else {
resolve();
}
} | [
"function",
"attemptNext",
"(",
")",
"{",
"if",
"(",
"--",
"settings",
".",
"attempts",
">",
"0",
"&&",
"dirty",
")",
"{",
"dirty",
"=",
"false",
";",
"// Mark sweep as clean - will get dirty if resolver sees a function return",
"resolver",
"(",
"base",
",",
"[",
... | Loop the resolver until we are out of attempts | [
"Loop",
"the",
"resolver",
"until",
"we",
"are",
"out",
"of",
"attempts"
] | 12544aebaaaa506cb34259f16da34e4b5364829d | https://github.com/hash-bang/tree-tools/blob/12544aebaaaa506cb34259f16da34e4b5364829d/dist/tree-tools.js#L290-L298 |
32,123 | hash-bang/tree-tools | dist/tree-tools.js | sortBy | function sortBy(tree, propertyName) {
var _this = this;
// It is needed an array structure to sort.
if (!_.isArray(tree)) tree = [tree];
tree.forEach(function (item) {
return _(item).keys().forEach(function (key) {
if (_.isArray(item[key])) item[key] = _this.sortBy(item[key], propertyName);
});
});
return _.sortBy(tree, propertyName);
} | javascript | function sortBy(tree, propertyName) {
var _this = this;
// It is needed an array structure to sort.
if (!_.isArray(tree)) tree = [tree];
tree.forEach(function (item) {
return _(item).keys().forEach(function (key) {
if (_.isArray(item[key])) item[key] = _this.sortBy(item[key], propertyName);
});
});
return _.sortBy(tree, propertyName);
} | [
"function",
"sortBy",
"(",
"tree",
",",
"propertyName",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"// It is needed an array structure to sort.",
"if",
"(",
"!",
"_",
".",
"isArray",
"(",
"tree",
")",
")",
"tree",
"=",
"[",
"tree",
"]",
";",
"tree",
"."... | Utility function to sort tree by specific property or an array of properties
@param {array} tree The tree structure to sort
@param {array|string} propertyName Property names to sort the tree
@return {array} An array sorted by propertyName | [
"Utility",
"function",
"to",
"sort",
"tree",
"by",
"specific",
"property",
"or",
"an",
"array",
"of",
"properties"
] | 12544aebaaaa506cb34259f16da34e4b5364829d | https://github.com/hash-bang/tree-tools/blob/12544aebaaaa506cb34259f16da34e4b5364829d/dist/tree-tools.js#L324-L335 |
32,124 | FBDY/bb-blocks | blocks_vertical/control.js | function() {
this.jsonInit({
"message0": "%1",
"args0": [
{
"type": "field_variable",
"name": "CLONE_NAME_OPTION",
"variableTypes": [Blockly.CLONE_NAME_VARIABLE_TYPE],
"variable": Blockly.Msg.DEFAULT_CLONE_NAME
}
],
"colour": Blockly.Colours.control.secondary,
"colourSecondary": Blockly.Colours.control.secondary,
"colourTertiary": Blockly.Colours.control.tertiary,
"extensions": ["output_string"]
});
} | javascript | function() {
this.jsonInit({
"message0": "%1",
"args0": [
{
"type": "field_variable",
"name": "CLONE_NAME_OPTION",
"variableTypes": [Blockly.CLONE_NAME_VARIABLE_TYPE],
"variable": Blockly.Msg.DEFAULT_CLONE_NAME
}
],
"colour": Blockly.Colours.control.secondary,
"colourSecondary": Blockly.Colours.control.secondary,
"colourTertiary": Blockly.Colours.control.tertiary,
"extensions": ["output_string"]
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"jsonInit",
"(",
"{",
"\"message0\"",
":",
"\"%1\"",
",",
"\"args0\"",
":",
"[",
"{",
"\"type\"",
":",
"\"field_variable\"",
",",
"\"name\"",
":",
"\"CLONE_NAME_OPTION\"",
",",
"\"variableTypes\"",
":",
"[",
"Blockly",
... | Clone name selection menu.
@this Blockly.Block | [
"Clone",
"name",
"selection",
"menu",
"."
] | 748cb75966a730f13134bba4e76690793b042675 | https://github.com/FBDY/bb-blocks/blob/748cb75966a730f13134bba4e76690793b042675/blocks_vertical/control.js#L404-L420 | |
32,125 | frig-js/frig | src/index.js | defaultTheme | function defaultTheme(theme) {
if (theme == null) return Form.defaultProps.theme
if (typeof theme !== 'object') {
throw new Error('Invalid Frig theme. Expected an object')
}
Form.defaultProps.theme = theme
UnboundInput.defaultProps.theme = theme
return true
} | javascript | function defaultTheme(theme) {
if (theme == null) return Form.defaultProps.theme
if (typeof theme !== 'object') {
throw new Error('Invalid Frig theme. Expected an object')
}
Form.defaultProps.theme = theme
UnboundInput.defaultProps.theme = theme
return true
} | [
"function",
"defaultTheme",
"(",
"theme",
")",
"{",
"if",
"(",
"theme",
"==",
"null",
")",
"return",
"Form",
".",
"defaultProps",
".",
"theme",
"if",
"(",
"typeof",
"theme",
"!==",
"'object'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Invalid Frig theme. E... | Setter and getter for the Frig default theme | [
"Setter",
"and",
"getter",
"for",
"the",
"Frig",
"default",
"theme"
] | 77770cabe1d8dc1222849c74946f18e47e29b7ea | https://github.com/frig-js/frig/blob/77770cabe1d8dc1222849c74946f18e47e29b7ea/src/index.js#L20-L28 |
32,126 | Xcraft-Inc/shellcraft.js | lib/argument.js | Argument | function Argument(handler, options, desc) {
if (!options.hasOwnProperty('scope')) {
options.scope = 'global';
}
this._parent = null;
this._name = null;
this._options = options;
this._desc = desc;
this._handler = handler;
return this;
} | javascript | function Argument(handler, options, desc) {
if (!options.hasOwnProperty('scope')) {
options.scope = 'global';
}
this._parent = null;
this._name = null;
this._options = options;
this._desc = desc;
this._handler = handler;
return this;
} | [
"function",
"Argument",
"(",
"handler",
",",
"options",
",",
"desc",
")",
"{",
"if",
"(",
"!",
"options",
".",
"hasOwnProperty",
"(",
"'scope'",
")",
")",
"{",
"options",
".",
"scope",
"=",
"'global'",
";",
"}",
"this",
".",
"_parent",
"=",
"null",
"... | Argument constructor. | [
"Argument",
"constructor",
"."
] | ff23cf75212e871a18ec2f1791a6939af489e0fb | https://github.com/Xcraft-Inc/shellcraft.js/blob/ff23cf75212e871a18ec2f1791a6939af489e0fb/lib/argument.js#L29-L39 |
32,127 | GCheung55/Neuro | src/collection/collection.js | function(model, at){
model = new this._Model(model, this.options.Model.options);
if (!this.hasModel(model)) {
// Attach events to the model that will signal collection events
this.attachModelEvents(model);
// If _models is empty, then we make sure to push instead of splice.
at = this.length == 0 ? void 0 : at;
if (at != void 0) {
this._models.splice(at, 0, model);
} else {
this._models.push(model);
}
this.length = this._models.length;
this._changed = true;
// if at is undefined, then it would be at the end of the array, thus this.length-1
this.signalAdd(model, at != void 0 ? at : this.length - 1);
}
return this;
} | javascript | function(model, at){
model = new this._Model(model, this.options.Model.options);
if (!this.hasModel(model)) {
// Attach events to the model that will signal collection events
this.attachModelEvents(model);
// If _models is empty, then we make sure to push instead of splice.
at = this.length == 0 ? void 0 : at;
if (at != void 0) {
this._models.splice(at, 0, model);
} else {
this._models.push(model);
}
this.length = this._models.length;
this._changed = true;
// if at is undefined, then it would be at the end of the array, thus this.length-1
this.signalAdd(model, at != void 0 ? at : this.length - 1);
}
return this;
} | [
"function",
"(",
"model",
",",
"at",
")",
"{",
"model",
"=",
"new",
"this",
".",
"_Model",
"(",
"model",
",",
"this",
".",
"options",
".",
"Model",
".",
"options",
")",
";",
"if",
"(",
"!",
"this",
".",
"hasModel",
"(",
"model",
")",
")",
"{",
... | Private add method
@param {Class} model A Model instance
@param {Number} at The index at which the model should be inserted
@return {Class} Collection Instance | [
"Private",
"add",
"method"
] | 9d21bb94fe60069ef51c4120215baa8f38865600 | https://github.com/GCheung55/Neuro/blob/9d21bb94fe60069ef51c4120215baa8f38865600/src/collection/collection.js#L126-L151 | |
32,128 | GCheung55/Neuro | src/collection/collection.js | function(index){
var len = arguments.length, i = 0, results;
if (len > 1) {
results = [];
while(len--){
results.push(this.get(arguments[i++]));
}
return results;
}
return this._models[index];
} | javascript | function(index){
var len = arguments.length, i = 0, results;
if (len > 1) {
results = [];
while(len--){
results.push(this.get(arguments[i++]));
}
return results;
}
return this._models[index];
} | [
"function",
"(",
"index",
")",
"{",
"var",
"len",
"=",
"arguments",
".",
"length",
",",
"i",
"=",
"0",
",",
"results",
";",
"if",
"(",
"len",
">",
"1",
")",
"{",
"results",
"=",
"[",
"]",
";",
"while",
"(",
"len",
"--",
")",
"{",
"results",
"... | Get model by index
Overloaded to return an array of models if more than one 'index'
argument is passed
@param {Number} index Index of model to return
@return {Class || Array} Model instance or Array of Model instances | [
"Get",
"model",
"by",
"index",
"Overloaded",
"to",
"return",
"an",
"array",
"of",
"models",
"if",
"more",
"than",
"one",
"index",
"argument",
"is",
"passed"
] | 9d21bb94fe60069ef51c4120215baa8f38865600 | https://github.com/GCheung55/Neuro/blob/9d21bb94fe60069ef51c4120215baa8f38865600/src/collection/collection.js#L195-L209 | |
32,129 | GCheung55/Neuro | src/collection/collection.js | function(model){
if (this.hasModel(model)) {
// Clean up when removing so that it doesn't try removing itself from the collection
this.detachModelEvents(model);
this._models.erase(model);
this.length = this._models.length;
this._changed = true;
this.signalRemove(model);
}
return this;
} | javascript | function(model){
if (this.hasModel(model)) {
// Clean up when removing so that it doesn't try removing itself from the collection
this.detachModelEvents(model);
this._models.erase(model);
this.length = this._models.length;
this._changed = true;
this.signalRemove(model);
}
return this;
} | [
"function",
"(",
"model",
")",
"{",
"if",
"(",
"this",
".",
"hasModel",
"(",
"model",
")",
")",
"{",
"// Clean up when removing so that it doesn't try removing itself from the collection",
"this",
".",
"detachModelEvents",
"(",
"model",
")",
";",
"this",
".",
"_mode... | Private remove method
@param {Class} model A Model instance
@return {Class} Collection Instance | [
"Private",
"remove",
"method"
] | 9d21bb94fe60069ef51c4120215baa8f38865600 | https://github.com/GCheung55/Neuro/blob/9d21bb94fe60069ef51c4120215baa8f38865600/src/collection/collection.js#L216-L231 | |
32,130 | GCheung55/Neuro | src/collection/collection.js | function(oldModel, newModel){
var index;
if (oldModel && newModel && this.hasModel(oldModel) && !this.hasModel(newModel)) {
index = this.indexOf(oldModel);
if (index > -1) {
this.act(function(){
this.add(newModel, index);
this.remove(oldModel);
});
!this.isActive() && this.signalChange() && this.resetChange();
}
}
return this;
} | javascript | function(oldModel, newModel){
var index;
if (oldModel && newModel && this.hasModel(oldModel) && !this.hasModel(newModel)) {
index = this.indexOf(oldModel);
if (index > -1) {
this.act(function(){
this.add(newModel, index);
this.remove(oldModel);
});
!this.isActive() && this.signalChange() && this.resetChange();
}
}
return this;
} | [
"function",
"(",
"oldModel",
",",
"newModel",
")",
"{",
"var",
"index",
";",
"if",
"(",
"oldModel",
"&&",
"newModel",
"&&",
"this",
".",
"hasModel",
"(",
"oldModel",
")",
"&&",
"!",
"this",
".",
"hasModel",
"(",
"newModel",
")",
")",
"{",
"index",
"=... | Replace an existing model with a new one
@param {Class} oldModel A Model instance that will be replaced with the new
@param {Object || Class} newModel An object or Model instance that will replace the old
@return {Class} Collection Instance | [
"Replace",
"an",
"existing",
"model",
"with",
"a",
"new",
"one"
] | 9d21bb94fe60069ef51c4120215baa8f38865600 | https://github.com/GCheung55/Neuro/blob/9d21bb94fe60069ef51c4120215baa8f38865600/src/collection/collection.js#L274-L292 | |
32,131 | Woorank/node-url-tools | index.js | fireRequest | function fireRequest(urlStr, callback) {
var start = Date.now();
request({
url: urlStr,
method: 'GET',
maxRedirects: 8,
timeout: 10 * 1000
//headers: { 'User-Agent': 'woobot/2.0' }
}, function (error, response) {
callback(error, response, Date.now() - start);
});
} | javascript | function fireRequest(urlStr, callback) {
var start = Date.now();
request({
url: urlStr,
method: 'GET',
maxRedirects: 8,
timeout: 10 * 1000
//headers: { 'User-Agent': 'woobot/2.0' }
}, function (error, response) {
callback(error, response, Date.now() - start);
});
} | [
"function",
"fireRequest",
"(",
"urlStr",
",",
"callback",
")",
"{",
"var",
"start",
"=",
"Date",
".",
"now",
"(",
")",
";",
"request",
"(",
"{",
"url",
":",
"urlStr",
",",
"method",
":",
"'GET'",
",",
"maxRedirects",
":",
"8",
",",
"timeout",
":",
... | Fire http request and callback when done.
@param {String} urlStr The url.
@param {Function} callback Callback with error, response and responstime. | [
"Fire",
"http",
"request",
"and",
"callback",
"when",
"done",
"."
] | d55b3a405a32a2d9d06dc47684d63fd91dbf5d6f | https://github.com/Woorank/node-url-tools/blob/d55b3a405a32a2d9d06dc47684d63fd91dbf5d6f/index.js#L20-L32 |
32,132 | MRN-Code/bookshelf-shield | lib/Rule.js | validate | function validate(options) {
const schema = joi.object().keys({
actionName: joi.string().required(),
authKey: joi.string().required(),
modelName: joi.string().required(),
acl: joi.object(),
aclContextName: joi.string().required()
});
const errorMsg = 'Invalid rule options: ';
const aclContext = options.acl[options.aclContextName];
joi.assert(options, schema, errorMsg);
joi.assert(aclContext, joi.func().required(), errorMsg);
return true;
} | javascript | function validate(options) {
const schema = joi.object().keys({
actionName: joi.string().required(),
authKey: joi.string().required(),
modelName: joi.string().required(),
acl: joi.object(),
aclContextName: joi.string().required()
});
const errorMsg = 'Invalid rule options: ';
const aclContext = options.acl[options.aclContextName];
joi.assert(options, schema, errorMsg);
joi.assert(aclContext, joi.func().required(), errorMsg);
return true;
} | [
"function",
"validate",
"(",
"options",
")",
"{",
"const",
"schema",
"=",
"joi",
".",
"object",
"(",
")",
".",
"keys",
"(",
"{",
"actionName",
":",
"joi",
".",
"string",
"(",
")",
".",
"required",
"(",
")",
",",
"authKey",
":",
"joi",
".",
"string"... | validate options sent to buildGeneric
@param {object} options is the options to validate
@return {boolean} true, otherwise throw error | [
"validate",
"options",
"sent",
"to",
"buildGeneric"
] | 4f13ed22e3f951b3e7733823841c7bf9ef88df0b | https://github.com/MRN-Code/bookshelf-shield/blob/4f13ed22e3f951b3e7733823841c7bf9ef88df0b/lib/Rule.js#L10-L23 |
32,133 | jmarca/makedir | lib/makedir.js | makeme | function makeme (dir,mode,cb){
var callback = function(err,parent){
//console.log('makeme: ',dir)
if(err) throw new Error(err)
if(parent){
// replace root of dir with parent
dir = path.join(parent,path.basename(dir));
}
fs.mkdir(dir,mode,function(err){
if(err !== null){
if( err.code === 'EEXIST'
&& err.path === dir){
// make sure the directory really does exist
fs.stat(dir,function(staterr,stat){
// as mkdirP guys say, this is very strange
if(staterr || !stat.isDirectory()){
if(cb) cb(err);
}
if(cb) cb(null,dir);
return null;
// if the stat is good, do nothing. some other processed did it
});
}else{
console.log(err);
throw new Error(err);
}
}else{
if(cb) cb(null,dir);
}
return 1;
});
};
return callback;
} | javascript | function makeme (dir,mode,cb){
var callback = function(err,parent){
//console.log('makeme: ',dir)
if(err) throw new Error(err)
if(parent){
// replace root of dir with parent
dir = path.join(parent,path.basename(dir));
}
fs.mkdir(dir,mode,function(err){
if(err !== null){
if( err.code === 'EEXIST'
&& err.path === dir){
// make sure the directory really does exist
fs.stat(dir,function(staterr,stat){
// as mkdirP guys say, this is very strange
if(staterr || !stat.isDirectory()){
if(cb) cb(err);
}
if(cb) cb(null,dir);
return null;
// if the stat is good, do nothing. some other processed did it
});
}else{
console.log(err);
throw new Error(err);
}
}else{
if(cb) cb(null,dir);
}
return 1;
});
};
return callback;
} | [
"function",
"makeme",
"(",
"dir",
",",
"mode",
",",
"cb",
")",
"{",
"var",
"callback",
"=",
"function",
"(",
"err",
",",
"parent",
")",
"{",
"//console.log('makeme: ',dir)",
"if",
"(",
"err",
")",
"throw",
"new",
"Error",
"(",
"err",
")",
"if",
"(",
... | do the actual directory making. probably should add mode as a parameter somewhere | [
"do",
"the",
"actual",
"directory",
"making",
".",
"probably",
"should",
"add",
"mode",
"as",
"a",
"parameter",
"somewhere"
] | 5e680c4878bf032bb7d11bd87d124abca4295941 | https://github.com/jmarca/makedir/blob/5e680c4878bf032bb7d11bd87d124abca4295941/lib/makedir.js#L35-L71 |
32,134 | jmarca/makedir | lib/makedir.js | handleStatforPath | function handleStatforPath(p, mode, parent,next){
return function(exists){
if(!exists){
//console.log('no path ' + p + ' so recurse');
return makedir(parent,
mode,
makeme(p,mode,next));
}else{
// console.log('have path, recursing ends at ',p);
next();
}
return 1;
};
} | javascript | function handleStatforPath(p, mode, parent,next){
return function(exists){
if(!exists){
//console.log('no path ' + p + ' so recurse');
return makedir(parent,
mode,
makeme(p,mode,next));
}else{
// console.log('have path, recursing ends at ',p);
next();
}
return 1;
};
} | [
"function",
"handleStatforPath",
"(",
"p",
",",
"mode",
",",
"parent",
",",
"next",
")",
"{",
"return",
"function",
"(",
"exists",
")",
"{",
"if",
"(",
"!",
"exists",
")",
"{",
"//console.log('no path ' + p + ' so recurse');",
"return",
"makedir",
"(",
"parent... | function to handle stat | [
"function",
"to",
"handle",
"stat"
] | 5e680c4878bf032bb7d11bd87d124abca4295941 | https://github.com/jmarca/makedir/blob/5e680c4878bf032bb7d11bd87d124abca4295941/lib/makedir.js#L76-L89 |
32,135 | jmarca/makedir | lib/makedir.js | makedir | function makedir(p,mode,next){
if (typeof mode === 'function' || mode === undefined) {
next = mode;
mode = 0777 & (~process.umask());
}
if (typeof mode === 'string') mode = parseInt(mode, 8);
p = path.resolve(p);
// recursively make sure that directory exists.
//
var parent = path.dirname(p);
if(parent){
fs.exists(p,handleStatforPath(p,mode,parent,next));
}else{
// following convention, if the path is actually a dot at this
// point, prepend the current process root dir and carry on
// back up the stack.
//
if(p === '.'){
// replace . with rootdir
p = rootdir;
// recurse back up with that value
return next(null,p)
}
//
// not sure what is up. path.dirname should create '.' for
// parent of relative path names
//
console.log('in make parent dir, no parents left for : '+p+' try prepending the process root dir');
throw new Error('parent failure ' + p);
}
return null;
} | javascript | function makedir(p,mode,next){
if (typeof mode === 'function' || mode === undefined) {
next = mode;
mode = 0777 & (~process.umask());
}
if (typeof mode === 'string') mode = parseInt(mode, 8);
p = path.resolve(p);
// recursively make sure that directory exists.
//
var parent = path.dirname(p);
if(parent){
fs.exists(p,handleStatforPath(p,mode,parent,next));
}else{
// following convention, if the path is actually a dot at this
// point, prepend the current process root dir and carry on
// back up the stack.
//
if(p === '.'){
// replace . with rootdir
p = rootdir;
// recurse back up with that value
return next(null,p)
}
//
// not sure what is up. path.dirname should create '.' for
// parent of relative path names
//
console.log('in make parent dir, no parents left for : '+p+' try prepending the process root dir');
throw new Error('parent failure ' + p);
}
return null;
} | [
"function",
"makedir",
"(",
"p",
",",
"mode",
",",
"next",
")",
"{",
"if",
"(",
"typeof",
"mode",
"===",
"'function'",
"||",
"mode",
"===",
"undefined",
")",
"{",
"next",
"=",
"mode",
";",
"mode",
"=",
"0777",
"&",
"(",
"~",
"process",
".",
"umask"... | the function that gets exported, but doesn't actually do any directory making checks if a directory parent exists using stat. If not, recurs into parent. | [
"the",
"function",
"that",
"gets",
"exported",
"but",
"doesn",
"t",
"actually",
"do",
"any",
"directory",
"making",
"checks",
"if",
"a",
"directory",
"parent",
"exists",
"using",
"stat",
".",
"If",
"not",
"recurs",
"into",
"parent",
"."
] | 5e680c4878bf032bb7d11bd87d124abca4295941 | https://github.com/jmarca/makedir/blob/5e680c4878bf032bb7d11bd87d124abca4295941/lib/makedir.js#L96-L129 |
32,136 | Woorank/node-url-tools | lib/Suffices.js | process | function process(segments, parent) {
var last = segments.pop();
if (last) {
parent[last] = parent[last] || {};
process(segments, parent[last]);
} else {
parent[true] = true;
}
} | javascript | function process(segments, parent) {
var last = segments.pop();
if (last) {
parent[last] = parent[last] || {};
process(segments, parent[last]);
} else {
parent[true] = true;
}
} | [
"function",
"process",
"(",
"segments",
",",
"parent",
")",
"{",
"var",
"last",
"=",
"segments",
".",
"pop",
"(",
")",
";",
"if",
"(",
"last",
")",
"{",
"parent",
"[",
"last",
"]",
"=",
"parent",
"[",
"last",
"]",
"||",
"{",
"}",
";",
"process",
... | Recursively parse an array of domain segments into a tree structure.
@param {Array} segments List of domain segments ordered sub to top.
@param {Object} parent Resulting tree object. | [
"Recursively",
"parse",
"an",
"array",
"of",
"domain",
"segments",
"into",
"a",
"tree",
"structure",
"."
] | d55b3a405a32a2d9d06dc47684d63fd91dbf5d6f | https://github.com/Woorank/node-url-tools/blob/d55b3a405a32a2d9d06dc47684d63fd91dbf5d6f/lib/Suffices.js#L9-L17 |
32,137 | konfirm/node-polymorphic | lib/polymorphic.js | isExtendOf | function isExtendOf(name, variable) {
var offset = typeof variable === 'object' && variable ? Object.getPrototypeOf(variable) : null,
pattern = offset ? new RegExp('^' + name + '$') : null;
// It is not quite feasible to compare the inheritance using `instanceof` (all constructors would have to
// be registered somehow then) we simply compare the constructor function names.
// As a side effect, this enables polymorphic to compare against the exact type (unless a developer has
// altered the constructor name, which is not protected from overwriting)
while (offset && offset.constructor) {
if (pattern.test(offset.constructor.name)) {
return true;
}
offset = Object.getPrototypeOf(offset);
}
return false;
} | javascript | function isExtendOf(name, variable) {
var offset = typeof variable === 'object' && variable ? Object.getPrototypeOf(variable) : null,
pattern = offset ? new RegExp('^' + name + '$') : null;
// It is not quite feasible to compare the inheritance using `instanceof` (all constructors would have to
// be registered somehow then) we simply compare the constructor function names.
// As a side effect, this enables polymorphic to compare against the exact type (unless a developer has
// altered the constructor name, which is not protected from overwriting)
while (offset && offset.constructor) {
if (pattern.test(offset.constructor.name)) {
return true;
}
offset = Object.getPrototypeOf(offset);
}
return false;
} | [
"function",
"isExtendOf",
"(",
"name",
",",
"variable",
")",
"{",
"var",
"offset",
"=",
"typeof",
"variable",
"===",
"'object'",
"&&",
"variable",
"?",
"Object",
".",
"getPrototypeOf",
"(",
"variable",
")",
":",
"null",
",",
"pattern",
"=",
"offset",
"?",
... | Determine if somewhere in the prototype chains the variable extends an Object with given name
@name isExtendOf
@access internal
@param string name
@param object variable
@return bool extends | [
"Determine",
"if",
"somewhere",
"in",
"the",
"prototype",
"chains",
"the",
"variable",
"extends",
"an",
"Object",
"with",
"given",
"name"
] | fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a | https://github.com/konfirm/node-polymorphic/blob/fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a/lib/polymorphic.js#L21-L38 |
32,138 | konfirm/node-polymorphic | lib/polymorphic.js | parameterize | function parameterize(candidate) {
candidate.param = candidate.param.map(function(param) {
var value;
if ('value' in param) {
value = param.value;
}
else if ('reference' in param) {
value = candidate.param.reduce(function(p, c) {
return c !== param && !p && param.reference === c.name && 'value' in c ? c.value : p;
}, null);
}
return value;
});
return candidate;
} | javascript | function parameterize(candidate) {
candidate.param = candidate.param.map(function(param) {
var value;
if ('value' in param) {
value = param.value;
}
else if ('reference' in param) {
value = candidate.param.reduce(function(p, c) {
return c !== param && !p && param.reference === c.name && 'value' in c ? c.value : p;
}, null);
}
return value;
});
return candidate;
} | [
"function",
"parameterize",
"(",
"candidate",
")",
"{",
"candidate",
".",
"param",
"=",
"candidate",
".",
"param",
".",
"map",
"(",
"function",
"(",
"param",
")",
"{",
"var",
"value",
";",
"if",
"(",
"'value'",
"in",
"param",
")",
"{",
"value",
"=",
... | Map the param property of given candidate to contain only the values and resolve any references to other arguments
@name parameterize
@access internal
@param Object candidate
@return Object candidate (with resolved params) | [
"Map",
"the",
"param",
"property",
"of",
"given",
"candidate",
"to",
"contain",
"only",
"the",
"values",
"and",
"resolve",
"any",
"references",
"to",
"other",
"arguments"
] | fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a | https://github.com/konfirm/node-polymorphic/blob/fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a/lib/polymorphic.js#L47-L64 |
32,139 | konfirm/node-polymorphic | lib/polymorphic.js | matchSignature | function matchSignature(list, arg) {
var types = arg.map(function(variable) {
return new RegExp('^(' + type(variable) + ')');
});
return list.filter(function(config) {
var variadic = false,
result;
// result is true if no more arguments are provided than the signature allows OR the last
// argument in the signature is variadic
result = arg.length <= config.arguments.length || (config.arguments[config.arguments.length - 1] && config.arguments[config.arguments.length - 1].type === '...');
// test each given argument agains the configured signatures
if (result) {
arg.forEach(function(value, index) {
var expect = config.arguments[index] ? config.arguments[index].type : null;
// look at ourself and ahead - if there is a following item, and it is variadic, it may be
// left out entirely (zero or more)
if (isTypeAtIndex('...', config.arguments, index)) {
variadic = true;
}
// the result remains valid as long as the values match the given signature
// (type matches or it is variadic)
result = result && (variadic || types[index].test(expect) || (expect[expect.length - 1] !== '!' && isExtendOf(expect, value)));
});
}
return result;
});
} | javascript | function matchSignature(list, arg) {
var types = arg.map(function(variable) {
return new RegExp('^(' + type(variable) + ')');
});
return list.filter(function(config) {
var variadic = false,
result;
// result is true if no more arguments are provided than the signature allows OR the last
// argument in the signature is variadic
result = arg.length <= config.arguments.length || (config.arguments[config.arguments.length - 1] && config.arguments[config.arguments.length - 1].type === '...');
// test each given argument agains the configured signatures
if (result) {
arg.forEach(function(value, index) {
var expect = config.arguments[index] ? config.arguments[index].type : null;
// look at ourself and ahead - if there is a following item, and it is variadic, it may be
// left out entirely (zero or more)
if (isTypeAtIndex('...', config.arguments, index)) {
variadic = true;
}
// the result remains valid as long as the values match the given signature
// (type matches or it is variadic)
result = result && (variadic || types[index].test(expect) || (expect[expect.length - 1] !== '!' && isExtendOf(expect, value)));
});
}
return result;
});
} | [
"function",
"matchSignature",
"(",
"list",
",",
"arg",
")",
"{",
"var",
"types",
"=",
"arg",
".",
"map",
"(",
"function",
"(",
"variable",
")",
"{",
"return",
"new",
"RegExp",
"(",
"'^('",
"+",
"type",
"(",
"variable",
")",
"+",
"')'",
")",
";",
"}... | Filter given list so only matching signatures are kept
@name matchSignature
@access internal
@param array candidates
@param array arguments
@return array filtered candidates | [
"Filter",
"given",
"list",
"so",
"only",
"matching",
"signatures",
"are",
"kept"
] | fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a | https://github.com/konfirm/node-polymorphic/blob/fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a/lib/polymorphic.js#L74-L106 |
32,140 | konfirm/node-polymorphic | lib/polymorphic.js | prepare | function prepare(list, arg) {
return list.map(function(config) {
var item = {
// the function to call
call: config.call,
// all configured arguments
arguments: config.arguments,
// the calculated specificity
specificity: config.arguments.map(function(argument, index) {
var value = 'value' in argument,
specificity = 0;
// if a argument not a variadic one and the value is specified
if (argument.type !== '...' && index < arg.length) {
++specificity;
// bonus points if the exact type matches (explicit by type)
// OR there is no default value (explicitly provided)
if (Number(argument.type === type(arg[index], true) || isExtendOf(argument.type, arg[index]) || !value)) {
++specificity;
}
// extra bonus points if the type is explicity the same (in case of inheritance)
if (new RegExp('^' + type(arg[index], true) + '!$').test(argument.type)){
++specificity;
}
}
return specificity;
}).join(''),
// the parameters with which the `call` may be executed
param: config.arguments.map(function(argument, index) {
var result = {};
result.name = argument.name;
// if a variadic type is encountered, the remainder of the given arguments becomes the value
if (argument.type === '...') {
result.value = arg.slice(index);
}
else if (index < arg.length && typeof arg[index] !== 'undefined' && arg[index] !== null) {
result.value = arg[index];
}
else if ('value' in argument) {
result.value = argument.value;
}
else if ('reference' in argument) {
result.reference = argument.reference;
}
return result;
})
};
return item;
});
} | javascript | function prepare(list, arg) {
return list.map(function(config) {
var item = {
// the function to call
call: config.call,
// all configured arguments
arguments: config.arguments,
// the calculated specificity
specificity: config.arguments.map(function(argument, index) {
var value = 'value' in argument,
specificity = 0;
// if a argument not a variadic one and the value is specified
if (argument.type !== '...' && index < arg.length) {
++specificity;
// bonus points if the exact type matches (explicit by type)
// OR there is no default value (explicitly provided)
if (Number(argument.type === type(arg[index], true) || isExtendOf(argument.type, arg[index]) || !value)) {
++specificity;
}
// extra bonus points if the type is explicity the same (in case of inheritance)
if (new RegExp('^' + type(arg[index], true) + '!$').test(argument.type)){
++specificity;
}
}
return specificity;
}).join(''),
// the parameters with which the `call` may be executed
param: config.arguments.map(function(argument, index) {
var result = {};
result.name = argument.name;
// if a variadic type is encountered, the remainder of the given arguments becomes the value
if (argument.type === '...') {
result.value = arg.slice(index);
}
else if (index < arg.length && typeof arg[index] !== 'undefined' && arg[index] !== null) {
result.value = arg[index];
}
else if ('value' in argument) {
result.value = argument.value;
}
else if ('reference' in argument) {
result.reference = argument.reference;
}
return result;
})
};
return item;
});
} | [
"function",
"prepare",
"(",
"list",
",",
"arg",
")",
"{",
"return",
"list",
".",
"map",
"(",
"function",
"(",
"config",
")",
"{",
"var",
"item",
"=",
"{",
"// the function to call",
"call",
":",
"config",
".",
"call",
",",
"// all configured arguments",
... | Map the registered values to a new object containing the specifics we use to determine the best
@name prepare
@access internal
@param array candidates
@param array arguments
@return array mapped candidates | [
"Map",
"the",
"registered",
"values",
"to",
"a",
"new",
"object",
"containing",
"the",
"specifics",
"we",
"use",
"to",
"determine",
"the",
"best"
] | fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a | https://github.com/konfirm/node-polymorphic/blob/fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a/lib/polymorphic.js#L116-L175 |
32,141 | konfirm/node-polymorphic | lib/polymorphic.js | prioritize | function prioritize(list, arg) {
return list.sort(function(a, b) {
var typing = function(item, index) {
return +(item.type === type(arg[index], true));
};
// if the calculated specificity is not equal it has precedence
if (a.specificity !== b.specificity) {
// the shortest specificity OR ELSE the highest specificity wins
return a.specificity.length - b.specificity.length || b.specificity - a.specificity;
}
// if the specificity is equal, we want to prioritize on the more explicit types
return b.arguments.map(typing).join('') - a.arguments.map(typing).join('');
});
} | javascript | function prioritize(list, arg) {
return list.sort(function(a, b) {
var typing = function(item, index) {
return +(item.type === type(arg[index], true));
};
// if the calculated specificity is not equal it has precedence
if (a.specificity !== b.specificity) {
// the shortest specificity OR ELSE the highest specificity wins
return a.specificity.length - b.specificity.length || b.specificity - a.specificity;
}
// if the specificity is equal, we want to prioritize on the more explicit types
return b.arguments.map(typing).join('') - a.arguments.map(typing).join('');
});
} | [
"function",
"prioritize",
"(",
"list",
",",
"arg",
")",
"{",
"return",
"list",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"var",
"typing",
"=",
"function",
"(",
"item",
",",
"index",
")",
"{",
"return",
"+",
"(",
"item",
".",
"ty... | Prioritize the items in the list
@name prepare
@access internal
@param array candidates
@param array arguments
@return array prioritized candidates
@note the list should contain pre-mapped items (as it works on specificity mostly) | [
"Prioritize",
"the",
"items",
"in",
"the",
"list"
] | fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a | https://github.com/konfirm/node-polymorphic/blob/fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a/lib/polymorphic.js#L186-L201 |
32,142 | konfirm/node-polymorphic | lib/polymorphic.js | isTypeAtIndex | function isTypeAtIndex(type, list, index) {
return list.length > index && 'type' in list[index] ? list[index].type === type : false;
} | javascript | function isTypeAtIndex(type, list, index) {
return list.length > index && 'type' in list[index] ? list[index].type === type : false;
} | [
"function",
"isTypeAtIndex",
"(",
"type",
",",
"list",
",",
"index",
")",
"{",
"return",
"list",
".",
"length",
">",
"index",
"&&",
"'type'",
"in",
"list",
"[",
"index",
"]",
"?",
"list",
"[",
"index",
"]",
".",
"type",
"===",
"type",
":",
"false",
... | Compare the type of the argument at a specific position within a collection
@name isTypeAtIndex
@access internal
@param string type
@param array arguments
@param int index
@return boolean type at index | [
"Compare",
"the",
"type",
"of",
"the",
"argument",
"at",
"a",
"specific",
"position",
"within",
"a",
"collection"
] | fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a | https://github.com/konfirm/node-polymorphic/blob/fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a/lib/polymorphic.js#L212-L214 |
32,143 | konfirm/node-polymorphic | lib/polymorphic.js | delegate | function delegate(arg) {
// create a list of possible candidates based on the given arguments
var candidate = matchSignature(registry, arg);
// prepare the configured signatures/arguments based on the arguments actually recieved
candidate = prepare(candidate, arg);
// prioritize the candidates
candidate = prioritize(candidate, arg);
// and finally, filter any candidate which does not fully comply with the signature based on the - now - parameters
candidate = candidate.filter(function(item) {
var variadic = false,
min = item.arguments.map(function(argument, index) {
variadic = isTypeAtIndex('...', item.arguments, index) || isTypeAtIndex('...', item.arguments, index + 1);
return +(!(variadic || 'value' in argument || 'reference' in argument));
}).join('').match(/^1+/);
return arg.length >= (min ? min[0].length : 0);
});
return candidate.length ? parameterize(candidate[0]) : false;
} | javascript | function delegate(arg) {
// create a list of possible candidates based on the given arguments
var candidate = matchSignature(registry, arg);
// prepare the configured signatures/arguments based on the arguments actually recieved
candidate = prepare(candidate, arg);
// prioritize the candidates
candidate = prioritize(candidate, arg);
// and finally, filter any candidate which does not fully comply with the signature based on the - now - parameters
candidate = candidate.filter(function(item) {
var variadic = false,
min = item.arguments.map(function(argument, index) {
variadic = isTypeAtIndex('...', item.arguments, index) || isTypeAtIndex('...', item.arguments, index + 1);
return +(!(variadic || 'value' in argument || 'reference' in argument));
}).join('').match(/^1+/);
return arg.length >= (min ? min[0].length : 0);
});
return candidate.length ? parameterize(candidate[0]) : false;
} | [
"function",
"delegate",
"(",
"arg",
")",
"{",
"// create a list of possible candidates based on the given arguments",
"var",
"candidate",
"=",
"matchSignature",
"(",
"registry",
",",
"arg",
")",
";",
"// prepare the configured signatures/arguments based on the arguments actually ... | Determine the proper delegate handler for given arguments
@name delegate
@access internal
@param array arguments
@return mixed handler result | [
"Determine",
"the",
"proper",
"delegate",
"handler",
"for",
"given",
"arguments"
] | fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a | https://github.com/konfirm/node-polymorphic/blob/fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a/lib/polymorphic.js#L223-L246 |
32,144 | konfirm/node-polymorphic | lib/polymorphic.js | cast | function cast(type, variable) {
var result = variable;
switch (type) {
case 'number':
result = +result;
break;
case 'int':
result = parseInt(result, 10);
break;
case 'float':
result = parseFloat(result);
break;
case 'bool':
case 'boolean':
result = ['true', '1', 1].indexOf(result) >= 0;
break;
}
return result;
} | javascript | function cast(type, variable) {
var result = variable;
switch (type) {
case 'number':
result = +result;
break;
case 'int':
result = parseInt(result, 10);
break;
case 'float':
result = parseFloat(result);
break;
case 'bool':
case 'boolean':
result = ['true', '1', 1].indexOf(result) >= 0;
break;
}
return result;
} | [
"function",
"cast",
"(",
"type",
",",
"variable",
")",
"{",
"var",
"result",
"=",
"variable",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"'number'",
":",
"result",
"=",
"+",
"result",
";",
"break",
";",
"case",
"'int'",
":",
"result",
"=",
"parseI... | Cast variable to given type
@name cast
@access internal
@param string type
@param string value
@return mixed value | [
"Cast",
"variable",
"to",
"given",
"type"
] | fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a | https://github.com/konfirm/node-polymorphic/blob/fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a/lib/polymorphic.js#L256-L279 |
32,145 | konfirm/node-polymorphic | lib/polymorphic.js | numberType | function numberType(type, variable, explicit) {
// if the integer value is identical to the float value, it is an integer
return (parseInt(variable, 10) === parseFloat(variable) ? 'int' : 'float') + (explicit ? '' : '|' + type);
} | javascript | function numberType(type, variable, explicit) {
// if the integer value is identical to the float value, it is an integer
return (parseInt(variable, 10) === parseFloat(variable) ? 'int' : 'float') + (explicit ? '' : '|' + type);
} | [
"function",
"numberType",
"(",
"type",
",",
"variable",
",",
"explicit",
")",
"{",
"// if the integer value is identical to the float value, it is an integer",
"return",
"(",
"parseInt",
"(",
"variable",
",",
"10",
")",
"===",
"parseFloat",
"(",
"variable",
")",
"?",... | Create a string matching various number types depending on given variable
@name numberType
@access internal
@param string type
@param number variable
@param bool explicit typing
@return string types | [
"Create",
"a",
"string",
"matching",
"various",
"number",
"types",
"depending",
"on",
"given",
"variable"
] | fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a | https://github.com/konfirm/node-polymorphic/blob/fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a/lib/polymorphic.js#L290-L293 |
32,146 | konfirm/node-polymorphic | lib/polymorphic.js | type | function type(variable, explicit) {
var result = typeof variable;
switch (result) {
case 'number':
result = numberType(result, variable, explicit);
break;
case 'object':
result = objectType(result, variable, explicit);
break;
case 'boolean':
result = booleanType(result, explicit);
break;
case 'undefined':
result = undefinedType(result, explicit);
break;
}
return result;
} | javascript | function type(variable, explicit) {
var result = typeof variable;
switch (result) {
case 'number':
result = numberType(result, variable, explicit);
break;
case 'object':
result = objectType(result, variable, explicit);
break;
case 'boolean':
result = booleanType(result, explicit);
break;
case 'undefined':
result = undefinedType(result, explicit);
break;
}
return result;
} | [
"function",
"type",
"(",
"variable",
",",
"explicit",
")",
"{",
"var",
"result",
"=",
"typeof",
"variable",
";",
"switch",
"(",
"result",
")",
"{",
"case",
"'number'",
":",
"result",
"=",
"numberType",
"(",
"result",
",",
"variable",
",",
"explicit",
")"... | Determine the type and create a string ready for use in regular expressions
@name type
@access internal
@param mixed variable
@param bool explicit
@return string type | [
"Determine",
"the",
"type",
"and",
"create",
"a",
"string",
"ready",
"for",
"use",
"in",
"regular",
"expressions"
] | fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a | https://github.com/konfirm/node-polymorphic/blob/fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a/lib/polymorphic.js#L346-L368 |
32,147 | konfirm/node-polymorphic | lib/polymorphic.js | prepareArgument | function prepareArgument(match, name) {
var result = {
type: match ? match[1] : false,
name: match ? match[2] : name
};
if (match) {
if (match[4] === '@') {
result.reference = match[5];
}
else if (match[3] === '=') {
result.value = cast(result.type, match[5]);
}
}
return result;
} | javascript | function prepareArgument(match, name) {
var result = {
type: match ? match[1] : false,
name: match ? match[2] : name
};
if (match) {
if (match[4] === '@') {
result.reference = match[5];
}
else if (match[3] === '=') {
result.value = cast(result.type, match[5]);
}
}
return result;
} | [
"function",
"prepareArgument",
"(",
"match",
",",
"name",
")",
"{",
"var",
"result",
"=",
"{",
"type",
":",
"match",
"?",
"match",
"[",
"1",
"]",
":",
"false",
",",
"name",
":",
"match",
"?",
"match",
"[",
"2",
"]",
":",
"name",
"}",
";",
"if",
... | Process the expression match result and prepare the argument object
@name prepareArgument
@access internal
@param RegExpMatch match
@param string defaultname
@result Object argument | [
"Process",
"the",
"expression",
"match",
"result",
"and",
"prepare",
"the",
"argument",
"object"
] | fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a | https://github.com/konfirm/node-polymorphic/blob/fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a/lib/polymorphic.js#L378-L394 |
32,148 | konfirm/node-polymorphic | lib/polymorphic.js | parse | function parse(signature) {
var pattern = /^(?:void|([a-zA-Z]+!?|\.{3})(?:[:\s]+([a-zA-Z]+)(?:(=)(@)?(.*))?)?)?$/;
return signature.split(/\s*,\s*/).map(function(argument, index, all) {
var result = prepareArgument(argument.match(pattern), 'var' + (index + 1));
if (result.type === false) {
throw new Error('polymorphic: invalid argument "' + argument + '" in signature "' + signature + '"');
}
else if (result.type === '...' && index < all.length - 1) {
throw new Error('polymorphic: variadic argument must be at end of signature "' + signature + '"');
}
return result;
}).filter(function(argument) {
// a type is undefined if it was declared as 'void' or '' (an empty string)
return argument.type !== undefined;
});
} | javascript | function parse(signature) {
var pattern = /^(?:void|([a-zA-Z]+!?|\.{3})(?:[:\s]+([a-zA-Z]+)(?:(=)(@)?(.*))?)?)?$/;
return signature.split(/\s*,\s*/).map(function(argument, index, all) {
var result = prepareArgument(argument.match(pattern), 'var' + (index + 1));
if (result.type === false) {
throw new Error('polymorphic: invalid argument "' + argument + '" in signature "' + signature + '"');
}
else if (result.type === '...' && index < all.length - 1) {
throw new Error('polymorphic: variadic argument must be at end of signature "' + signature + '"');
}
return result;
}).filter(function(argument) {
// a type is undefined if it was declared as 'void' or '' (an empty string)
return argument.type !== undefined;
});
} | [
"function",
"parse",
"(",
"signature",
")",
"{",
"var",
"pattern",
"=",
"/",
"^(?:void|([a-zA-Z]+!?|\\.{3})(?:[:\\s]+([a-zA-Z]+)(?:(=)(@)?(.*))?)?)?$",
"/",
";",
"return",
"signature",
".",
"split",
"(",
"/",
"\\s*,\\s*",
"/",
")",
".",
"map",
"(",
"function",
"("... | Parse given signature string and create an array containing all argument options for the signature
@name parse
@access internal
@param string signature
@return array options | [
"Parse",
"given",
"signature",
"string",
"and",
"create",
"an",
"array",
"containing",
"all",
"argument",
"options",
"for",
"the",
"signature"
] | fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a | https://github.com/konfirm/node-polymorphic/blob/fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a/lib/polymorphic.js#L403-L421 |
32,149 | konfirm/node-polymorphic | lib/polymorphic.js | polymorph | function polymorph() {
var arg = Array.prototype.slice.call(arguments),
candidate = delegate(arg);
if (!candidate) {
throw new Error('polymorph: signature not found "' + arg.map(function(variable) {
return type(variable);
}).join(', ') + '"');
}
return candidate.call.apply(this, candidate.param);
} | javascript | function polymorph() {
var arg = Array.prototype.slice.call(arguments),
candidate = delegate(arg);
if (!candidate) {
throw new Error('polymorph: signature not found "' + arg.map(function(variable) {
return type(variable);
}).join(', ') + '"');
}
return candidate.call.apply(this, candidate.param);
} | [
"function",
"polymorph",
"(",
")",
"{",
"var",
"arg",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
",",
"candidate",
"=",
"delegate",
"(",
"arg",
")",
";",
"if",
"(",
"!",
"candidate",
")",
"{",
"throw",
"new",
... | The main result function, this is the function actually being returned by `polymorphic`
@name result
@access internal
@param * [one or more arguments]
@return mixed handler result
@throws polymorph: signature not found "<resolved pattern>" | [
"The",
"main",
"result",
"function",
"this",
"is",
"the",
"function",
"actually",
"being",
"returned",
"by",
"polymorphic"
] | fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a | https://github.com/konfirm/node-polymorphic/blob/fa947c97d2c1ead9dcbb4e59fe0551bac3b2f33a/lib/polymorphic.js#L431-L442 |
32,150 | litixsoft/generator-baboon | app/templates/server/routes/index.js | getRouteFiles | function getRouteFiles (pathName) {
var items = fs.readdirSync(pathName);
var files = [];
items.forEach(function(itemName) {
var fullName = path.join(pathName, itemName);
var fsStat = fs.statSync(fullName);
// If directory, then scan for "routes.js"
if (fsStat.isDirectory()) {
getRouteFiles(fullName).forEach(function(a) {
files.push(a);
});
} else if (fsStat.isFile() && itemName === 'routes.js') {
// routes.js found, append to list
files.push(fullName);
}
});
return files;
} | javascript | function getRouteFiles (pathName) {
var items = fs.readdirSync(pathName);
var files = [];
items.forEach(function(itemName) {
var fullName = path.join(pathName, itemName);
var fsStat = fs.statSync(fullName);
// If directory, then scan for "routes.js"
if (fsStat.isDirectory()) {
getRouteFiles(fullName).forEach(function(a) {
files.push(a);
});
} else if (fsStat.isFile() && itemName === 'routes.js') {
// routes.js found, append to list
files.push(fullName);
}
});
return files;
} | [
"function",
"getRouteFiles",
"(",
"pathName",
")",
"{",
"var",
"items",
"=",
"fs",
".",
"readdirSync",
"(",
"pathName",
")",
";",
"var",
"files",
"=",
"[",
"]",
";",
"items",
".",
"forEach",
"(",
"function",
"(",
"itemName",
")",
"{",
"var",
"fullName"... | Returns all "routes.js" files in specified directory, including sub directory
@param {String} pathName
@returns {Array} | [
"Returns",
"all",
"routes",
".",
"js",
"files",
"in",
"specified",
"directory",
"including",
"sub",
"directory"
] | 37282a92f3c1d2945c01b5c4a45f9b11528e99a1 | https://github.com/litixsoft/generator-baboon/blob/37282a92f3c1d2945c01b5c4a45f9b11528e99a1/app/templates/server/routes/index.js#L12-L32 |
32,151 | MRN-Code/bookshelf-shield | lib/secureAccessMethods.js | applyRules | function applyRules(rules, model, user) {
const rulePromises = _.map(rules, (rule) => rule.applyTo(model, user));
return Promise.all(rulePromises)
//TODO validate rule results to handle optional vs. required auth...
.catch(function catchAuthError(error) {
return Promise.reject(error);
});
} | javascript | function applyRules(rules, model, user) {
const rulePromises = _.map(rules, (rule) => rule.applyTo(model, user));
return Promise.all(rulePromises)
//TODO validate rule results to handle optional vs. required auth...
.catch(function catchAuthError(error) {
return Promise.reject(error);
});
} | [
"function",
"applyRules",
"(",
"rules",
",",
"model",
",",
"user",
")",
"{",
"const",
"rulePromises",
"=",
"_",
".",
"map",
"(",
"rules",
",",
"(",
"rule",
")",
"=>",
"rule",
".",
"applyTo",
"(",
"model",
",",
"user",
")",
")",
";",
"return",
"Prom... | Iterate through rules and apply each one on the model and user
@param {array} rules is an array of Rule objects
@param {object} models is a bookshelf model instance
@param {object} user is the user credentials
@return {Promise} resolves to array of rule results,
or rejects with AuthorizationError. | [
"Iterate",
"through",
"rules",
"and",
"apply",
"each",
"one",
"on",
"the",
"model",
"and",
"user"
] | 4f13ed22e3f951b3e7733823841c7bf9ef88df0b | https://github.com/MRN-Code/bookshelf-shield/blob/4f13ed22e3f951b3e7733823841c7bf9ef88df0b/lib/secureAccessMethods.js#L14-L22 |
32,152 | MRN-Code/bookshelf-shield | lib/secureAccessMethods.js | readSecure | function readSecure(user, options) {
// jscs:disable
// jshint -W040
const self = this;
// jshint +W040
// jscs:enable
const shield = self.constructor.shield;
const action = 'read';
const rules = shield.getApplicableRules(action);
return shield._fetch.call(self, options)
.then(function runShieldRules(result) {
// TODO: investigate what happens if fetch returns nothing (err?)
return applyRules(rules, self, user)
.then(function resolveResult() {
return result;
});
});
} | javascript | function readSecure(user, options) {
// jscs:disable
// jshint -W040
const self = this;
// jshint +W040
// jscs:enable
const shield = self.constructor.shield;
const action = 'read';
const rules = shield.getApplicableRules(action);
return shield._fetch.call(self, options)
.then(function runShieldRules(result) {
// TODO: investigate what happens if fetch returns nothing (err?)
return applyRules(rules, self, user)
.then(function resolveResult() {
return result;
});
});
} | [
"function",
"readSecure",
"(",
"user",
",",
"options",
")",
"{",
"// jscs:disable",
"// jshint -W040",
"const",
"self",
"=",
"this",
";",
"// jshint +W040",
"// jscs:enable",
"const",
"shield",
"=",
"self",
".",
"constructor",
".",
"shield",
";",
"const",
"actio... | Fetch a record from DB, then verify permissions
@param {object} user is the user credentials
@param {object} options are options to be passed to destroy call
@return {Promise} resolves to fetch result or rejects with auth error | [
"Fetch",
"a",
"record",
"from",
"DB",
"then",
"verify",
"permissions"
] | 4f13ed22e3f951b3e7733823841c7bf9ef88df0b | https://github.com/MRN-Code/bookshelf-shield/blob/4f13ed22e3f951b3e7733823841c7bf9ef88df0b/lib/secureAccessMethods.js#L30-L47 |
32,153 | MRN-Code/bookshelf-shield | lib/secureAccessMethods.js | readAllSecure | function readAllSecure(user, options) {
// jscs:disable
// jshint -W040
const self = this;
// jshint +W040
// jscs:enable
const shield = self.constructor.shield;
const action = 'read';
const rules = shield.getApplicableRules(action);
return shield._fetchAll.call(self, options)
.then(function runShieldRules(collection) {
// TODO: investigate what happens if fetch returns nothing (err?)
return collection.mapThen((mdl) => applyRules(rules, mdl, user))
.then(function resolveResult() {
return collection;
});
});
} | javascript | function readAllSecure(user, options) {
// jscs:disable
// jshint -W040
const self = this;
// jshint +W040
// jscs:enable
const shield = self.constructor.shield;
const action = 'read';
const rules = shield.getApplicableRules(action);
return shield._fetchAll.call(self, options)
.then(function runShieldRules(collection) {
// TODO: investigate what happens if fetch returns nothing (err?)
return collection.mapThen((mdl) => applyRules(rules, mdl, user))
.then(function resolveResult() {
return collection;
});
});
} | [
"function",
"readAllSecure",
"(",
"user",
",",
"options",
")",
"{",
"// jscs:disable",
"// jshint -W040",
"const",
"self",
"=",
"this",
";",
"// jshint +W040",
"// jscs:enable",
"const",
"shield",
"=",
"self",
".",
"constructor",
".",
"shield",
";",
"const",
"ac... | Fetch All records from DB, then verify permissions
@param {object} user is the user credentials
@param {object} options are options to be passed to destroy call
@return {Promise} resolves to fetchAll result or rejects with auth error | [
"Fetch",
"All",
"records",
"from",
"DB",
"then",
"verify",
"permissions"
] | 4f13ed22e3f951b3e7733823841c7bf9ef88df0b | https://github.com/MRN-Code/bookshelf-shield/blob/4f13ed22e3f951b3e7733823841c7bf9ef88df0b/lib/secureAccessMethods.js#L55-L72 |
32,154 | MRN-Code/bookshelf-shield | lib/secureAccessMethods.js | deleteSecure | function deleteSecure(user, options) {
// jscs:disable
// jshint -W040
const self = this;
// jshint +W040
// jscs:enable
const Model = self.constructor;
const shield = Model.shield;
const action = 'delete';
const rules = shield.getApplicableRules(action);
const primaryKey = Model.idAttribute;
const query = {};
const tmpModel = Model.forge(query);
query[primaryKey] = self.get(primaryKey);
return tmpModel.read(user)
.then(function validateUpdatePrivs(originalModel) {
// TODO: investigate what happens if fetch returns nothing (err?)
return applyRules(rules, originalModel, user);
}).then(function executeUpdate() {
return shield._destroy.call(self, options);
});
} | javascript | function deleteSecure(user, options) {
// jscs:disable
// jshint -W040
const self = this;
// jshint +W040
// jscs:enable
const Model = self.constructor;
const shield = Model.shield;
const action = 'delete';
const rules = shield.getApplicableRules(action);
const primaryKey = Model.idAttribute;
const query = {};
const tmpModel = Model.forge(query);
query[primaryKey] = self.get(primaryKey);
return tmpModel.read(user)
.then(function validateUpdatePrivs(originalModel) {
// TODO: investigate what happens if fetch returns nothing (err?)
return applyRules(rules, originalModel, user);
}).then(function executeUpdate() {
return shield._destroy.call(self, options);
});
} | [
"function",
"deleteSecure",
"(",
"user",
",",
"options",
")",
"{",
"// jscs:disable",
"// jshint -W040",
"const",
"self",
"=",
"this",
";",
"// jshint +W040",
"// jscs:enable",
"const",
"Model",
"=",
"self",
".",
"constructor",
";",
"const",
"shield",
"=",
"Mode... | Delete a record in the db after verifying privs
Permissions are validated against the current record in DB
@param {object} user is the user credentials
@param {object} options are options to be passed to destroy call
@return {Promise} resolves to destroy result or rejects with auth error | [
"Delete",
"a",
"record",
"in",
"the",
"db",
"after",
"verifying",
"privs",
"Permissions",
"are",
"validated",
"against",
"the",
"current",
"record",
"in",
"DB"
] | 4f13ed22e3f951b3e7733823841c7bf9ef88df0b | https://github.com/MRN-Code/bookshelf-shield/blob/4f13ed22e3f951b3e7733823841c7bf9ef88df0b/lib/secureAccessMethods.js#L81-L102 |
32,155 | MRN-Code/bookshelf-shield | lib/secureAccessMethods.js | updateSecure | function updateSecure(user, options) {
// jscs:disable
// jshint -W040
const self = this;
// jshint +W040
// jscs:enable
const Model = self.constructor;
const shield = Model.shield;
const action = 'update';
const rules = shield.getApplicableRules(action);
const primaryKey = Model.idAttribute;
const query = {};
const tmpModel = Model.forge(query);
// validate that the model isNew
if (self.isNew()) {
return Promise.reject(
new AuthError('attempt to update a new record')
);
}
query[primaryKey] = self.get(primaryKey);
return tmpModel.read(user)
.then(function validateUpdatePrivs(originalModel) {
// TODO: investigate what happens if fetch returns nothing (err?)
return applyRules(rules, originalModel, user);
}).then(function executeUpdate() {
return shield._save.call(self, options);
});
} | javascript | function updateSecure(user, options) {
// jscs:disable
// jshint -W040
const self = this;
// jshint +W040
// jscs:enable
const Model = self.constructor;
const shield = Model.shield;
const action = 'update';
const rules = shield.getApplicableRules(action);
const primaryKey = Model.idAttribute;
const query = {};
const tmpModel = Model.forge(query);
// validate that the model isNew
if (self.isNew()) {
return Promise.reject(
new AuthError('attempt to update a new record')
);
}
query[primaryKey] = self.get(primaryKey);
return tmpModel.read(user)
.then(function validateUpdatePrivs(originalModel) {
// TODO: investigate what happens if fetch returns nothing (err?)
return applyRules(rules, originalModel, user);
}).then(function executeUpdate() {
return shield._save.call(self, options);
});
} | [
"function",
"updateSecure",
"(",
"user",
",",
"options",
")",
"{",
"// jscs:disable",
"// jshint -W040",
"const",
"self",
"=",
"this",
";",
"// jshint +W040",
"// jscs:enable",
"const",
"Model",
"=",
"self",
".",
"constructor",
";",
"const",
"shield",
"=",
"Mode... | update an existing record in DB after verifying privs
Permissions are validated against the current record in DB
@param {object} user is the user credentials
@param {object} options are options to be passed to save call
@return {Promise} resolves to save result or rejects with auth error | [
"update",
"an",
"existing",
"record",
"in",
"DB",
"after",
"verifying",
"privs",
"Permissions",
"are",
"validated",
"against",
"the",
"current",
"record",
"in",
"DB"
] | 4f13ed22e3f951b3e7733823841c7bf9ef88df0b | https://github.com/MRN-Code/bookshelf-shield/blob/4f13ed22e3f951b3e7733823841c7bf9ef88df0b/lib/secureAccessMethods.js#L111-L140 |
32,156 | MRN-Code/bookshelf-shield | lib/secureAccessMethods.js | createSecure | function createSecure(user, options) {
// jscs:disable
// jshint -W040
const self = this;
// jshint +W040
// jscs:enable
let shield;
let action;
let rules;
// validate that the model isNew
if (!self.isNew()) {
return Promise.reject(
new AuthError('attempt to create a record that exists')
);
}
// assign vars
shield = self.constructor.shield;
action = 'create';
rules = shield.getApplicableRules(action);
// run authorization, then perform save
return applyRules(rules, self, user)
.then(function executeSave() {
return shield._save.call(self, options);
});
} | javascript | function createSecure(user, options) {
// jscs:disable
// jshint -W040
const self = this;
// jshint +W040
// jscs:enable
let shield;
let action;
let rules;
// validate that the model isNew
if (!self.isNew()) {
return Promise.reject(
new AuthError('attempt to create a record that exists')
);
}
// assign vars
shield = self.constructor.shield;
action = 'create';
rules = shield.getApplicableRules(action);
// run authorization, then perform save
return applyRules(rules, self, user)
.then(function executeSave() {
return shield._save.call(self, options);
});
} | [
"function",
"createSecure",
"(",
"user",
",",
"options",
")",
"{",
"// jscs:disable",
"// jshint -W040",
"const",
"self",
"=",
"this",
";",
"// jshint +W040",
"// jscs:enable",
"let",
"shield",
";",
"let",
"action",
";",
"let",
"rules",
";",
"// validate that the ... | create a new record in DB after verifying privs
@param {object} user is the user credentials
@param {object} options are options to be passed to save call
@return {Promise} resolves to save result or rejects with auth error | [
"create",
"a",
"new",
"record",
"in",
"DB",
"after",
"verifying",
"privs"
] | 4f13ed22e3f951b3e7733823841c7bf9ef88df0b | https://github.com/MRN-Code/bookshelf-shield/blob/4f13ed22e3f951b3e7733823841c7bf9ef88df0b/lib/secureAccessMethods.js#L148-L175 |
32,157 | MRN-Code/bookshelf-shield | lib/secureAccessMethods.js | bypass | function bypass(method, options) {
// jscs:disable
// jshint -W040
const self = this;
// jshint +W040
// jscs:enable
const shield = self.constructor.shield;
if (!_.includes(shield.protectedMethods, method)) {
return Promise.reject(new Error('no such protected method'));
}
const protectedMethod = `_${method}`;
return shield[protectedMethod].call(self, options);
} | javascript | function bypass(method, options) {
// jscs:disable
// jshint -W040
const self = this;
// jshint +W040
// jscs:enable
const shield = self.constructor.shield;
if (!_.includes(shield.protectedMethods, method)) {
return Promise.reject(new Error('no such protected method'));
}
const protectedMethod = `_${method}`;
return shield[protectedMethod].call(self, options);
} | [
"function",
"bypass",
"(",
"method",
",",
"options",
")",
"{",
"// jscs:disable",
"// jshint -W040",
"const",
"self",
"=",
"this",
";",
"// jshint +W040",
"// jscs:enable",
"const",
"shield",
"=",
"self",
".",
"constructor",
".",
"shield",
";",
"if",
"(",
"!",... | allows a protected method to be called
@param {string} method protected method to call
@param {object} options options to call function with
@return {Promise} Promise that the called function returns | [
"allows",
"a",
"protected",
"method",
"to",
"be",
"called"
] | 4f13ed22e3f951b3e7733823841c7bf9ef88df0b | https://github.com/MRN-Code/bookshelf-shield/blob/4f13ed22e3f951b3e7733823841c7bf9ef88df0b/lib/secureAccessMethods.js#L183-L196 |
32,158 | Kronos-Integration/kronos-interceptor-object-data-processor-chunk | src/data-processor-chunk.js | addError | function addError(data, error) {
if (!data.error) {
data.error = [];
}
error.lineNumber = data.lineNumber;
data.error.push(error);
} | javascript | function addError(data, error) {
if (!data.error) {
data.error = [];
}
error.lineNumber = data.lineNumber;
data.error.push(error);
} | [
"function",
"addError",
"(",
"data",
",",
"error",
")",
"{",
"if",
"(",
"!",
"data",
".",
"error",
")",
"{",
"data",
".",
"error",
"=",
"[",
"]",
";",
"}",
"error",
".",
"lineNumber",
"=",
"data",
".",
"lineNumber",
";",
"data",
".",
"error",
"."... | Adds an error to the stream data
@param data The current stream data
@param error The error to be added. | [
"Adds",
"an",
"error",
"to",
"the",
"stream",
"data"
] | 0ec3db7982808835b123af1f7e212663e2e3a755 | https://github.com/Kronos-Integration/kronos-interceptor-object-data-processor-chunk/blob/0ec3db7982808835b123af1f7e212663e2e3a755/src/data-processor-chunk.js#L297-L303 |
32,159 | Kronos-Integration/kronos-interceptor-object-data-processor-chunk | src/data-processor-chunk.js | createTmpHashAction | function createTmpHashAction(contentHashFields, multiRowFields) {
let tmpHashFields = [];
// where there fields from the contentHashFields in the multiRowFields?
let fieldClash = false;
// add the original content hash fields to an new array
// but check that there are not in the multiRowFields.
for (let i = 0; i < contentHashFields.length; i++) {
let found = false;
for (let j = 0; j < multiRowFields.length; j++) {
if (contentHashFields[i] === multiRowFields[j]) {
found = true;
continue;
}
}
if (found) {
fieldClash = true;
} else {
tmpHashFields.push(contentHashFields[i]);
}
}
// now we have a new array
if (fieldClash) {
// only in this case we need a separate hash
return createHashFunction(tmpHashFields, TMP_HASH_FIELD_NAME);
} else {
// In this case we could use the normal content hash as the muti row fields where not included
return;
}
} | javascript | function createTmpHashAction(contentHashFields, multiRowFields) {
let tmpHashFields = [];
// where there fields from the contentHashFields in the multiRowFields?
let fieldClash = false;
// add the original content hash fields to an new array
// but check that there are not in the multiRowFields.
for (let i = 0; i < contentHashFields.length; i++) {
let found = false;
for (let j = 0; j < multiRowFields.length; j++) {
if (contentHashFields[i] === multiRowFields[j]) {
found = true;
continue;
}
}
if (found) {
fieldClash = true;
} else {
tmpHashFields.push(contentHashFields[i]);
}
}
// now we have a new array
if (fieldClash) {
// only in this case we need a separate hash
return createHashFunction(tmpHashFields, TMP_HASH_FIELD_NAME);
} else {
// In this case we could use the normal content hash as the muti row fields where not included
return;
}
} | [
"function",
"createTmpHashAction",
"(",
"contentHashFields",
",",
"multiRowFields",
")",
"{",
"let",
"tmpHashFields",
"=",
"[",
"]",
";",
"// where there fields from the contentHashFields in the multiRowFields?",
"let",
"fieldClash",
"=",
"false",
";",
"// add the original co... | Creates a hash function to compute a content hash without the multirow fields | [
"Creates",
"a",
"hash",
"function",
"to",
"compute",
"a",
"content",
"hash",
"without",
"the",
"multirow",
"fields"
] | 0ec3db7982808835b123af1f7e212663e2e3a755 | https://github.com/Kronos-Integration/kronos-interceptor-object-data-processor-chunk/blob/0ec3db7982808835b123af1f7e212663e2e3a755/src/data-processor-chunk.js#L309-L343 |
32,160 | bunnybones1/threejs-managed-view | src/RenderManager.js | RenderManager | function RenderManager(view) {
this.running = false;
this._frame = 0;
this.view = view;
this.skipFrames = 0;
this.skipFramesCounter = 0;
this.onEnterFrame = new signals.Signal();
this.onExitFrame = new signals.Signal();
this.render = this.render.bind(this);
this.renderLoop = this.renderLoop.bind(this);
} | javascript | function RenderManager(view) {
this.running = false;
this._frame = 0;
this.view = view;
this.skipFrames = 0;
this.skipFramesCounter = 0;
this.onEnterFrame = new signals.Signal();
this.onExitFrame = new signals.Signal();
this.render = this.render.bind(this);
this.renderLoop = this.renderLoop.bind(this);
} | [
"function",
"RenderManager",
"(",
"view",
")",
"{",
"this",
".",
"running",
"=",
"false",
";",
"this",
".",
"_frame",
"=",
"0",
";",
"this",
".",
"view",
"=",
"view",
";",
"this",
".",
"skipFrames",
"=",
"0",
";",
"this",
".",
"skipFramesCounter",
"=... | Manages render timing, pause and unpause
@param {View} view the view to manage | [
"Manages",
"render",
"timing",
"pause",
"and",
"unpause"
] | a082301458e8a17c998bdee287547ae67fc8e813 | https://github.com/bunnybones1/threejs-managed-view/blob/a082301458e8a17c998bdee287547ae67fc8e813/src/RenderManager.js#L7-L18 |
32,161 | canjs/can-diff | merge-deep/merge-deep.js | mergeMap | function mergeMap(instance, data) {
// for each key in
canReflect.eachKey(instance, function(value, prop) {
if(!canReflect.hasKey(data, prop)) {
canReflect.deleteKeyValue(instance, prop);
return;
}
var newValue = canReflect.getKeyValue(data, prop);
canReflect.deleteKeyValue(data, prop);
// cases:
// a. list
// b. map
// c. primitive
// if the data is typed, we would just replace it
if (canReflect.isPrimitive(value)) {
canReflect.setKeyValue(instance, prop, newValue);
return;
}
var newValueIsList = Array.isArray(newValue),
currentValueIsList = canReflect.isMoreListLikeThanMapLike(value);
if (currentValueIsList && newValueIsList) {
mergeList(value, newValue);
} else if (!newValueIsList && !currentValueIsList && canReflect.isMapLike(value) && canReflect.isPlainObject(newValue)) {
// TODO: the `TYPE` should probably be infered from the `_define` property definition.
var schema = canReflect.getSchema(value);
if (schema && schema.identity && schema.identity.length) {
var id = canReflect.getIdentity(value, schema);
if (id != null && id === canReflect.getIdentity(newValue, schema)) {
mergeMap(value, newValue);
return;
}
}
canReflect.setKeyValue(instance, prop, canReflect.new(value.constructor, newValue));
} else {
canReflect.setKeyValue(instance, prop, newValue);
}
});
canReflect.eachKey(data, function(value, prop) {
canReflect.setKeyValue(instance, prop, value);
});
} | javascript | function mergeMap(instance, data) {
// for each key in
canReflect.eachKey(instance, function(value, prop) {
if(!canReflect.hasKey(data, prop)) {
canReflect.deleteKeyValue(instance, prop);
return;
}
var newValue = canReflect.getKeyValue(data, prop);
canReflect.deleteKeyValue(data, prop);
// cases:
// a. list
// b. map
// c. primitive
// if the data is typed, we would just replace it
if (canReflect.isPrimitive(value)) {
canReflect.setKeyValue(instance, prop, newValue);
return;
}
var newValueIsList = Array.isArray(newValue),
currentValueIsList = canReflect.isMoreListLikeThanMapLike(value);
if (currentValueIsList && newValueIsList) {
mergeList(value, newValue);
} else if (!newValueIsList && !currentValueIsList && canReflect.isMapLike(value) && canReflect.isPlainObject(newValue)) {
// TODO: the `TYPE` should probably be infered from the `_define` property definition.
var schema = canReflect.getSchema(value);
if (schema && schema.identity && schema.identity.length) {
var id = canReflect.getIdentity(value, schema);
if (id != null && id === canReflect.getIdentity(newValue, schema)) {
mergeMap(value, newValue);
return;
}
}
canReflect.setKeyValue(instance, prop, canReflect.new(value.constructor, newValue));
} else {
canReflect.setKeyValue(instance, prop, newValue);
}
});
canReflect.eachKey(data, function(value, prop) {
canReflect.setKeyValue(instance, prop, value);
});
} | [
"function",
"mergeMap",
"(",
"instance",
",",
"data",
")",
"{",
"// for each key in",
"canReflect",
".",
"eachKey",
"(",
"instance",
",",
"function",
"(",
"value",
",",
"prop",
")",
"{",
"if",
"(",
"!",
"canReflect",
".",
"hasKey",
"(",
"data",
",",
"pro... | date is expected to be mutable here | [
"date",
"is",
"expected",
"to",
"be",
"mutable",
"here"
] | 03f925eafcbd15e8b2ac7d7a7f46db0bde5a9023 | https://github.com/canjs/can-diff/blob/03f925eafcbd15e8b2ac7d7a7f46db0bde5a9023/merge-deep/merge-deep.js#L18-L67 |
32,162 | Xcraft-Inc/shellcraft.js | lib/command.js | Command | function Command(handler, options, desc) {
Command.super_.apply(this, [handler, options, desc]);
} | javascript | function Command(handler, options, desc) {
Command.super_.apply(this, [handler, options, desc]);
} | [
"function",
"Command",
"(",
"handler",
",",
"options",
",",
"desc",
")",
"{",
"Command",
".",
"super_",
".",
"apply",
"(",
"this",
",",
"[",
"handler",
",",
"options",
",",
"desc",
"]",
")",
";",
"}"
] | Command constructor. | [
"Command",
"constructor",
"."
] | ff23cf75212e871a18ec2f1791a6939af489e0fb | https://github.com/Xcraft-Inc/shellcraft.js/blob/ff23cf75212e871a18ec2f1791a6939af489e0fb/lib/command.js#L32-L34 |
32,163 | pex-gl/pex-io | loadJSON.js | loadJSON | function loadJSON (file, callback) {
loadText(file, function (err, data) {
if (err) {
callback(err, null)
} else {
var json = null
try {
json = JSON.parse(data)
} catch (e) {
return callback(e, null)
}
callback(null, json)
}
})
} | javascript | function loadJSON (file, callback) {
loadText(file, function (err, data) {
if (err) {
callback(err, null)
} else {
var json = null
try {
json = JSON.parse(data)
} catch (e) {
return callback(e, null)
}
callback(null, json)
}
})
} | [
"function",
"loadJSON",
"(",
"file",
",",
"callback",
")",
"{",
"loadText",
"(",
"file",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
",",
"null",
")",
"}",
"else",
"{",
"var",
"json",
"=... | Loads JSON data
@param {String} file - url addess (Browser) or file path (Plask)
@param {Function} callback - function(err, json) { }
@param {Error} callback.err - error if any or null
@param {String} callback.json - loaded JSON data | [
"Loads",
"JSON",
"data"
] | 58e730e2c0a20e3574627ecbc5b0d03f20019972 | https://github.com/pex-gl/pex-io/blob/58e730e2c0a20e3574627ecbc5b0d03f20019972/loadJSON.js#L11-L25 |
32,164 | containership/containership.api | handlers/v1/cluster.js | function(req, res, next) {
async.parallel({
applications: (fn) => {
const spy = { stash: {} };
applications.get(req, spy, () => {
if(spy.stash.code !== 200) {
return fn(new Error('Error getting applications.'));
}
return fn(null, spy.stash.body);
});
},
hosts: (fn) => {
const spy = { stash: {} };
hosts.get(req, spy, () => {
if(spy.stash.code !== 200) {
return fn(new Error('Error getting hosts.'));
}
return fn(null, spy.stash.body);
});
}
}, (err, results) => {
if(err) {
res.stash.code = 500;
return next();
}
res.stash.body = {
applications: results.applications,
hosts: results.hosts
};
res.stash.code = 200;
return next();
});
} | javascript | function(req, res, next) {
async.parallel({
applications: (fn) => {
const spy = { stash: {} };
applications.get(req, spy, () => {
if(spy.stash.code !== 200) {
return fn(new Error('Error getting applications.'));
}
return fn(null, spy.stash.body);
});
},
hosts: (fn) => {
const spy = { stash: {} };
hosts.get(req, spy, () => {
if(spy.stash.code !== 200) {
return fn(new Error('Error getting hosts.'));
}
return fn(null, spy.stash.body);
});
}
}, (err, results) => {
if(err) {
res.stash.code = 500;
return next();
}
res.stash.body = {
applications: results.applications,
hosts: results.hosts
};
res.stash.code = 200;
return next();
});
} | [
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"async",
".",
"parallel",
"(",
"{",
"applications",
":",
"(",
"fn",
")",
"=>",
"{",
"const",
"spy",
"=",
"{",
"stash",
":",
"{",
"}",
"}",
";",
"applications",
".",
"get",
"(",
"req",
"... | get hosts, applications, and other cluster stuff | [
"get",
"hosts",
"applications",
"and",
"other",
"cluster",
"stuff"
] | 555d30d3f49fdb1e6906a9198694ec96af9955e6 | https://github.com/containership/containership.api/blob/555d30d3f49fdb1e6906a9198694ec96af9955e6/handlers/v1/cluster.js#L40-L75 | |
32,165 | storj/service-error-types | index.js | HTTPError | function HTTPError(statusCode, message) {
if (!(this instanceof HTTPError)) {
return new HTTPError(statusCode, message);
}
assert(statusCode >= 400, 'Not a valid HTTP error code');
this.statusCode = statusCode;
this.code = statusCode;
this.message = message || defaultMessage;
} | javascript | function HTTPError(statusCode, message) {
if (!(this instanceof HTTPError)) {
return new HTTPError(statusCode, message);
}
assert(statusCode >= 400, 'Not a valid HTTP error code');
this.statusCode = statusCode;
this.code = statusCode;
this.message = message || defaultMessage;
} | [
"function",
"HTTPError",
"(",
"statusCode",
",",
"message",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"HTTPError",
")",
")",
"{",
"return",
"new",
"HTTPError",
"(",
"statusCode",
",",
"message",
")",
";",
"}",
"assert",
"(",
"statusCode",
">="... | Error constructor for creating error objects with a given status code
@param {Number} statusCode - The HTTP status code
@param {String} message - The default error message | [
"Error",
"constructor",
"for",
"creating",
"error",
"objects",
"with",
"a",
"given",
"status",
"code"
] | a71648e0ffe4d2d29149feec0882f53bccd9105a | https://github.com/storj/service-error-types/blob/a71648e0ffe4d2d29149feec0882f53bccd9105a/index.js#L16-L26 |
32,166 | zipscene/common-schema | lib/map.js | map | function map(schema, valueSchema) {
if (!objtools.isPlainObject(schema)) {
valueSchema = schema;
schema = {};
}
schema.type = 'map';
schema.values = valueSchema;
return schema;
} | javascript | function map(schema, valueSchema) {
if (!objtools.isPlainObject(schema)) {
valueSchema = schema;
schema = {};
}
schema.type = 'map';
schema.values = valueSchema;
return schema;
} | [
"function",
"map",
"(",
"schema",
",",
"valueSchema",
")",
"{",
"if",
"(",
"!",
"objtools",
".",
"isPlainObject",
"(",
"schema",
")",
")",
"{",
"valueSchema",
"=",
"schema",
";",
"schema",
"=",
"{",
"}",
";",
"}",
"schema",
".",
"type",
"=",
"'map'",... | Generates a subschema that's a map type.
```js
createSchema({
// Required map from string (all keys are strings) to number
foo: map({ required: true }, Number)
})
```
@method map
@param {Object} schema - Schema params or empty object. This can be left out if the first
arg isn't an object.
@param {Mixed} valueSchema - Schema for values
@return {Object} The `map` type subschema. | [
"Generates",
"a",
"subschema",
"that",
"s",
"a",
"map",
"type",
"."
] | 857c53faf18536199bddb5f162fc7f2ab7c035f8 | https://github.com/zipscene/common-schema/blob/857c53faf18536199bddb5f162fc7f2ab7c035f8/lib/map.js#L23-L31 |
32,167 | FBDY/bb-blocks | blocks_vertical/motion.js | function() {
this.jsonInit({
"message0": "%1",
"args0": [
{
"type": "field_dropdown",
"name": "ON",
"options": [
[Blockly.Msg.MOTION_IFON_EDGE, '_edge_'],
[Blockly.Msg.MOTION_IFON_POINTER, '_mouse_'],
]
}
],
"colour": Blockly.Colours.motion.secondary,
"colourSecondary": Blockly.Colours.motion.secondary,
"colourTertiary": Blockly.Colours.motion.tertiary,
"extensions": ["output_string"]
});
} | javascript | function() {
this.jsonInit({
"message0": "%1",
"args0": [
{
"type": "field_dropdown",
"name": "ON",
"options": [
[Blockly.Msg.MOTION_IFON_EDGE, '_edge_'],
[Blockly.Msg.MOTION_IFON_POINTER, '_mouse_'],
]
}
],
"colour": Blockly.Colours.motion.secondary,
"colourSecondary": Blockly.Colours.motion.secondary,
"colourTertiary": Blockly.Colours.motion.tertiary,
"extensions": ["output_string"]
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"jsonInit",
"(",
"{",
"\"message0\"",
":",
"\"%1\"",
",",
"\"args0\"",
":",
"[",
"{",
"\"type\"",
":",
"\"field_dropdown\"",
",",
"\"name\"",
":",
"\"ON\"",
",",
"\"options\"",
":",
"[",
"[",
"Blockly",
".",
"Msg",... | If on X, bounce block menu.
@this Blockly.Block | [
"If",
"on",
"X",
"bounce",
"block",
"menu",
"."
] | 748cb75966a730f13134bba4e76690793b042675 | https://github.com/FBDY/bb-blocks/blob/748cb75966a730f13134bba4e76690793b042675/blocks_vertical/motion.js#L402-L420 | |
32,168 | CyberAgent/beezlib | lib/css/stylus.js | function (src, dst, config, headers, callback) {
if (_.isFunction(headers)) {
callback = headers;
headers = undefined;
}
var options = config.options;
if (!fsys.isFileSync(src)) {
return callback(new Error('source file not found. path:', src));
}
_.defaults(options || (options = {}), DEFAULT_OPTIONS);
var encode = options.encode;
var compress = options.compress;
var firebug = options.firebug;
var linenos = options.linenos;
var urlopt = options.url;
var raw = fs.readFileSync(src, encode);
var styl = stylus(raw)
.set('filename', dst)
.set('compress', compress)
.set('firebug', firebug)
.set('linenos', linenos)
.define('b64', stylus.url(urlopt))
;
if (options.nib) { // use nib library
styl.use(nib());
}
// extend options
if (config.hasOwnProperty('extend') && headers && common.isUAOverride(config, headers) && config.extend.hasOwnProperty('content')) {
options = obj.copy(config.extend.content, config).options;
logger.debug('Override stylus options:', options);
}
// define functions and constant values
if (options.fn && Object.keys(options.fn).length) {
styl.use(function (styl) {
_.each(options.fn, function (fn, name) {
if (_.isFunction(fn)) {
styl.define(name, function (data) {
return fn(data && data.val);
});
} else {
styl.define(name, function () {
return fn;
});
}
});
});
}
styl.render(function (err, css) {
err && callback(err, css);
fs.writeFileSync(dst, css, encode);
callback(null, css);
});
} | javascript | function (src, dst, config, headers, callback) {
if (_.isFunction(headers)) {
callback = headers;
headers = undefined;
}
var options = config.options;
if (!fsys.isFileSync(src)) {
return callback(new Error('source file not found. path:', src));
}
_.defaults(options || (options = {}), DEFAULT_OPTIONS);
var encode = options.encode;
var compress = options.compress;
var firebug = options.firebug;
var linenos = options.linenos;
var urlopt = options.url;
var raw = fs.readFileSync(src, encode);
var styl = stylus(raw)
.set('filename', dst)
.set('compress', compress)
.set('firebug', firebug)
.set('linenos', linenos)
.define('b64', stylus.url(urlopt))
;
if (options.nib) { // use nib library
styl.use(nib());
}
// extend options
if (config.hasOwnProperty('extend') && headers && common.isUAOverride(config, headers) && config.extend.hasOwnProperty('content')) {
options = obj.copy(config.extend.content, config).options;
logger.debug('Override stylus options:', options);
}
// define functions and constant values
if (options.fn && Object.keys(options.fn).length) {
styl.use(function (styl) {
_.each(options.fn, function (fn, name) {
if (_.isFunction(fn)) {
styl.define(name, function (data) {
return fn(data && data.val);
});
} else {
styl.define(name, function () {
return fn;
});
}
});
});
}
styl.render(function (err, css) {
err && callback(err, css);
fs.writeFileSync(dst, css, encode);
callback(null, css);
});
} | [
"function",
"(",
"src",
",",
"dst",
",",
"config",
",",
"headers",
",",
"callback",
")",
"{",
"if",
"(",
"_",
".",
"isFunction",
"(",
"headers",
")",
")",
"{",
"callback",
"=",
"headers",
";",
"headers",
"=",
"undefined",
";",
"}",
"var",
"options",
... | Compile the stylus file, and save it to a file.
@name write
@memberof stylus
@method
@param {String} src Stylus target file(formt: stylus)
@param {String} dst CSS file to be saved
@param {Object} options stylus options
@param {function} callback
@example
beezlib.css.stylus.write('./test.styl', './test.css', {
options: {
compress: true,
firebug: false,
linenos: false,
nib: true,
fn : function (styl) {
styl.define('body-padding', function (data) {
var rate = data.val || 1;
var base = 10;
return (rate * base) + 'px';
});
}
},
{
extend: {
"condition": {
"ua": [ "android", "ios" ]
},
"content": {
"options": {
"fn": {
"STAT_URL": "http://stat.example.com"
}
}
}
}
}
}, function (err, css) {
if (err) {
throw err;
}
console.log(css)
}); | [
"Compile",
"the",
"stylus",
"file",
"and",
"save",
"it",
"to",
"a",
"file",
"."
] | 1fda067ccc2d07e06ebc7ea7e500e94f21e0080f | https://github.com/CyberAgent/beezlib/blob/1fda067ccc2d07e06ebc7ea7e500e94f21e0080f/lib/css/stylus.js#L76-L140 | |
32,169 | kevinoid/stream-compare | lib/make-incremental.js | incrementalProp | function incrementalProp(state1, state2, propName, compare) {
const values1 = state1[propName];
const values2 = state2[propName];
let result;
// Note: Values may be undefined if no data was read.
if (((values1 && values1.length !== 0) || state1.ended)
&& ((values2 && values2.length !== 0) || state2.ended)) {
const minLen = Math.min(
values1 ? values1.length : 0,
values2 ? values2.length : 0
);
if ((values1 && values1.length > minLen) && !state2.ended) {
result = compare(values1.slice(0, minLen), values2);
} else if ((values2 && values2.length > minLen) && !state1.ended) {
result = compare(values1, values2.slice(0, minLen));
} else {
result = compare(values1, values2);
}
if (minLen > 0 && (result === null || result === undefined)) {
state1[propName] = values1.slice(minLen);
state2[propName] = values2.slice(minLen);
}
}
return result;
} | javascript | function incrementalProp(state1, state2, propName, compare) {
const values1 = state1[propName];
const values2 = state2[propName];
let result;
// Note: Values may be undefined if no data was read.
if (((values1 && values1.length !== 0) || state1.ended)
&& ((values2 && values2.length !== 0) || state2.ended)) {
const minLen = Math.min(
values1 ? values1.length : 0,
values2 ? values2.length : 0
);
if ((values1 && values1.length > minLen) && !state2.ended) {
result = compare(values1.slice(0, minLen), values2);
} else if ((values2 && values2.length > minLen) && !state1.ended) {
result = compare(values1, values2.slice(0, minLen));
} else {
result = compare(values1, values2);
}
if (minLen > 0 && (result === null || result === undefined)) {
state1[propName] = values1.slice(minLen);
state2[propName] = values2.slice(minLen);
}
}
return result;
} | [
"function",
"incrementalProp",
"(",
"state1",
",",
"state2",
",",
"propName",
",",
"compare",
")",
"{",
"const",
"values1",
"=",
"state1",
"[",
"propName",
"]",
";",
"const",
"values2",
"=",
"state2",
"[",
"propName",
"]",
";",
"let",
"result",
";",
"// ... | Incrementally compares and reduces an Array-like property of the states
using a given comparison function.
@ template CompareResult
@param {!StreamState} state1 First state to compare.
@param {!StreamState} state2 Second state to compare.
@param {string} propName Name of Array-like property to compare.
@param {function(*, *): CompareResult} compare Comparison function to apply
to the <code>propName</code> values from each state.
@return {CompareResult} Result of comparing <code>propName</code> values, up
to the minimum common length.
@private | [
"Incrementally",
"compares",
"and",
"reduces",
"an",
"Array",
"-",
"like",
"property",
"of",
"the",
"states",
"using",
"a",
"given",
"comparison",
"function",
"."
] | 37cea4249b827151533024e79eca707f2a37c7c5 | https://github.com/kevinoid/stream-compare/blob/37cea4249b827151533024e79eca707f2a37c7c5/lib/make-incremental.js#L21-L49 |
32,170 | Hairfie/fluxible-plugin-cookie | index.js | function (context) {
context.setCookie = function (name, value, options) {
var cookieStr = cookie.serialize(name, value, options);
if (res) {
var header = res.getHeader('Set-Cookie') || [];
if (!Array.isArray(header)) {
header = [header];
}
header.push(cookieStr);
res.setHeader('Set-Cookie', header);
} else {
document.cookie = cookieStr;
}
cookies[name] = value;
};
context.clearCookie = function (name, options) {
context.setCookie(name, "", merge({ expires: new Date(1), path: '/' }, options));
delete cookies[name];
};
context.getCookie = function (name) {
return cookies[name];
};
} | javascript | function (context) {
context.setCookie = function (name, value, options) {
var cookieStr = cookie.serialize(name, value, options);
if (res) {
var header = res.getHeader('Set-Cookie') || [];
if (!Array.isArray(header)) {
header = [header];
}
header.push(cookieStr);
res.setHeader('Set-Cookie', header);
} else {
document.cookie = cookieStr;
}
cookies[name] = value;
};
context.clearCookie = function (name, options) {
context.setCookie(name, "", merge({ expires: new Date(1), path: '/' }, options));
delete cookies[name];
};
context.getCookie = function (name) {
return cookies[name];
};
} | [
"function",
"(",
"context",
")",
"{",
"context",
".",
"setCookie",
"=",
"function",
"(",
"name",
",",
"value",
",",
"options",
")",
"{",
"var",
"cookieStr",
"=",
"cookie",
".",
"serialize",
"(",
"name",
",",
"value",
",",
"options",
")",
";",
"if",
"... | give all context types access to cookies | [
"give",
"all",
"context",
"types",
"access",
"to",
"cookies"
] | b4d9b8d14dbc81e69ea4be871d64a6c4d0b67502 | https://github.com/Hairfie/fluxible-plugin-cookie/blob/b4d9b8d14dbc81e69ea4be871d64a6c4d0b67502/index.js#L16-L39 | |
32,171 | canjs/can-diff | patcher/patcher.js | onList | function onList(newList) {
var current = this.currentList || [];
newList = newList || [];
if (current[offPatchesSymbol]) {
current[offPatchesSymbol](this.onPatchesNotify, "notify");
}
var patches = diff(current, newList);
this.currentList = newList;
this.onPatchesNotify(patches);
if (newList[onPatchesSymbol]) {
// If observable, set up bindings on list changes
newList[onPatchesSymbol](this.onPatchesNotify, "notify");
}
} | javascript | function onList(newList) {
var current = this.currentList || [];
newList = newList || [];
if (current[offPatchesSymbol]) {
current[offPatchesSymbol](this.onPatchesNotify, "notify");
}
var patches = diff(current, newList);
this.currentList = newList;
this.onPatchesNotify(patches);
if (newList[onPatchesSymbol]) {
// If observable, set up bindings on list changes
newList[onPatchesSymbol](this.onPatchesNotify, "notify");
}
} | [
"function",
"onList",
"(",
"newList",
")",
"{",
"var",
"current",
"=",
"this",
".",
"currentList",
"||",
"[",
"]",
";",
"newList",
"=",
"newList",
"||",
"[",
"]",
";",
"if",
"(",
"current",
"[",
"offPatchesSymbol",
"]",
")",
"{",
"current",
"[",
"off... | when the list changes, teardown the old list bindings and setup the new list | [
"when",
"the",
"list",
"changes",
"teardown",
"the",
"old",
"list",
"bindings",
"and",
"setup",
"the",
"new",
"list"
] | 03f925eafcbd15e8b2ac7d7a7f46db0bde5a9023 | https://github.com/canjs/can-diff/blob/03f925eafcbd15e8b2ac7d7a7f46db0bde5a9023/patcher/patcher.js#L112-L125 |
32,172 | canjs/can-diff | patcher/patcher.js | onPatchesNotify | function onPatchesNotify(patches) {
// we are going to collect all patches
this.patches.push.apply(this.patches, patches);
// TODO: share priority
queues.deriveQueue.enqueue(this.onPatchesDerive, this, [], {
priority: this.priority
});
} | javascript | function onPatchesNotify(patches) {
// we are going to collect all patches
this.patches.push.apply(this.patches, patches);
// TODO: share priority
queues.deriveQueue.enqueue(this.onPatchesDerive, this, [], {
priority: this.priority
});
} | [
"function",
"onPatchesNotify",
"(",
"patches",
")",
"{",
"// we are going to collect all patches",
"this",
".",
"patches",
".",
"push",
".",
"apply",
"(",
"this",
".",
"patches",
",",
"patches",
")",
";",
"// TODO: share priority",
"queues",
".",
"deriveQueue",
".... | This is when we get notified of patches on the underlying list. Save the patches and queue up a `derive` task that will call `domUI` updates. | [
"This",
"is",
"when",
"we",
"get",
"notified",
"of",
"patches",
"on",
"the",
"underlying",
"list",
".",
"Save",
"the",
"patches",
"and",
"queue",
"up",
"a",
"derive",
"task",
"that",
"will",
"call",
"domUI",
"updates",
"."
] | 03f925eafcbd15e8b2ac7d7a7f46db0bde5a9023 | https://github.com/canjs/can-diff/blob/03f925eafcbd15e8b2ac7d7a7f46db0bde5a9023/patcher/patcher.js#L129-L136 |
32,173 | hammy2899/o | src/clean.js | clean | function clean(object, follow = false) {
// check if object is an object
if (is(object) && !empty(object)) {
// clone the object to use as the result and
// so it is immutable
let result = clone(object);
// if follow is true flatten the object keys so
// its easy to get the path to delete and so
// it's easy to check if values are null/undefined
// if follow is false it will just be the base
// object therefore it will only check the base keys
const keysObject = follow
? deflate(object)
: object;
// loop over the keys of the object
Object.keys(keysObject).forEach((key) => {
// get the value of the current key
const value = keysObject[key];
// if the value is undefined or null
if (value === undefined || value === null) {
// delete the key/value from the object
result = del(result, key);
}
});
// return the result
return result;
}
// if the object isn't an object or is empty return
// an empty object this will keep the return immutable
return {};
} | javascript | function clean(object, follow = false) {
// check if object is an object
if (is(object) && !empty(object)) {
// clone the object to use as the result and
// so it is immutable
let result = clone(object);
// if follow is true flatten the object keys so
// its easy to get the path to delete and so
// it's easy to check if values are null/undefined
// if follow is false it will just be the base
// object therefore it will only check the base keys
const keysObject = follow
? deflate(object)
: object;
// loop over the keys of the object
Object.keys(keysObject).forEach((key) => {
// get the value of the current key
const value = keysObject[key];
// if the value is undefined or null
if (value === undefined || value === null) {
// delete the key/value from the object
result = del(result, key);
}
});
// return the result
return result;
}
// if the object isn't an object or is empty return
// an empty object this will keep the return immutable
return {};
} | [
"function",
"clean",
"(",
"object",
",",
"follow",
"=",
"false",
")",
"{",
"// check if object is an object",
"if",
"(",
"is",
"(",
"object",
")",
"&&",
"!",
"empty",
"(",
"object",
")",
")",
"{",
"// clone the object to use as the result and",
"// so it is immuta... | Remove `null` and `undefined` values from the specified object
@example
const a = { a: 1, b: undefined, c: null };
clean(a); // => { a: 1 }
@since 1.0.0
@version 1.0.0
@param {object} object The object to clean
@param {boolean} [follow=false] Whether to follow objects
@returns {object} The clean object | [
"Remove",
"null",
"and",
"undefined",
"values",
"from",
"the",
"specified",
"object"
] | 666c9faa36586c0bcdecc0f2a7e1f069a7a3ce54 | https://github.com/hammy2899/o/blob/666c9faa36586c0bcdecc0f2a7e1f069a7a3ce54/src/clean.js#L23-L58 |
32,174 | bunnybones1/threejs-managed-view | src/View.js | function(id) {
var canvasContainer = document.createElement("div");
canvasContainer.id = id;
canvasContainer.width = window.innerWidth;
canvasContainer.height = window.innerHeight;
this.addCanvasContainerToDOMBody(canvasContainer);
this.setDOMMode(canvasContainer, this.domMode);
return canvasContainer;
} | javascript | function(id) {
var canvasContainer = document.createElement("div");
canvasContainer.id = id;
canvasContainer.width = window.innerWidth;
canvasContainer.height = window.innerHeight;
this.addCanvasContainerToDOMBody(canvasContainer);
this.setDOMMode(canvasContainer, this.domMode);
return canvasContainer;
} | [
"function",
"(",
"id",
")",
"{",
"var",
"canvasContainer",
"=",
"document",
".",
"createElement",
"(",
"\"div\"",
")",
";",
"canvasContainer",
".",
"id",
"=",
"id",
";",
"canvasContainer",
".",
"width",
"=",
"window",
".",
"innerWidth",
";",
"canvasContainer... | Creates the canvas DOM Element and appends it to the document body
@return {CanvasElement} The newly created canvas element. | [
"Creates",
"the",
"canvas",
"DOM",
"Element",
"and",
"appends",
"it",
"to",
"the",
"document",
"body"
] | a082301458e8a17c998bdee287547ae67fc8e813 | https://github.com/bunnybones1/threejs-managed-view/blob/a082301458e8a17c998bdee287547ae67fc8e813/src/View.js#L110-L118 | |
32,175 | bunnybones1/threejs-managed-view | src/View.js | function(element, mode) {
var style = element.style;
switch(mode) {
case DOMMode.FULLSCREEN:
style.position = "fixed";
style.left = "0px";
style.top = "0px";
style.width = '100%';
style.height = '100%';
break;
case DOMMode.CONTAINER:
style.position = "absolute";
style.left = "0px";
style.top = "0px";
style.width = this.canvasContainer.clientWidth + 'px';
style.height = this.canvasContainer.clientHeight + 'px';
break;
default:
}
} | javascript | function(element, mode) {
var style = element.style;
switch(mode) {
case DOMMode.FULLSCREEN:
style.position = "fixed";
style.left = "0px";
style.top = "0px";
style.width = '100%';
style.height = '100%';
break;
case DOMMode.CONTAINER:
style.position = "absolute";
style.left = "0px";
style.top = "0px";
style.width = this.canvasContainer.clientWidth + 'px';
style.height = this.canvasContainer.clientHeight + 'px';
break;
default:
}
} | [
"function",
"(",
"element",
",",
"mode",
")",
"{",
"var",
"style",
"=",
"element",
".",
"style",
";",
"switch",
"(",
"mode",
")",
"{",
"case",
"DOMMode",
".",
"FULLSCREEN",
":",
"style",
".",
"position",
"=",
"\"fixed\"",
";",
"style",
".",
"left",
"... | sets the DOM Mode, which controls the css rules of the canvas element
@param {String} mode string, enumerated in DOMMode | [
"sets",
"the",
"DOM",
"Mode",
"which",
"controls",
"the",
"css",
"rules",
"of",
"the",
"canvas",
"element"
] | a082301458e8a17c998bdee287547ae67fc8e813 | https://github.com/bunnybones1/threejs-managed-view/blob/a082301458e8a17c998bdee287547ae67fc8e813/src/View.js#L152-L171 | |
32,176 | hammy2899/o | src/del.js | del | function del(object, path) {
// check if the object is an object and isn't empty
if (is(object) && !empty(object)) {
// clone the object
let cloned = clone(object);
// set the new value for the cloned object so we
// can manipulate it
const result = cloned;
// get the path parts
const pathParts = getPathParts(path);
// loop over all the path parts
for (let index = 0; index < pathParts.length; index += 1) {
// get the current key
const key = pathParts[index];
// check if the current path is the last key
if (index === pathParts.length - 1) {
// if it is the last key delete the value from the object
delete cloned[key];
}
// set the modified values to the object
cloned = cloned[key];
}
// return the result
return result;
}
// if the object isn't an object or is empty return
// an empty object this will keep the return immutable
return {};
} | javascript | function del(object, path) {
// check if the object is an object and isn't empty
if (is(object) && !empty(object)) {
// clone the object
let cloned = clone(object);
// set the new value for the cloned object so we
// can manipulate it
const result = cloned;
// get the path parts
const pathParts = getPathParts(path);
// loop over all the path parts
for (let index = 0; index < pathParts.length; index += 1) {
// get the current key
const key = pathParts[index];
// check if the current path is the last key
if (index === pathParts.length - 1) {
// if it is the last key delete the value from the object
delete cloned[key];
}
// set the modified values to the object
cloned = cloned[key];
}
// return the result
return result;
}
// if the object isn't an object or is empty return
// an empty object this will keep the return immutable
return {};
} | [
"function",
"del",
"(",
"object",
",",
"path",
")",
"{",
"// check if the object is an object and isn't empty",
"if",
"(",
"is",
"(",
"object",
")",
"&&",
"!",
"empty",
"(",
"object",
")",
")",
"{",
"// clone the object",
"let",
"cloned",
"=",
"clone",
"(",
... | Delete the specified path from the object
@example
const a = { a: 1, b: 2 };
del(a, 'b'); // => { a: 1 }
@since 1.0.0
@version 1.0.0
@param {object} object The object to delete from
@param {string} path The path to delete
@returns {object} The result object | [
"Delete",
"the",
"specified",
"path",
"from",
"the",
"object"
] | 666c9faa36586c0bcdecc0f2a7e1f069a7a3ce54 | https://github.com/hammy2899/o/blob/666c9faa36586c0bcdecc0f2a7e1f069a7a3ce54/src/del.js#L22-L57 |
32,177 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(e, ui) {
var dst = $(this),
targets = $.grep(ui.helper.data('files')||[], function(h) { return h? true : false; }),
result = [],
dups = [],
faults = [],
isCopy = ui.helper.hasClass('elfinder-drag-helper-plus'),
c = 'class',
cnt, hash, i, h;
if (typeof e.button === 'undefined' || ui.helper.data('namespace') !== namespace || ! self.insideWorkzone(e.pageX, e.pageY)) {
return false;
}
if (dst.hasClass(self.res(c, 'cwdfile'))) {
hash = self.cwdId2Hash(dst.attr('id'));
} else if (dst.hasClass(self.res(c, 'navdir'))) {
hash = self.navId2Hash(dst.attr('id'));
} else {
hash = cwd;
}
cnt = targets.length;
while (cnt--) {
h = targets[cnt];
// ignore drop into itself or in own location
if (h != hash && files[h].phash != hash) {
result.push(h);
} else {
((isCopy && h !== hash && files[hash].write)? dups : faults).push(h);
}
}
if (faults.length) {
return false;
}
ui.helper.data('droped', true);
if (dups.length) {
ui.helper.hide();
self.exec('duplicate', dups, {_userAction: true});
}
if (result.length) {
ui.helper.hide();
self.clipboard(result, !isCopy);
self.exec('paste', hash, {_userAction: true}, hash).always(function(){
self.clipboard([]);
self.trigger('unlockfiles', {files : targets});
});
self.trigger('drop', {files : targets});
}
} | javascript | function(e, ui) {
var dst = $(this),
targets = $.grep(ui.helper.data('files')||[], function(h) { return h? true : false; }),
result = [],
dups = [],
faults = [],
isCopy = ui.helper.hasClass('elfinder-drag-helper-plus'),
c = 'class',
cnt, hash, i, h;
if (typeof e.button === 'undefined' || ui.helper.data('namespace') !== namespace || ! self.insideWorkzone(e.pageX, e.pageY)) {
return false;
}
if (dst.hasClass(self.res(c, 'cwdfile'))) {
hash = self.cwdId2Hash(dst.attr('id'));
} else if (dst.hasClass(self.res(c, 'navdir'))) {
hash = self.navId2Hash(dst.attr('id'));
} else {
hash = cwd;
}
cnt = targets.length;
while (cnt--) {
h = targets[cnt];
// ignore drop into itself or in own location
if (h != hash && files[h].phash != hash) {
result.push(h);
} else {
((isCopy && h !== hash && files[hash].write)? dups : faults).push(h);
}
}
if (faults.length) {
return false;
}
ui.helper.data('droped', true);
if (dups.length) {
ui.helper.hide();
self.exec('duplicate', dups, {_userAction: true});
}
if (result.length) {
ui.helper.hide();
self.clipboard(result, !isCopy);
self.exec('paste', hash, {_userAction: true}, hash).always(function(){
self.clipboard([]);
self.trigger('unlockfiles', {files : targets});
});
self.trigger('drop', {files : targets});
}
} | [
"function",
"(",
"e",
",",
"ui",
")",
"{",
"var",
"dst",
"=",
"$",
"(",
"this",
")",
",",
"targets",
"=",
"$",
".",
"grep",
"(",
"ui",
".",
"helper",
".",
"data",
"(",
"'files'",
")",
"||",
"[",
"]",
",",
"function",
"(",
"h",
")",
"{",
"re... | elFinder original, see jquery.elfinder.js | [
"elFinder",
"original",
"see",
"jquery",
".",
"elfinder",
".",
"js"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L1278-L1331 | |
32,178 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function() {
var full;
if (node.hasClass(cls)) {
return node.get(0);
} else {
full = node.find('.' + cls);
if (full.length) {
return full.get(0);
}
}
return null;
} | javascript | function() {
var full;
if (node.hasClass(cls)) {
return node.get(0);
} else {
full = node.find('.' + cls);
if (full.length) {
return full.get(0);
}
}
return null;
} | [
"function",
"(",
")",
"{",
"var",
"full",
";",
"if",
"(",
"node",
".",
"hasClass",
"(",
"cls",
")",
")",
"{",
"return",
"node",
".",
"get",
"(",
"0",
")",
";",
"}",
"else",
"{",
"full",
"=",
"node",
".",
"find",
"(",
"'.'",
"+",
"cls",
")",
... | node element maximize mode | [
"node",
"element",
"maximize",
"mode"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L3451-L3462 | |
32,179 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(type, order, stickFolders, alsoTreeview) {
this.storage('sortType', (this.sortType = this.sortRules[type] ? type : 'name'));
this.storage('sortOrder', (this.sortOrder = /asc|desc/.test(order) ? order : 'asc'));
this.storage('sortStickFolders', (this.sortStickFolders = !!stickFolders) ? 1 : '');
this.storage('sortAlsoTreeview', (this.sortAlsoTreeview = !!alsoTreeview) ? 1 : '');
this.trigger('sortchange');
} | javascript | function(type, order, stickFolders, alsoTreeview) {
this.storage('sortType', (this.sortType = this.sortRules[type] ? type : 'name'));
this.storage('sortOrder', (this.sortOrder = /asc|desc/.test(order) ? order : 'asc'));
this.storage('sortStickFolders', (this.sortStickFolders = !!stickFolders) ? 1 : '');
this.storage('sortAlsoTreeview', (this.sortAlsoTreeview = !!alsoTreeview) ? 1 : '');
this.trigger('sortchange');
} | [
"function",
"(",
"type",
",",
"order",
",",
"stickFolders",
",",
"alsoTreeview",
")",
"{",
"this",
".",
"storage",
"(",
"'sortType'",
",",
"(",
"this",
".",
"sortType",
"=",
"this",
".",
"sortRules",
"[",
"type",
"]",
"?",
"type",
":",
"'name'",
")",
... | Update sort options
@param {String} sort type
@param {String} sort order
@param {Boolean} show folder first | [
"Update",
"sort",
"options"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L7519-L7525 | |
32,180 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(a, b) {
var self = elFinder.prototype.naturalCompare;
if (typeof self.loc == 'undefined') {
self.loc = (navigator.userLanguage || navigator.browserLanguage || navigator.language || 'en-US');
}
if (typeof self.sort == 'undefined') {
if ('11'.localeCompare('2', self.loc, {numeric: true}) > 0) {
// Native support
if (window.Intl && window.Intl.Collator) {
self.sort = new Intl.Collator(self.loc, {numeric: true}).compare;
} else {
self.sort = function(a, b) {
return a.localeCompare(b, self.loc, {numeric: true});
};
}
} else {
/*
* Edited for elFinder (emulates localeCompare() by numeric) by Naoki Sawada aka nao-pon
*/
/*
* Huddle/javascript-natural-sort (https://github.com/Huddle/javascript-natural-sort)
*/
/*
* Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
* Author: Jim Palmer (based on chunking idea from Dave Koelle)
* http://opensource.org/licenses/mit-license.php
*/
self.sort = function(a, b) {
var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,
sre = /(^[ ]*|[ ]*$)/g,
dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
hre = /^0x[0-9a-f]+$/i,
ore = /^0/,
syre = /^[\x01\x21-\x2f\x3a-\x40\x5b-\x60\x7b-\x7e]/, // symbol first - (Naoki Sawada)
i = function(s) { return self.sort.insensitive && (''+s).toLowerCase() || ''+s; },
// convert all to strings strip whitespace
// first character is "_", it's smallest - (Naoki Sawada)
x = i(a).replace(sre, '').replace(/^_/, "\x01") || '',
y = i(b).replace(sre, '').replace(/^_/, "\x01") || '',
// chunk/tokenize
xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
// numeric, hex or date detection
xD = parseInt(x.match(hre)) || (xN.length != 1 && x.match(dre) && Date.parse(x)),
yD = parseInt(y.match(hre)) || xD && y.match(dre) && Date.parse(y) || null,
oFxNcL, oFyNcL,
locRes = 0;
// first try and sort Hex codes or Dates
if (yD) {
if ( xD < yD ) return -1;
else if ( xD > yD ) return 1;
}
// natural sorting through split numeric strings and default strings
for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc++) {
// find floats not starting with '0', string or 0 if not defined (Clint Priest)
oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
// handle numeric vs string comparison - number < string - (Kyle Adams)
// but symbol first < number - (Naoki Sawada)
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) {
if (isNaN(oFxNcL) && (typeof oFxNcL !== 'string' || ! oFxNcL.match(syre))) {
return 1;
} else if (typeof oFyNcL !== 'string' || ! oFyNcL.match(syre)) {
return -1;
}
}
// use decimal number comparison if either value is string zero
if (parseInt(oFxNcL, 10) === 0) oFxNcL = 0;
if (parseInt(oFyNcL, 10) === 0) oFyNcL = 0;
// rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
if (typeof oFxNcL !== typeof oFyNcL) {
oFxNcL += '';
oFyNcL += '';
}
// use locale sensitive sort for strings when case insensitive
// note: localeCompare interleaves uppercase with lowercase (e.g. A,a,B,b)
if (self.sort.insensitive && typeof oFxNcL === 'string' && typeof oFyNcL === 'string') {
locRes = oFxNcL.localeCompare(oFyNcL, self.loc);
if (locRes !== 0) return locRes;
}
if (oFxNcL < oFyNcL) return -1;
if (oFxNcL > oFyNcL) return 1;
}
return 0;
};
self.sort.insensitive = true;
}
}
return self.sort(a, b);
} | javascript | function(a, b) {
var self = elFinder.prototype.naturalCompare;
if (typeof self.loc == 'undefined') {
self.loc = (navigator.userLanguage || navigator.browserLanguage || navigator.language || 'en-US');
}
if (typeof self.sort == 'undefined') {
if ('11'.localeCompare('2', self.loc, {numeric: true}) > 0) {
// Native support
if (window.Intl && window.Intl.Collator) {
self.sort = new Intl.Collator(self.loc, {numeric: true}).compare;
} else {
self.sort = function(a, b) {
return a.localeCompare(b, self.loc, {numeric: true});
};
}
} else {
/*
* Edited for elFinder (emulates localeCompare() by numeric) by Naoki Sawada aka nao-pon
*/
/*
* Huddle/javascript-natural-sort (https://github.com/Huddle/javascript-natural-sort)
*/
/*
* Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
* Author: Jim Palmer (based on chunking idea from Dave Koelle)
* http://opensource.org/licenses/mit-license.php
*/
self.sort = function(a, b) {
var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,
sre = /(^[ ]*|[ ]*$)/g,
dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
hre = /^0x[0-9a-f]+$/i,
ore = /^0/,
syre = /^[\x01\x21-\x2f\x3a-\x40\x5b-\x60\x7b-\x7e]/, // symbol first - (Naoki Sawada)
i = function(s) { return self.sort.insensitive && (''+s).toLowerCase() || ''+s; },
// convert all to strings strip whitespace
// first character is "_", it's smallest - (Naoki Sawada)
x = i(a).replace(sre, '').replace(/^_/, "\x01") || '',
y = i(b).replace(sre, '').replace(/^_/, "\x01") || '',
// chunk/tokenize
xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
// numeric, hex or date detection
xD = parseInt(x.match(hre)) || (xN.length != 1 && x.match(dre) && Date.parse(x)),
yD = parseInt(y.match(hre)) || xD && y.match(dre) && Date.parse(y) || null,
oFxNcL, oFyNcL,
locRes = 0;
// first try and sort Hex codes or Dates
if (yD) {
if ( xD < yD ) return -1;
else if ( xD > yD ) return 1;
}
// natural sorting through split numeric strings and default strings
for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc++) {
// find floats not starting with '0', string or 0 if not defined (Clint Priest)
oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
// handle numeric vs string comparison - number < string - (Kyle Adams)
// but symbol first < number - (Naoki Sawada)
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) {
if (isNaN(oFxNcL) && (typeof oFxNcL !== 'string' || ! oFxNcL.match(syre))) {
return 1;
} else if (typeof oFyNcL !== 'string' || ! oFyNcL.match(syre)) {
return -1;
}
}
// use decimal number comparison if either value is string zero
if (parseInt(oFxNcL, 10) === 0) oFxNcL = 0;
if (parseInt(oFyNcL, 10) === 0) oFyNcL = 0;
// rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
if (typeof oFxNcL !== typeof oFyNcL) {
oFxNcL += '';
oFyNcL += '';
}
// use locale sensitive sort for strings when case insensitive
// note: localeCompare interleaves uppercase with lowercase (e.g. A,a,B,b)
if (self.sort.insensitive && typeof oFxNcL === 'string' && typeof oFyNcL === 'string') {
locRes = oFxNcL.localeCompare(oFyNcL, self.loc);
if (locRes !== 0) return locRes;
}
if (oFxNcL < oFyNcL) return -1;
if (oFxNcL > oFyNcL) return 1;
}
return 0;
};
self.sort.insensitive = true;
}
}
return self.sort(a, b);
} | [
"function",
"(",
"a",
",",
"b",
")",
"{",
"var",
"self",
"=",
"elFinder",
".",
"prototype",
".",
"naturalCompare",
";",
"if",
"(",
"typeof",
"self",
".",
"loc",
"==",
"'undefined'",
")",
"{",
"self",
".",
"loc",
"=",
"(",
"navigator",
".",
"userLangu... | Compare strings for natural sort
@param String
@param String
@return Number | [
"Compare",
"strings",
"for",
"natural",
"sort"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L7583-L7679 | |
32,181 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(file1, file2) {
var self = this,
type = self.sortType,
asc = self.sortOrder == 'asc',
stick = self.sortStickFolders,
rules = self.sortRules,
sort = rules[type],
d1 = file1.mime == 'directory',
d2 = file2.mime == 'directory',
res;
if (stick) {
if (d1 && !d2) {
return -1;
} else if (!d1 && d2) {
return 1;
}
}
res = asc ? sort(file1, file2) : sort(file2, file1);
return type !== 'name' && res === 0
? res = asc ? rules.name(file1, file2) : rules.name(file2, file1)
: res;
} | javascript | function(file1, file2) {
var self = this,
type = self.sortType,
asc = self.sortOrder == 'asc',
stick = self.sortStickFolders,
rules = self.sortRules,
sort = rules[type],
d1 = file1.mime == 'directory',
d2 = file2.mime == 'directory',
res;
if (stick) {
if (d1 && !d2) {
return -1;
} else if (!d1 && d2) {
return 1;
}
}
res = asc ? sort(file1, file2) : sort(file2, file1);
return type !== 'name' && res === 0
? res = asc ? rules.name(file1, file2) : rules.name(file2, file1)
: res;
} | [
"function",
"(",
"file1",
",",
"file2",
")",
"{",
"var",
"self",
"=",
"this",
",",
"type",
"=",
"self",
".",
"sortType",
",",
"asc",
"=",
"self",
".",
"sortOrder",
"==",
"'asc'",
",",
"stick",
"=",
"self",
".",
"sortStickFolders",
",",
"rules",
"=",
... | Compare files based on elFinder.sort
@param Object file
@param Object file
@return Number | [
"Compare",
"files",
"based",
"on",
"elFinder",
".",
"sort"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L7688-L7712 | |
32,182 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(prefix, phash, glue) {
var i = 0, ext = '', p, name;
prefix = this.i18n(false, prefix);
phash = phash || this.cwd().hash;
glue = (typeof glue === 'undefined')? ' ' : glue;
if (p = prefix.match(/^(.+)(\.[^.]+)$/)) {
ext = p[2];
prefix = p[1];
}
name = prefix+ext;
if (!this.fileByName(name, phash)) {
return name;
}
while (i < 10000) {
name = prefix + glue + (++i) + ext;
if (!this.fileByName(name, phash)) {
return name;
}
}
return prefix + Math.random() + ext;
} | javascript | function(prefix, phash, glue) {
var i = 0, ext = '', p, name;
prefix = this.i18n(false, prefix);
phash = phash || this.cwd().hash;
glue = (typeof glue === 'undefined')? ' ' : glue;
if (p = prefix.match(/^(.+)(\.[^.]+)$/)) {
ext = p[2];
prefix = p[1];
}
name = prefix+ext;
if (!this.fileByName(name, phash)) {
return name;
}
while (i < 10000) {
name = prefix + glue + (++i) + ext;
if (!this.fileByName(name, phash)) {
return name;
}
}
return prefix + Math.random() + ext;
} | [
"function",
"(",
"prefix",
",",
"phash",
",",
"glue",
")",
"{",
"var",
"i",
"=",
"0",
",",
"ext",
"=",
"''",
",",
"p",
",",
"name",
";",
"prefix",
"=",
"this",
".",
"i18n",
"(",
"false",
",",
"prefix",
")",
";",
"phash",
"=",
"phash",
"||",
"... | Create unique file name in required dir
@param String file name
@param String parent dir hash
@param String glue
@return String | [
"Create",
"unique",
"file",
"name",
"in",
"required",
"dir"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L7951-L7975 | |
32,183 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(file, asObject) {
var self = this,
template = {
'background' : 'url(\'{url}\') 0 0 no-repeat',
'background-size' : 'contain'
},
style = '',
cssObj = {},
i = 0;
if (file.icon) {
style = 'style="';
$.each(template, function(k, v) {
if (i++ === 0) {
v = v.replace('{url}', self.escape(file.icon));
}
if (asObject) {
cssObj[k] = v;
} else {
style += k+':'+v+';';
}
});
style += '"';
}
return asObject? cssObj : style;
} | javascript | function(file, asObject) {
var self = this,
template = {
'background' : 'url(\'{url}\') 0 0 no-repeat',
'background-size' : 'contain'
},
style = '',
cssObj = {},
i = 0;
if (file.icon) {
style = 'style="';
$.each(template, function(k, v) {
if (i++ === 0) {
v = v.replace('{url}', self.escape(file.icon));
}
if (asObject) {
cssObj[k] = v;
} else {
style += k+':'+v+';';
}
});
style += '"';
}
return asObject? cssObj : style;
} | [
"function",
"(",
"file",
",",
"asObject",
")",
"{",
"var",
"self",
"=",
"this",
",",
"template",
"=",
"{",
"'background'",
":",
"'url(\\'{url}\\') 0 0 no-repeat'",
",",
"'background-size'",
":",
"'contain'",
"}",
",",
"style",
"=",
"''",
",",
"cssObj",
"=",
... | Get icon style from file.icon
@param Object elFinder file object
@return String|Object | [
"Get",
"icon",
"style",
"from",
"file",
".",
"icon"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L8059-L8083 | |
32,184 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(mimeType) {
var prefix = 'elfinder-cwd-icon-',
mime = mimeType.toLowerCase(),
isText = this.textMimes[mime];
mime = mime.split('/');
if (isText) {
mime[0] += ' ' + prefix + 'text';
}
return prefix + mime[0] + (mime[1] ? ' ' + prefix + mime[1].replace(/(\.|\+)/g, '-') : '');
} | javascript | function(mimeType) {
var prefix = 'elfinder-cwd-icon-',
mime = mimeType.toLowerCase(),
isText = this.textMimes[mime];
mime = mime.split('/');
if (isText) {
mime[0] += ' ' + prefix + 'text';
}
return prefix + mime[0] + (mime[1] ? ' ' + prefix + mime[1].replace(/(\.|\+)/g, '-') : '');
} | [
"function",
"(",
"mimeType",
")",
"{",
"var",
"prefix",
"=",
"'elfinder-cwd-icon-'",
",",
"mime",
"=",
"mimeType",
".",
"toLowerCase",
"(",
")",
",",
"isText",
"=",
"this",
".",
"textMimes",
"[",
"mime",
"]",
";",
"mime",
"=",
"mime",
".",
"split",
"("... | Convert mimetype into css classes
@param String file mimetype
@return String | [
"Convert",
"mimetype",
"into",
"css",
"classes"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L8091-L8102 | |
32,185 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(f) {
var isObj = typeof(f) == 'object' ? true : false,
mime = isObj ? f.mime : f,
kind;
if (isObj && f.alias && mime != 'symlink-broken') {
kind = 'Alias';
} else if (this.kinds[mime]) {
if (isObj && mime === 'directory' && (! f.phash || f.isroot)) {
kind = 'Root';
} else {
kind = this.kinds[mime];
}
}
if (! kind) {
if (mime.indexOf('text') === 0) {
kind = 'Text';
} else if (mime.indexOf('image') === 0) {
kind = 'Image';
} else if (mime.indexOf('audio') === 0) {
kind = 'Audio';
} else if (mime.indexOf('video') === 0) {
kind = 'Video';
} else if (mime.indexOf('application') === 0) {
kind = 'App';
} else {
kind = mime;
}
}
return this.messages['kind'+kind] ? this.i18n('kind'+kind) : mime;
} | javascript | function(f) {
var isObj = typeof(f) == 'object' ? true : false,
mime = isObj ? f.mime : f,
kind;
if (isObj && f.alias && mime != 'symlink-broken') {
kind = 'Alias';
} else if (this.kinds[mime]) {
if (isObj && mime === 'directory' && (! f.phash || f.isroot)) {
kind = 'Root';
} else {
kind = this.kinds[mime];
}
}
if (! kind) {
if (mime.indexOf('text') === 0) {
kind = 'Text';
} else if (mime.indexOf('image') === 0) {
kind = 'Image';
} else if (mime.indexOf('audio') === 0) {
kind = 'Audio';
} else if (mime.indexOf('video') === 0) {
kind = 'Video';
} else if (mime.indexOf('application') === 0) {
kind = 'App';
} else {
kind = mime;
}
}
return this.messages['kind'+kind] ? this.i18n('kind'+kind) : mime;
} | [
"function",
"(",
"f",
")",
"{",
"var",
"isObj",
"=",
"typeof",
"(",
"f",
")",
"==",
"'object'",
"?",
"true",
":",
"false",
",",
"mime",
"=",
"isObj",
"?",
"f",
".",
"mime",
":",
"f",
",",
"kind",
";",
"if",
"(",
"isObj",
"&&",
"f",
".",
"alia... | Return localized kind of file
@param Object|String file or file mimetype
@return String | [
"Return",
"localized",
"kind",
"of",
"file"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L8110-L8142 | |
32,186 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(format, date) {
var self = this,
output, d, dw, m, y, h, g, i, s;
if (! date) {
date = new Date();
}
h = date[self.getHours]();
g = h > 12 ? h - 12 : h;
i = date[self.getMinutes]();
s = date[self.getSeconds]();
d = date[self.getDate]();
dw = date[self.getDay]();
m = date[self.getMonth]() + 1;
y = date[self.getFullYear]();
output = format.replace(/[a-z]/gi, function(val) {
switch (val) {
case 'd': return d > 9 ? d : '0'+d;
case 'j': return d;
case 'D': return self.i18n(self.i18.daysShort[dw]);
case 'l': return self.i18n(self.i18.days[dw]);
case 'm': return m > 9 ? m : '0'+m;
case 'n': return m;
case 'M': return self.i18n(self.i18.monthsShort[m-1]);
case 'F': return self.i18n(self.i18.months[m-1]);
case 'Y': return y;
case 'y': return (''+y).substr(2);
case 'H': return h > 9 ? h : '0'+h;
case 'G': return h;
case 'g': return g;
case 'h': return g > 9 ? g : '0'+g;
case 'a': return h >= 12 ? 'pm' : 'am';
case 'A': return h >= 12 ? 'PM' : 'AM';
case 'i': return i > 9 ? i : '0'+i;
case 's': return s > 9 ? s : '0'+s;
}
return val;
});
return output;
} | javascript | function(format, date) {
var self = this,
output, d, dw, m, y, h, g, i, s;
if (! date) {
date = new Date();
}
h = date[self.getHours]();
g = h > 12 ? h - 12 : h;
i = date[self.getMinutes]();
s = date[self.getSeconds]();
d = date[self.getDate]();
dw = date[self.getDay]();
m = date[self.getMonth]() + 1;
y = date[self.getFullYear]();
output = format.replace(/[a-z]/gi, function(val) {
switch (val) {
case 'd': return d > 9 ? d : '0'+d;
case 'j': return d;
case 'D': return self.i18n(self.i18.daysShort[dw]);
case 'l': return self.i18n(self.i18.days[dw]);
case 'm': return m > 9 ? m : '0'+m;
case 'n': return m;
case 'M': return self.i18n(self.i18.monthsShort[m-1]);
case 'F': return self.i18n(self.i18.months[m-1]);
case 'Y': return y;
case 'y': return (''+y).substr(2);
case 'H': return h > 9 ? h : '0'+h;
case 'G': return h;
case 'g': return g;
case 'h': return g > 9 ? g : '0'+g;
case 'a': return h >= 12 ? 'pm' : 'am';
case 'A': return h >= 12 ? 'PM' : 'AM';
case 'i': return i > 9 ? i : '0'+i;
case 's': return s > 9 ? s : '0'+s;
}
return val;
});
return output;
} | [
"function",
"(",
"format",
",",
"date",
")",
"{",
"var",
"self",
"=",
"this",
",",
"output",
",",
"d",
",",
"dw",
",",
"m",
",",
"y",
",",
"h",
",",
"g",
",",
"i",
",",
"s",
";",
"if",
"(",
"!",
"date",
")",
"{",
"date",
"=",
"new",
"Date... | Returns a date string formatted according to the given format string
@param String format string
@param Object Date object
@return String | [
"Returns",
"a",
"date",
"string",
"formatted",
"according",
"to",
"the",
"given",
"format",
"string"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L8161-L8203 | |
32,187 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(file, t) {
var self = this,
ts = t || file.ts,
i18 = self.i18,
date, format, output, d, dw, m, y, h, g, i, s;
if (self.options.clientFormatDate && ts > 0) {
date = new Date(ts*1000);
format = ts >= this.yesterday
? this.fancyFormat
: this.dateFormat;
output = self.date(format, date);
return ts >= this.yesterday
? output.replace('$1', this.i18n(ts >= this.today ? 'Today' : 'Yesterday'))
: output;
} else if (file.date) {
return file.date.replace(/([a-z]+)\s/i, function(a1, a2) { return self.i18n(a2)+' '; });
}
return self.i18n('dateUnknown');
} | javascript | function(file, t) {
var self = this,
ts = t || file.ts,
i18 = self.i18,
date, format, output, d, dw, m, y, h, g, i, s;
if (self.options.clientFormatDate && ts > 0) {
date = new Date(ts*1000);
format = ts >= this.yesterday
? this.fancyFormat
: this.dateFormat;
output = self.date(format, date);
return ts >= this.yesterday
? output.replace('$1', this.i18n(ts >= this.today ? 'Today' : 'Yesterday'))
: output;
} else if (file.date) {
return file.date.replace(/([a-z]+)\s/i, function(a1, a2) { return self.i18n(a2)+' '; });
}
return self.i18n('dateUnknown');
} | [
"function",
"(",
"file",
",",
"t",
")",
"{",
"var",
"self",
"=",
"this",
",",
"ts",
"=",
"t",
"||",
"file",
".",
"ts",
",",
"i18",
"=",
"self",
".",
"i18",
",",
"date",
",",
"format",
",",
"output",
",",
"d",
",",
"dw",
",",
"m",
",",
"y",
... | Return localized date
@param Object file object
@return String | [
"Return",
"localized",
"date"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L8211-L8234 | |
32,188 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(num) {
var v = new Number(num);
if (v) {
if (v.toLocaleString) {
return v.toLocaleString();
} else {
return String(num).replace( /(\d)(?=(\d\d\d)+(?!\d))/g, '$1,');
}
}
return num;
} | javascript | function(num) {
var v = new Number(num);
if (v) {
if (v.toLocaleString) {
return v.toLocaleString();
} else {
return String(num).replace( /(\d)(?=(\d\d\d)+(?!\d))/g, '$1,');
}
}
return num;
} | [
"function",
"(",
"num",
")",
"{",
"var",
"v",
"=",
"new",
"Number",
"(",
"num",
")",
";",
"if",
"(",
"v",
")",
"{",
"if",
"(",
"v",
".",
"toLocaleString",
")",
"{",
"return",
"v",
".",
"toLocaleString",
"(",
")",
";",
"}",
"else",
"{",
"return"... | Return localized number string
@param Number
@return String | [
"Return",
"localized",
"number",
"string"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L8242-L8252 | |
32,189 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(o) {
var c = '';
if (!o.read && !o.write) {
c = 'elfinder-na';
} else if (!o.read) {
c = 'elfinder-wo';
} else if (!o.write) {
c = 'elfinder-ro';
}
if (o.type) {
c += ' elfinder-' + this.escape(o.type);
}
return c;
} | javascript | function(o) {
var c = '';
if (!o.read && !o.write) {
c = 'elfinder-na';
} else if (!o.read) {
c = 'elfinder-wo';
} else if (!o.write) {
c = 'elfinder-ro';
}
if (o.type) {
c += ' elfinder-' + this.escape(o.type);
}
return c;
} | [
"function",
"(",
"o",
")",
"{",
"var",
"c",
"=",
"''",
";",
"if",
"(",
"!",
"o",
".",
"read",
"&&",
"!",
"o",
".",
"write",
")",
"{",
"c",
"=",
"'elfinder-na'",
";",
"}",
"else",
"if",
"(",
"!",
"o",
".",
"read",
")",
"{",
"c",
"=",
"'elf... | Return css class marks file permissions
@param Object file
@return String | [
"Return",
"css",
"class",
"marks",
"file",
"permissions"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L8260-L8276 | |
32,190 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(f) {
var p = [];
f.read && p.push(this.i18n('read'));
f.write && p.push(this.i18n('write'));
return p.length ? p.join(' '+this.i18n('and')+' ') : this.i18n('noaccess');
} | javascript | function(f) {
var p = [];
f.read && p.push(this.i18n('read'));
f.write && p.push(this.i18n('write'));
return p.length ? p.join(' '+this.i18n('and')+' ') : this.i18n('noaccess');
} | [
"function",
"(",
"f",
")",
"{",
"var",
"p",
"=",
"[",
"]",
";",
"f",
".",
"read",
"&&",
"p",
".",
"push",
"(",
"this",
".",
"i18n",
"(",
"'read'",
")",
")",
";",
"f",
".",
"write",
"&&",
"p",
".",
"push",
"(",
"this",
".",
"i18n",
"(",
"'... | Return localized string with file permissions
@param Object file
@return String | [
"Return",
"localized",
"string",
"with",
"file",
"permissions"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L8284-L8291 | |
32,191 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(s) {
var n = 1, u = 'b';
if (s == 'unknown') {
return this.i18n('unknown');
}
if (s > 1073741824) {
n = 1073741824;
u = 'GB';
} else if (s > 1048576) {
n = 1048576;
u = 'MB';
} else if (s > 1024) {
n = 1024;
u = 'KB';
}
s = s/n;
return (s > 0 ? n >= 1048576 ? s.toFixed(2) : Math.round(s) : 0) +' '+u;
} | javascript | function(s) {
var n = 1, u = 'b';
if (s == 'unknown') {
return this.i18n('unknown');
}
if (s > 1073741824) {
n = 1073741824;
u = 'GB';
} else if (s > 1048576) {
n = 1048576;
u = 'MB';
} else if (s > 1024) {
n = 1024;
u = 'KB';
}
s = s/n;
return (s > 0 ? n >= 1048576 ? s.toFixed(2) : Math.round(s) : 0) +' '+u;
} | [
"function",
"(",
"s",
")",
"{",
"var",
"n",
"=",
"1",
",",
"u",
"=",
"'b'",
";",
"if",
"(",
"s",
"==",
"'unknown'",
")",
"{",
"return",
"this",
".",
"i18n",
"(",
"'unknown'",
")",
";",
"}",
"if",
"(",
"s",
">",
"1073741824",
")",
"{",
"n",
... | Return formated file size
@param Number file size
@return String | [
"Return",
"formated",
"file",
"size"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L8299-L8318 | |
32,192 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(mime, target) {
target = target || this.cwd().hash;
var res = true, // default is allow
mimeChecker = this.option('uploadMime', target),
allow,
deny,
check = function(checker) {
var ret = false;
if (typeof checker === 'string' && checker.toLowerCase() === 'all') {
ret = true;
} else if (Array.isArray(checker) && checker.length) {
$.each(checker, function(i, v) {
v = v.toLowerCase();
if (v === 'all' || mime.indexOf(v) === 0) {
ret = true;
return false;
}
});
}
return ret;
};
if (mime && $.isPlainObject(mimeChecker)) {
mime = mime.toLowerCase();
allow = check(mimeChecker.allow);
deny = check(mimeChecker.deny);
if (mimeChecker.firstOrder === 'allow') {
res = false; // default is deny
if (! deny && allow === true) { // match only allow
res = true;
}
} else {
res = true; // default is allow
if (deny === true && ! allow) { // match only deny
res = false;
}
}
}
return res;
} | javascript | function(mime, target) {
target = target || this.cwd().hash;
var res = true, // default is allow
mimeChecker = this.option('uploadMime', target),
allow,
deny,
check = function(checker) {
var ret = false;
if (typeof checker === 'string' && checker.toLowerCase() === 'all') {
ret = true;
} else if (Array.isArray(checker) && checker.length) {
$.each(checker, function(i, v) {
v = v.toLowerCase();
if (v === 'all' || mime.indexOf(v) === 0) {
ret = true;
return false;
}
});
}
return ret;
};
if (mime && $.isPlainObject(mimeChecker)) {
mime = mime.toLowerCase();
allow = check(mimeChecker.allow);
deny = check(mimeChecker.deny);
if (mimeChecker.firstOrder === 'allow') {
res = false; // default is deny
if (! deny && allow === true) { // match only allow
res = true;
}
} else {
res = true; // default is allow
if (deny === true && ! allow) { // match only deny
res = false;
}
}
}
return res;
} | [
"function",
"(",
"mime",
",",
"target",
")",
"{",
"target",
"=",
"target",
"||",
"this",
".",
"cwd",
"(",
")",
".",
"hash",
";",
"var",
"res",
"=",
"true",
",",
"// default is allow",
"mimeChecker",
"=",
"this",
".",
"option",
"(",
"'uploadMime'",
",",... | Return boolean that uploadable MIME type into target folder
@param String mime MIME type
@param String target target folder hash
@return Bool | [
"Return",
"boolean",
"that",
"uploadable",
"MIME",
"type",
"into",
"target",
"folder"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L8429-L8467 | |
32,193 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(tasks) {
var l = tasks.length,
chain = function(task, idx) {
++idx;
if (tasks[idx]) {
return chain(task.then(tasks[idx]), idx);
} else {
return task;
}
};
if (l > 1) {
return chain(tasks[0](), 0);
} else {
return tasks[0]();
}
} | javascript | function(tasks) {
var l = tasks.length,
chain = function(task, idx) {
++idx;
if (tasks[idx]) {
return chain(task.then(tasks[idx]), idx);
} else {
return task;
}
};
if (l > 1) {
return chain(tasks[0](), 0);
} else {
return tasks[0]();
}
} | [
"function",
"(",
"tasks",
")",
"{",
"var",
"l",
"=",
"tasks",
".",
"length",
",",
"chain",
"=",
"function",
"(",
"task",
",",
"idx",
")",
"{",
"++",
"idx",
";",
"if",
"(",
"tasks",
"[",
"idx",
"]",
")",
"{",
"return",
"chain",
"(",
"task",
".",... | call chained sequence of async deferred functions
@param Array tasks async functions
@return Object jQuery.Deferred | [
"call",
"chained",
"sequence",
"of",
"async",
"deferred",
"functions"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L8475-L8490 | |
32,194 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(url) {
var dfd = $.Deferred(),
ifm;
try {
ifm = $('<iframe width="1" height="1" scrolling="no" frameborder="no" style="position:absolute; top:-1px; left:-1px" crossorigin="use-credentials">')
.attr('src', url)
.one('load', function() {
var ifm = $(this);
try {
this.contentDocument.location.reload(true);
ifm.one('load', function() {
ifm.remove();
dfd.resolve();
});
} catch(e) {
ifm.attr('src', '').attr('src', url).one('load', function() {
ifm.remove();
dfd.resolve();
});
}
})
.appendTo('body');
} catch(e) {
ifm && ifm.remove();
dfd.reject();
}
return dfd;
} | javascript | function(url) {
var dfd = $.Deferred(),
ifm;
try {
ifm = $('<iframe width="1" height="1" scrolling="no" frameborder="no" style="position:absolute; top:-1px; left:-1px" crossorigin="use-credentials">')
.attr('src', url)
.one('load', function() {
var ifm = $(this);
try {
this.contentDocument.location.reload(true);
ifm.one('load', function() {
ifm.remove();
dfd.resolve();
});
} catch(e) {
ifm.attr('src', '').attr('src', url).one('load', function() {
ifm.remove();
dfd.resolve();
});
}
})
.appendTo('body');
} catch(e) {
ifm && ifm.remove();
dfd.reject();
}
return dfd;
} | [
"function",
"(",
"url",
")",
"{",
"var",
"dfd",
"=",
"$",
".",
"Deferred",
"(",
")",
",",
"ifm",
";",
"try",
"{",
"ifm",
"=",
"$",
"(",
"'<iframe width=\"1\" height=\"1\" scrolling=\"no\" frameborder=\"no\" style=\"position:absolute; top:-1px; left:-1px\" crossorigin=\"us... | Reload contents of target URL for clear browser cache
@param String url target URL
@return Object jQuery.Deferred | [
"Reload",
"contents",
"of",
"target",
"URL",
"for",
"clear",
"browser",
"cache"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L8498-L8525 | |
32,195 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(files, opts) {
var self = this,
cwd = this.getUI('cwd'),
cwdHash = this.cwd().hash,
newItem = $();
opts = opts || {};
$.each(files, function(i, f) {
if (f.phash === cwdHash || self.searchStatus.state > 1) {
newItem = newItem.add(cwd.find('#'+self.cwdHash2Id(f.hash)));
if (opts.firstOnly) {
return false;
}
}
});
return newItem;
} | javascript | function(files, opts) {
var self = this,
cwd = this.getUI('cwd'),
cwdHash = this.cwd().hash,
newItem = $();
opts = opts || {};
$.each(files, function(i, f) {
if (f.phash === cwdHash || self.searchStatus.state > 1) {
newItem = newItem.add(cwd.find('#'+self.cwdHash2Id(f.hash)));
if (opts.firstOnly) {
return false;
}
}
});
return newItem;
} | [
"function",
"(",
"files",
",",
"opts",
")",
"{",
"var",
"self",
"=",
"this",
",",
"cwd",
"=",
"this",
".",
"getUI",
"(",
"'cwd'",
")",
",",
"cwdHash",
"=",
"this",
".",
"cwd",
"(",
")",
".",
"hash",
",",
"newItem",
"=",
"$",
"(",
")",
";",
"o... | Find cwd's nodes from files
@param Array files
@param Object opts {firstOnly: true|false} | [
"Find",
"cwd",
"s",
"nodes",
"from",
"files"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L8711-L8729 | |
32,196 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(url) {
if (url.match(/^http/i)) {
return url;
}
if (url.substr(0,2) === '//') {
return window.location.protocol + url;
}
var root = window.location.protocol + '//' + window.location.host,
reg = /[^\/]+\/\.\.\//,
ret;
if (url.substr(0, 1) === '/') {
ret = root + url;
} else {
ret = root + window.location.pathname.replace(/\/[^\/]+$/, '/') + url;
}
ret = ret.replace('/./', '/');
while(reg.test(ret)) {
ret = ret.replace(reg, '');
}
return ret;
} | javascript | function(url) {
if (url.match(/^http/i)) {
return url;
}
if (url.substr(0,2) === '//') {
return window.location.protocol + url;
}
var root = window.location.protocol + '//' + window.location.host,
reg = /[^\/]+\/\.\.\//,
ret;
if (url.substr(0, 1) === '/') {
ret = root + url;
} else {
ret = root + window.location.pathname.replace(/\/[^\/]+$/, '/') + url;
}
ret = ret.replace('/./', '/');
while(reg.test(ret)) {
ret = ret.replace(reg, '');
}
return ret;
} | [
"function",
"(",
"url",
")",
"{",
"if",
"(",
"url",
".",
"match",
"(",
"/",
"^http",
"/",
"i",
")",
")",
"{",
"return",
"url",
";",
"}",
"if",
"(",
"url",
".",
"substr",
"(",
"0",
",",
"2",
")",
"===",
"'//'",
")",
"{",
"return",
"window",
... | Convert from relative URL to abstract URL based on current URL
@param String URL
@return String | [
"Convert",
"from",
"relative",
"URL",
"to",
"abstract",
"URL",
"based",
"on",
"current",
"URL"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L8737-L8757 | |
32,197 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function (checkUrl) {
var url;
checkUrl = this.convAbsUrl(checkUrl);
if (location.origin && window.URL) {
try {
url = new URL(checkUrl);
return location.origin === url.origin;
} catch(e) {}
}
url = document.createElement('a');
url.href = checkUrl;
return location.protocol === url.protocol && location.host === url.host && location.port && url.port;
} | javascript | function (checkUrl) {
var url;
checkUrl = this.convAbsUrl(checkUrl);
if (location.origin && window.URL) {
try {
url = new URL(checkUrl);
return location.origin === url.origin;
} catch(e) {}
}
url = document.createElement('a');
url.href = checkUrl;
return location.protocol === url.protocol && location.host === url.host && location.port && url.port;
} | [
"function",
"(",
"checkUrl",
")",
"{",
"var",
"url",
";",
"checkUrl",
"=",
"this",
".",
"convAbsUrl",
"(",
"checkUrl",
")",
";",
"if",
"(",
"location",
".",
"origin",
"&&",
"window",
".",
"URL",
")",
"{",
"try",
"{",
"url",
"=",
"new",
"URL",
"(",
... | Is same origin to current site
@param String check url
@return Boolean | [
"Is",
"same",
"origin",
"to",
"current",
"site"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L8765-L8777 | |
32,198 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function() {
var self = this,
node = this.getUI(),
ni = node.css('z-index');
if (ni && ni !== 'auto' && ni !== 'inherit') {
self.zIndex = ni;
} else {
node.parents().each(function(i, n) {
var z = $(n).css('z-index');
if (z !== 'auto' && z !== 'inherit' && (z = parseInt(z))) {
self.zIndex = z;
return false;
}
});
}
} | javascript | function() {
var self = this,
node = this.getUI(),
ni = node.css('z-index');
if (ni && ni !== 'auto' && ni !== 'inherit') {
self.zIndex = ni;
} else {
node.parents().each(function(i, n) {
var z = $(n).css('z-index');
if (z !== 'auto' && z !== 'inherit' && (z = parseInt(z))) {
self.zIndex = z;
return false;
}
});
}
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"node",
"=",
"this",
".",
"getUI",
"(",
")",
",",
"ni",
"=",
"node",
".",
"css",
"(",
"'z-index'",
")",
";",
"if",
"(",
"ni",
"&&",
"ni",
"!==",
"'auto'",
"&&",
"ni",
"!==",
"'inherit'... | calculate elFinder node z-index
@return void | [
"calculate",
"elFinder",
"node",
"z",
"-",
"index"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L8812-L8827 | |
32,199 | ArchimediaZerogroup/alchemy-custom-model | vendor/assets/elfinder_OLD/js/elfinder.full.js | function(urls) {
var self = this;
if (typeof urls === 'string') {
urls = [ urls ];
}
$.each(urls, function(i, url) {
url = self.convAbsUrl(url).replace(/^https?:/i, '');
if (! $("head > link[href='+url+']").length) {
$('head').append('<link rel="stylesheet" type="text/css" href="' + url + '" />');
}
});
return this;
} | javascript | function(urls) {
var self = this;
if (typeof urls === 'string') {
urls = [ urls ];
}
$.each(urls, function(i, url) {
url = self.convAbsUrl(url).replace(/^https?:/i, '');
if (! $("head > link[href='+url+']").length) {
$('head').append('<link rel="stylesheet" type="text/css" href="' + url + '" />');
}
});
return this;
} | [
"function",
"(",
"urls",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"typeof",
"urls",
"===",
"'string'",
")",
"{",
"urls",
"=",
"[",
"urls",
"]",
";",
"}",
"$",
".",
"each",
"(",
"urls",
",",
"function",
"(",
"i",
",",
"url",
")",
... | Load CSS files
@param Array to load CSS file URLs
@return elFinder | [
"Load",
"CSS",
"files"
] | 1654c68c48dd0f760d46eac720f59fed75a32357 | https://github.com/ArchimediaZerogroup/alchemy-custom-model/blob/1654c68c48dd0f760d46eac720f59fed75a32357/vendor/assets/elfinder_OLD/js/elfinder.full.js#L8941-L8953 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.