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
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
|
---|---|---|---|---|---|---|---|---|---|---|---|
55,900 | joekarl/fastsync | fastsync.js | makeChainedCallback | function makeChainedCallback(i, fns, results, cb) {
return function(err, result) {
if (err) {
return cb(err);
}
results[i] = result;
if (fns[i + 1]) {
return fns[i + 1](makeChainedCallback(i + 1, fns, results, cb));
} else {
return cb(null, results);
}
};
} | javascript | function makeChainedCallback(i, fns, results, cb) {
return function(err, result) {
if (err) {
return cb(err);
}
results[i] = result;
if (fns[i + 1]) {
return fns[i + 1](makeChainedCallback(i + 1, fns, results, cb));
} else {
return cb(null, results);
}
};
} | [
"function",
"makeChainedCallback",
"(",
"i",
",",
"fns",
",",
"results",
",",
"cb",
")",
"{",
"return",
"function",
"(",
"err",
",",
"result",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"cb",
"(",
"err",
")",
";",
"}",
"results",
"[",
"i",
"]",
"=",
"result",
";",
"if",
"(",
"fns",
"[",
"i",
"+",
"1",
"]",
")",
"{",
"return",
"fns",
"[",
"i",
"+",
"1",
"]",
"(",
"makeChainedCallback",
"(",
"i",
"+",
"1",
",",
"fns",
",",
"results",
",",
"cb",
")",
")",
";",
"}",
"else",
"{",
"return",
"cb",
"(",
"null",
",",
"results",
")",
";",
"}",
"}",
";",
"}"
] | Create a function that will call the next function in a chain
when finished | [
"Create",
"a",
"function",
"that",
"will",
"call",
"the",
"next",
"function",
"in",
"a",
"chain",
"when",
"finished"
] | b2a81cb5990e15c3f8bfab6efd7856ae4d51b9d4 | https://github.com/joekarl/fastsync/blob/b2a81cb5990e15c3f8bfab6efd7856ae4d51b9d4/fastsync.js#L142-L154 |
55,901 | joekarl/fastsync | fastsync.js | makeCountNCallback | function makeCountNCallback(n, cb) {
var count = 0,
results = [],
error;
return function(index, err, result) {
results[index] = result;
if (!error && err) {
error = err;
return cb(err);
}
if (!error && ++count == n) {
cb(null, results);
}
};
} | javascript | function makeCountNCallback(n, cb) {
var count = 0,
results = [],
error;
return function(index, err, result) {
results[index] = result;
if (!error && err) {
error = err;
return cb(err);
}
if (!error && ++count == n) {
cb(null, results);
}
};
} | [
"function",
"makeCountNCallback",
"(",
"n",
",",
"cb",
")",
"{",
"var",
"count",
"=",
"0",
",",
"results",
"=",
"[",
"]",
",",
"error",
";",
"return",
"function",
"(",
"index",
",",
"err",
",",
"result",
")",
"{",
"results",
"[",
"index",
"]",
"=",
"result",
";",
"if",
"(",
"!",
"error",
"&&",
"err",
")",
"{",
"error",
"=",
"err",
";",
"return",
"cb",
"(",
"err",
")",
";",
"}",
"if",
"(",
"!",
"error",
"&&",
"++",
"count",
"==",
"n",
")",
"{",
"cb",
"(",
"null",
",",
"results",
")",
";",
"}",
"}",
";",
"}"
] | Create a function that will call a callback after n function calls | [
"Create",
"a",
"function",
"that",
"will",
"call",
"a",
"callback",
"after",
"n",
"function",
"calls"
] | b2a81cb5990e15c3f8bfab6efd7856ae4d51b9d4 | https://github.com/joekarl/fastsync/blob/b2a81cb5990e15c3f8bfab6efd7856ae4d51b9d4/fastsync.js#L159-L173 |
55,902 | walling/logentries-query-stream | index.js | logentriesRawStream | function logentriesRawStream(pathname, query={}) {
query = Object.assign({}, query);
// If query format is not defined, we set it by default to JSON.
if (!query.format) {
query.format = 'json';
}
// Text format is default in Logentries, in this case we remove the parameter.
if (query.format === 'text') {
delete query.format;
}
// Put default start and/or end times, if not given.
if (!query.start && !query.end) {
query.end = Date.now();
query.start = query.end - 15*60*1000; // 15 minutes
} else if (!query.start) {
query.start = query.end - 15*60*1000;
} else if (!query.end) {
query.end = query.start + 15*60*1000;
}
// Return raw stream using the download API.
return request.get({
url : url.format({
protocol : 'https:',
host : 'pull.logentries.com',
pathname : pathname,
query : query
}),
gzip : true,
timeout : 30000 // 30 seconds
});
} | javascript | function logentriesRawStream(pathname, query={}) {
query = Object.assign({}, query);
// If query format is not defined, we set it by default to JSON.
if (!query.format) {
query.format = 'json';
}
// Text format is default in Logentries, in this case we remove the parameter.
if (query.format === 'text') {
delete query.format;
}
// Put default start and/or end times, if not given.
if (!query.start && !query.end) {
query.end = Date.now();
query.start = query.end - 15*60*1000; // 15 minutes
} else if (!query.start) {
query.start = query.end - 15*60*1000;
} else if (!query.end) {
query.end = query.start + 15*60*1000;
}
// Return raw stream using the download API.
return request.get({
url : url.format({
protocol : 'https:',
host : 'pull.logentries.com',
pathname : pathname,
query : query
}),
gzip : true,
timeout : 30000 // 30 seconds
});
} | [
"function",
"logentriesRawStream",
"(",
"pathname",
",",
"query",
"=",
"{",
"}",
")",
"{",
"query",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"query",
")",
";",
"// If query format is not defined, we set it by default to JSON.",
"if",
"(",
"!",
"query",
".",
"format",
")",
"{",
"query",
".",
"format",
"=",
"'json'",
";",
"}",
"// Text format is default in Logentries, in this case we remove the parameter.",
"if",
"(",
"query",
".",
"format",
"===",
"'text'",
")",
"{",
"delete",
"query",
".",
"format",
";",
"}",
"// Put default start and/or end times, if not given.",
"if",
"(",
"!",
"query",
".",
"start",
"&&",
"!",
"query",
".",
"end",
")",
"{",
"query",
".",
"end",
"=",
"Date",
".",
"now",
"(",
")",
";",
"query",
".",
"start",
"=",
"query",
".",
"end",
"-",
"15",
"*",
"60",
"*",
"1000",
";",
"// 15 minutes",
"}",
"else",
"if",
"(",
"!",
"query",
".",
"start",
")",
"{",
"query",
".",
"start",
"=",
"query",
".",
"end",
"-",
"15",
"*",
"60",
"*",
"1000",
";",
"}",
"else",
"if",
"(",
"!",
"query",
".",
"end",
")",
"{",
"query",
".",
"end",
"=",
"query",
".",
"start",
"+",
"15",
"*",
"60",
"*",
"1000",
";",
"}",
"// Return raw stream using the download API.",
"return",
"request",
".",
"get",
"(",
"{",
"url",
":",
"url",
".",
"format",
"(",
"{",
"protocol",
":",
"'https:'",
",",
"host",
":",
"'pull.logentries.com'",
",",
"pathname",
":",
"pathname",
",",
"query",
":",
"query",
"}",
")",
",",
"gzip",
":",
"true",
",",
"timeout",
":",
"30000",
"// 30 seconds",
"}",
")",
";",
"}"
] | Query and stream raw logs from Logentries. This is not returning an object stream. If you want JSON objects, use the `logentriesJsonStream` function. | [
"Query",
"and",
"stream",
"raw",
"logs",
"from",
"Logentries",
".",
"This",
"is",
"not",
"returning",
"an",
"object",
"stream",
".",
"If",
"you",
"want",
"JSON",
"objects",
"use",
"the",
"logentriesJsonStream",
"function",
"."
] | 59035ebc0acaf269ca5230e56116d535c2d88d7a | https://github.com/walling/logentries-query-stream/blob/59035ebc0acaf269ca5230e56116d535c2d88d7a/index.js#L10-L44 |
55,903 | walling/logentries-query-stream | index.js | logentriesJsonStream | function logentriesJsonStream(pathname, query={}) {
query = Object.assign({}, query);
// Force query format to JSON.
query.format = 'json';
// Parse each array entry from raw stream and emit JSON objects.
return pump(logentriesRawStream(pathname, query), JSONStream.parse('*'));
} | javascript | function logentriesJsonStream(pathname, query={}) {
query = Object.assign({}, query);
// Force query format to JSON.
query.format = 'json';
// Parse each array entry from raw stream and emit JSON objects.
return pump(logentriesRawStream(pathname, query), JSONStream.parse('*'));
} | [
"function",
"logentriesJsonStream",
"(",
"pathname",
",",
"query",
"=",
"{",
"}",
")",
"{",
"query",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"query",
")",
";",
"// Force query format to JSON.",
"query",
".",
"format",
"=",
"'json'",
";",
"// Parse each array entry from raw stream and emit JSON objects.",
"return",
"pump",
"(",
"logentriesRawStream",
"(",
"pathname",
",",
"query",
")",
",",
"JSONStream",
".",
"parse",
"(",
"'*'",
")",
")",
";",
"}"
] | Query and stream logs from Logentries. This returns a readable object stream emitting log record JSON objects. | [
"Query",
"and",
"stream",
"logs",
"from",
"Logentries",
".",
"This",
"returns",
"a",
"readable",
"object",
"stream",
"emitting",
"log",
"record",
"JSON",
"objects",
"."
] | 59035ebc0acaf269ca5230e56116d535c2d88d7a | https://github.com/walling/logentries-query-stream/blob/59035ebc0acaf269ca5230e56116d535c2d88d7a/index.js#L48-L56 |
55,904 | walling/logentries-query-stream | index.js | logentriesConnect | function logentriesConnect(options={}) {
// Define path to access specific account, log set and log.
let pathname = '/' + encodeURIComponent(options.account) +
'/hosts/' + encodeURIComponent(options.logset) +
'/' + encodeURIComponent(options.log) + '/';
// Bind path argument in query functions.
let json = logentriesJsonStream.bind(null, pathname);
let raw = logentriesRawStream.bind(null, pathname);
return Object.assign(json, {
json : json,
raw : raw
});
} | javascript | function logentriesConnect(options={}) {
// Define path to access specific account, log set and log.
let pathname = '/' + encodeURIComponent(options.account) +
'/hosts/' + encodeURIComponent(options.logset) +
'/' + encodeURIComponent(options.log) + '/';
// Bind path argument in query functions.
let json = logentriesJsonStream.bind(null, pathname);
let raw = logentriesRawStream.bind(null, pathname);
return Object.assign(json, {
json : json,
raw : raw
});
} | [
"function",
"logentriesConnect",
"(",
"options",
"=",
"{",
"}",
")",
"{",
"// Define path to access specific account, log set and log.",
"let",
"pathname",
"=",
"'/'",
"+",
"encodeURIComponent",
"(",
"options",
".",
"account",
")",
"+",
"'/hosts/'",
"+",
"encodeURIComponent",
"(",
"options",
".",
"logset",
")",
"+",
"'/'",
"+",
"encodeURIComponent",
"(",
"options",
".",
"log",
")",
"+",
"'/'",
";",
"// Bind path argument in query functions.",
"let",
"json",
"=",
"logentriesJsonStream",
".",
"bind",
"(",
"null",
",",
"pathname",
")",
";",
"let",
"raw",
"=",
"logentriesRawStream",
".",
"bind",
"(",
"null",
",",
"pathname",
")",
";",
"return",
"Object",
".",
"assign",
"(",
"json",
",",
"{",
"json",
":",
"json",
",",
"raw",
":",
"raw",
"}",
")",
";",
"}"
] | Setup connection to a specific account and log. Returns query function. | [
"Setup",
"connection",
"to",
"a",
"specific",
"account",
"and",
"log",
".",
"Returns",
"query",
"function",
"."
] | 59035ebc0acaf269ca5230e56116d535c2d88d7a | https://github.com/walling/logentries-query-stream/blob/59035ebc0acaf269ca5230e56116d535c2d88d7a/index.js#L59-L73 |
55,905 | Qwerios/madlib-generic-cache | lib/index.js | CacheModule | function CacheModule(settings, cacheName, serviceHandler, serviceCallName) {
if (serviceCallName == null) {
serviceCallName = "call";
}
settings.init("cacheModules", {
expiration: {
"default": 1800000
}
});
this.settings = settings;
this.cache = {
data: {},
mtime: {},
name: cacheName
};
this.service = serviceHandler;
this.serviceCallName = serviceCallName;
} | javascript | function CacheModule(settings, cacheName, serviceHandler, serviceCallName) {
if (serviceCallName == null) {
serviceCallName = "call";
}
settings.init("cacheModules", {
expiration: {
"default": 1800000
}
});
this.settings = settings;
this.cache = {
data: {},
mtime: {},
name: cacheName
};
this.service = serviceHandler;
this.serviceCallName = serviceCallName;
} | [
"function",
"CacheModule",
"(",
"settings",
",",
"cacheName",
",",
"serviceHandler",
",",
"serviceCallName",
")",
"{",
"if",
"(",
"serviceCallName",
"==",
"null",
")",
"{",
"serviceCallName",
"=",
"\"call\"",
";",
"}",
"settings",
".",
"init",
"(",
"\"cacheModules\"",
",",
"{",
"expiration",
":",
"{",
"\"default\"",
":",
"1800000",
"}",
"}",
")",
";",
"this",
".",
"settings",
"=",
"settings",
";",
"this",
".",
"cache",
"=",
"{",
"data",
":",
"{",
"}",
",",
"mtime",
":",
"{",
"}",
",",
"name",
":",
"cacheName",
"}",
";",
"this",
".",
"service",
"=",
"serviceHandler",
";",
"this",
".",
"serviceCallName",
"=",
"serviceCallName",
";",
"}"
] | The class constructor.
@function constructor
@params {Object} settings A madlib-settings instance
@params {String} cacheName The name of the cache. Used to retrieve expiration settings and logging purposes
@params {Function} serviceHandler The 'service' instance providing the data for the cache
@params {String} [serviceCallName] The name of the method to call on the serviceHandler. Defaults to 'call'
@params
@return None | [
"The",
"class",
"constructor",
"."
] | 0d2d00d727abab421a5ae4fd91ca162ad3d0d126 | https://github.com/Qwerios/madlib-generic-cache/blob/0d2d00d727abab421a5ae4fd91ca162ad3d0d126/lib/index.js#L36-L53 |
55,906 | Industryswarm/isnode-mod-data | lib/mongodb/mongodb/lib/operations/db_ops.js | addUser | function addUser(db, username, password, options, callback) {
const Db = require('../db');
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed())
return callback(new MongoError('topology was destroyed'));
// Attempt to execute auth command
executeAuthCreateUserCommand(db, username, password, options, (err, r) => {
// We need to perform the backward compatible insert operation
if (err && err.code === -5000) {
const finalOptions = applyWriteConcern(Object.assign({}, options), { db }, options);
// Use node md5 generator
const md5 = crypto.createHash('md5');
// Generate keys used for authentication
md5.update(username + ':mongo:' + password);
const userPassword = md5.digest('hex');
// If we have another db set
const db = options.dbName ? new Db(options.dbName, db.s.topology, db.s.options) : db;
// Fetch a user collection
const collection = db.collection(CONSTANTS.SYSTEM_USER_COLLECTION);
// Check if we are inserting the first user
count(collection, {}, finalOptions, (err, count) => {
// We got an error (f.ex not authorized)
if (err != null) return handleCallback(callback, err, null);
// Check if the user exists and update i
const findOptions = Object.assign({ projection: { dbName: 1 } }, finalOptions);
collection.find({ user: username }, findOptions).toArray(err => {
// We got an error (f.ex not authorized)
if (err != null) return handleCallback(callback, err, null);
// Add command keys
finalOptions.upsert = true;
// We have a user, let's update the password or upsert if not
updateOne(
collection,
{ user: username },
{ $set: { user: username, pwd: userPassword } },
finalOptions,
err => {
if (count === 0 && err)
return handleCallback(callback, null, [{ user: username, pwd: userPassword }]);
if (err) return handleCallback(callback, err, null);
handleCallback(callback, null, [{ user: username, pwd: userPassword }]);
}
);
});
});
return;
}
if (err) return handleCallback(callback, err);
handleCallback(callback, err, r);
});
} | javascript | function addUser(db, username, password, options, callback) {
const Db = require('../db');
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed())
return callback(new MongoError('topology was destroyed'));
// Attempt to execute auth command
executeAuthCreateUserCommand(db, username, password, options, (err, r) => {
// We need to perform the backward compatible insert operation
if (err && err.code === -5000) {
const finalOptions = applyWriteConcern(Object.assign({}, options), { db }, options);
// Use node md5 generator
const md5 = crypto.createHash('md5');
// Generate keys used for authentication
md5.update(username + ':mongo:' + password);
const userPassword = md5.digest('hex');
// If we have another db set
const db = options.dbName ? new Db(options.dbName, db.s.topology, db.s.options) : db;
// Fetch a user collection
const collection = db.collection(CONSTANTS.SYSTEM_USER_COLLECTION);
// Check if we are inserting the first user
count(collection, {}, finalOptions, (err, count) => {
// We got an error (f.ex not authorized)
if (err != null) return handleCallback(callback, err, null);
// Check if the user exists and update i
const findOptions = Object.assign({ projection: { dbName: 1 } }, finalOptions);
collection.find({ user: username }, findOptions).toArray(err => {
// We got an error (f.ex not authorized)
if (err != null) return handleCallback(callback, err, null);
// Add command keys
finalOptions.upsert = true;
// We have a user, let's update the password or upsert if not
updateOne(
collection,
{ user: username },
{ $set: { user: username, pwd: userPassword } },
finalOptions,
err => {
if (count === 0 && err)
return handleCallback(callback, null, [{ user: username, pwd: userPassword }]);
if (err) return handleCallback(callback, err, null);
handleCallback(callback, null, [{ user: username, pwd: userPassword }]);
}
);
});
});
return;
}
if (err) return handleCallback(callback, err);
handleCallback(callback, err, r);
});
} | [
"function",
"addUser",
"(",
"db",
",",
"username",
",",
"password",
",",
"options",
",",
"callback",
")",
"{",
"const",
"Db",
"=",
"require",
"(",
"'../db'",
")",
";",
"// Did the user destroy the topology",
"if",
"(",
"db",
".",
"serverConfig",
"&&",
"db",
".",
"serverConfig",
".",
"isDestroyed",
"(",
")",
")",
"return",
"callback",
"(",
"new",
"MongoError",
"(",
"'topology was destroyed'",
")",
")",
";",
"// Attempt to execute auth command",
"executeAuthCreateUserCommand",
"(",
"db",
",",
"username",
",",
"password",
",",
"options",
",",
"(",
"err",
",",
"r",
")",
"=>",
"{",
"// We need to perform the backward compatible insert operation",
"if",
"(",
"err",
"&&",
"err",
".",
"code",
"===",
"-",
"5000",
")",
"{",
"const",
"finalOptions",
"=",
"applyWriteConcern",
"(",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"options",
")",
",",
"{",
"db",
"}",
",",
"options",
")",
";",
"// Use node md5 generator",
"const",
"md5",
"=",
"crypto",
".",
"createHash",
"(",
"'md5'",
")",
";",
"// Generate keys used for authentication",
"md5",
".",
"update",
"(",
"username",
"+",
"':mongo:'",
"+",
"password",
")",
";",
"const",
"userPassword",
"=",
"md5",
".",
"digest",
"(",
"'hex'",
")",
";",
"// If we have another db set",
"const",
"db",
"=",
"options",
".",
"dbName",
"?",
"new",
"Db",
"(",
"options",
".",
"dbName",
",",
"db",
".",
"s",
".",
"topology",
",",
"db",
".",
"s",
".",
"options",
")",
":",
"db",
";",
"// Fetch a user collection",
"const",
"collection",
"=",
"db",
".",
"collection",
"(",
"CONSTANTS",
".",
"SYSTEM_USER_COLLECTION",
")",
";",
"// Check if we are inserting the first user",
"count",
"(",
"collection",
",",
"{",
"}",
",",
"finalOptions",
",",
"(",
"err",
",",
"count",
")",
"=>",
"{",
"// We got an error (f.ex not authorized)",
"if",
"(",
"err",
"!=",
"null",
")",
"return",
"handleCallback",
"(",
"callback",
",",
"err",
",",
"null",
")",
";",
"// Check if the user exists and update i",
"const",
"findOptions",
"=",
"Object",
".",
"assign",
"(",
"{",
"projection",
":",
"{",
"dbName",
":",
"1",
"}",
"}",
",",
"finalOptions",
")",
";",
"collection",
".",
"find",
"(",
"{",
"user",
":",
"username",
"}",
",",
"findOptions",
")",
".",
"toArray",
"(",
"err",
"=>",
"{",
"// We got an error (f.ex not authorized)",
"if",
"(",
"err",
"!=",
"null",
")",
"return",
"handleCallback",
"(",
"callback",
",",
"err",
",",
"null",
")",
";",
"// Add command keys",
"finalOptions",
".",
"upsert",
"=",
"true",
";",
"// We have a user, let's update the password or upsert if not",
"updateOne",
"(",
"collection",
",",
"{",
"user",
":",
"username",
"}",
",",
"{",
"$set",
":",
"{",
"user",
":",
"username",
",",
"pwd",
":",
"userPassword",
"}",
"}",
",",
"finalOptions",
",",
"err",
"=>",
"{",
"if",
"(",
"count",
"===",
"0",
"&&",
"err",
")",
"return",
"handleCallback",
"(",
"callback",
",",
"null",
",",
"[",
"{",
"user",
":",
"username",
",",
"pwd",
":",
"userPassword",
"}",
"]",
")",
";",
"if",
"(",
"err",
")",
"return",
"handleCallback",
"(",
"callback",
",",
"err",
",",
"null",
")",
";",
"handleCallback",
"(",
"callback",
",",
"null",
",",
"[",
"{",
"user",
":",
"username",
",",
"pwd",
":",
"userPassword",
"}",
"]",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}",
")",
";",
"return",
";",
"}",
"if",
"(",
"err",
")",
"return",
"handleCallback",
"(",
"callback",
",",
"err",
")",
";",
"handleCallback",
"(",
"callback",
",",
"err",
",",
"r",
")",
";",
"}",
")",
";",
"}"
] | Add a user to the database.
@method
@param {Db} db The Db instance on which to add a user.
@param {string} username The username.
@param {string} password The password.
@param {object} [options] Optional settings. See Db.prototype.addUser for a list of options.
@param {Db~resultCallback} [callback] The command result callback | [
"Add",
"a",
"user",
"to",
"the",
"database",
"."
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb/lib/operations/db_ops.js#L66-L124 |
55,907 | ojj11/morphic | morphic.js | morphic | function morphic(options) {
var optionsIn = options || {};
var Matcher = optionsIn.matcherCore || defaultMatcher
var matcher = new Matcher(optionsIn);
var generateMatchers = optionsIn.generateMatchers || defaultGenerateMatchers;
var generateNamedFieldExtractors = optionsIn.generateNamedFieldExtractors || defaultGenerateNamedFieldExtractors;
var extractNamedFields = optionsIn.extractNamedFields || defaultExtractNamedFields;
putRecord(matcher.useFallback.bind(matcher), [], function() {
throw new Error("No methods matched input " + util.inspect(arguments));
});
var morphicFunction = function morphicFunction() {
var match = matcher.getRecordFromInput(arguments);
var extractedFields = extractNamedFields(match.namedFields || [], arguments);
var args = [extractedFields].concat(Array.from(arguments));
var action = match.action;
return action.apply(this, args);
};
morphicFunction.with = function() {
var generatedMatchers = generateMatchers(matchers, arguments);
var namedFields = generateNamedFieldExtractors(generatedMatchers);
return builder(
putRecord.bind(
undefined, matcher.addRecord.bind(matcher, generatedMatchers), namedFields));
};
morphicFunction.otherwise = function() {
return builder(
putRecord.bind(
undefined, matcher.useFallback.bind(matcher), []));
};
return morphicFunction;
} | javascript | function morphic(options) {
var optionsIn = options || {};
var Matcher = optionsIn.matcherCore || defaultMatcher
var matcher = new Matcher(optionsIn);
var generateMatchers = optionsIn.generateMatchers || defaultGenerateMatchers;
var generateNamedFieldExtractors = optionsIn.generateNamedFieldExtractors || defaultGenerateNamedFieldExtractors;
var extractNamedFields = optionsIn.extractNamedFields || defaultExtractNamedFields;
putRecord(matcher.useFallback.bind(matcher), [], function() {
throw new Error("No methods matched input " + util.inspect(arguments));
});
var morphicFunction = function morphicFunction() {
var match = matcher.getRecordFromInput(arguments);
var extractedFields = extractNamedFields(match.namedFields || [], arguments);
var args = [extractedFields].concat(Array.from(arguments));
var action = match.action;
return action.apply(this, args);
};
morphicFunction.with = function() {
var generatedMatchers = generateMatchers(matchers, arguments);
var namedFields = generateNamedFieldExtractors(generatedMatchers);
return builder(
putRecord.bind(
undefined, matcher.addRecord.bind(matcher, generatedMatchers), namedFields));
};
morphicFunction.otherwise = function() {
return builder(
putRecord.bind(
undefined, matcher.useFallback.bind(matcher), []));
};
return morphicFunction;
} | [
"function",
"morphic",
"(",
"options",
")",
"{",
"var",
"optionsIn",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"Matcher",
"=",
"optionsIn",
".",
"matcherCore",
"||",
"defaultMatcher",
"var",
"matcher",
"=",
"new",
"Matcher",
"(",
"optionsIn",
")",
";",
"var",
"generateMatchers",
"=",
"optionsIn",
".",
"generateMatchers",
"||",
"defaultGenerateMatchers",
";",
"var",
"generateNamedFieldExtractors",
"=",
"optionsIn",
".",
"generateNamedFieldExtractors",
"||",
"defaultGenerateNamedFieldExtractors",
";",
"var",
"extractNamedFields",
"=",
"optionsIn",
".",
"extractNamedFields",
"||",
"defaultExtractNamedFields",
";",
"putRecord",
"(",
"matcher",
".",
"useFallback",
".",
"bind",
"(",
"matcher",
")",
",",
"[",
"]",
",",
"function",
"(",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"No methods matched input \"",
"+",
"util",
".",
"inspect",
"(",
"arguments",
")",
")",
";",
"}",
")",
";",
"var",
"morphicFunction",
"=",
"function",
"morphicFunction",
"(",
")",
"{",
"var",
"match",
"=",
"matcher",
".",
"getRecordFromInput",
"(",
"arguments",
")",
";",
"var",
"extractedFields",
"=",
"extractNamedFields",
"(",
"match",
".",
"namedFields",
"||",
"[",
"]",
",",
"arguments",
")",
";",
"var",
"args",
"=",
"[",
"extractedFields",
"]",
".",
"concat",
"(",
"Array",
".",
"from",
"(",
"arguments",
")",
")",
";",
"var",
"action",
"=",
"match",
".",
"action",
";",
"return",
"action",
".",
"apply",
"(",
"this",
",",
"args",
")",
";",
"}",
";",
"morphicFunction",
".",
"with",
"=",
"function",
"(",
")",
"{",
"var",
"generatedMatchers",
"=",
"generateMatchers",
"(",
"matchers",
",",
"arguments",
")",
";",
"var",
"namedFields",
"=",
"generateNamedFieldExtractors",
"(",
"generatedMatchers",
")",
";",
"return",
"builder",
"(",
"putRecord",
".",
"bind",
"(",
"undefined",
",",
"matcher",
".",
"addRecord",
".",
"bind",
"(",
"matcher",
",",
"generatedMatchers",
")",
",",
"namedFields",
")",
")",
";",
"}",
";",
"morphicFunction",
".",
"otherwise",
"=",
"function",
"(",
")",
"{",
"return",
"builder",
"(",
"putRecord",
".",
"bind",
"(",
"undefined",
",",
"matcher",
".",
"useFallback",
".",
"bind",
"(",
"matcher",
")",
",",
"[",
"]",
")",
")",
";",
"}",
";",
"return",
"morphicFunction",
";",
"}"
] | This class is essentially syntactic sugar around the core matcher found in matcher.js | [
"This",
"class",
"is",
"essentially",
"syntactic",
"sugar",
"around",
"the",
"core",
"matcher",
"found",
"in",
"matcher",
".",
"js"
] | 1ec6fd2f299e50866b9165c2545c430519f522ef | https://github.com/ojj11/morphic/blob/1ec6fd2f299e50866b9165c2545c430519f522ef/morphic.js#L43-L79 |
55,908 | gmalysa/flux-link | lib/flux-link.js | LoopChain | function LoopChain(cond, fns) {
if (fns instanceof Array)
Chain.apply(this, fns);
else
Chain.apply(this, slice.call(arguments, 1));
this.cond = this.wrap(cond);
this.name = '(anonymous loop chain)';
} | javascript | function LoopChain(cond, fns) {
if (fns instanceof Array)
Chain.apply(this, fns);
else
Chain.apply(this, slice.call(arguments, 1));
this.cond = this.wrap(cond);
this.name = '(anonymous loop chain)';
} | [
"function",
"LoopChain",
"(",
"cond",
",",
"fns",
")",
"{",
"if",
"(",
"fns",
"instanceof",
"Array",
")",
"Chain",
".",
"apply",
"(",
"this",
",",
"fns",
")",
";",
"else",
"Chain",
".",
"apply",
"(",
"this",
",",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
")",
";",
"this",
".",
"cond",
"=",
"this",
".",
"wrap",
"(",
"cond",
")",
";",
"this",
".",
"name",
"=",
"'(anonymous loop chain)'",
";",
"}"
] | A Loop Chain will iterate over its functions until the condition function specified returns
false, standardizing and simplifying the implementation for something that could already be
done with standard serial Chains.
@param cond Conditional function that is evaluated with an environment and an after
@param fns/varargs Functions to use for the body of the chain | [
"A",
"Loop",
"Chain",
"will",
"iterate",
"over",
"its",
"functions",
"until",
"the",
"condition",
"function",
"specified",
"returns",
"false",
"standardizing",
"and",
"simplifying",
"the",
"implementation",
"for",
"something",
"that",
"could",
"already",
"be",
"done",
"with",
"standard",
"serial",
"Chains",
"."
] | 567ac39a1f4a74f85465a58fb6fd96d64b1b765f | https://github.com/gmalysa/flux-link/blob/567ac39a1f4a74f85465a58fb6fd96d64b1b765f/lib/flux-link.js#L344-L352 |
55,909 | gmalysa/flux-link | lib/flux-link.js | Branch | function Branch(cond, t, f) {
this.cond = this.wrap(cond);
this.if_true = this.wrap(t);
this.if_false = this.wrap(f);
this.name = '(Unnamed Branch)';
} | javascript | function Branch(cond, t, f) {
this.cond = this.wrap(cond);
this.if_true = this.wrap(t);
this.if_false = this.wrap(f);
this.name = '(Unnamed Branch)';
} | [
"function",
"Branch",
"(",
"cond",
",",
"t",
",",
"f",
")",
"{",
"this",
".",
"cond",
"=",
"this",
".",
"wrap",
"(",
"cond",
")",
";",
"this",
".",
"if_true",
"=",
"this",
".",
"wrap",
"(",
"t",
")",
";",
"this",
".",
"if_false",
"=",
"this",
".",
"wrap",
"(",
"f",
")",
";",
"this",
".",
"name",
"=",
"'(Unnamed Branch)'",
";",
"}"
] | A branch is used to simplify multipath management when constructing Chains.
It works just like a normal Chain, except that it calls the asynchronous
decision function and uses it to select between the A and B alternatives,
which are most useful when given as Chains.
@param cond Condition function to use as the branch decision point
@param t Chain/function to execute if the condition is true
@param f Chain/function to execute if the condition is false | [
"A",
"branch",
"is",
"used",
"to",
"simplify",
"multipath",
"management",
"when",
"constructing",
"Chains",
".",
"It",
"works",
"just",
"like",
"a",
"normal",
"Chain",
"except",
"that",
"it",
"calls",
"the",
"asynchronous",
"decision",
"function",
"and",
"uses",
"it",
"to",
"select",
"between",
"the",
"A",
"and",
"B",
"alternatives",
"which",
"are",
"most",
"useful",
"when",
"given",
"as",
"Chains",
"."
] | 567ac39a1f4a74f85465a58fb6fd96d64b1b765f | https://github.com/gmalysa/flux-link/blob/567ac39a1f4a74f85465a58fb6fd96d64b1b765f/lib/flux-link.js#L526-L531 |
55,910 | gmalysa/flux-link | lib/flux-link.js | __chain_inner | function __chain_inner(result) {
var args = slice.call(arguments, 1);
nextTick(function() {
try {
if (result) {
var params = that.handle_args(env, that.if_true, args);
params.unshift(env, after);
env._fm.$push_call(helpers.fname(that.if_true, that.if_true.fn.name));
that.if_true.fn.apply(null, params);
}
else {
var params = that.handle_args(env, that.if_false, args);
params.unshift(env, after);
env._fm.$push_call(helpers.fname(that.if_false, that.if_false.fn.name));
that.if_false.fn.apply(null, params);
}
}
catch (e) {
env.$throw(e);
}
});
} | javascript | function __chain_inner(result) {
var args = slice.call(arguments, 1);
nextTick(function() {
try {
if (result) {
var params = that.handle_args(env, that.if_true, args);
params.unshift(env, after);
env._fm.$push_call(helpers.fname(that.if_true, that.if_true.fn.name));
that.if_true.fn.apply(null, params);
}
else {
var params = that.handle_args(env, that.if_false, args);
params.unshift(env, after);
env._fm.$push_call(helpers.fname(that.if_false, that.if_false.fn.name));
that.if_false.fn.apply(null, params);
}
}
catch (e) {
env.$throw(e);
}
});
} | [
"function",
"__chain_inner",
"(",
"result",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"nextTick",
"(",
"function",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"result",
")",
"{",
"var",
"params",
"=",
"that",
".",
"handle_args",
"(",
"env",
",",
"that",
".",
"if_true",
",",
"args",
")",
";",
"params",
".",
"unshift",
"(",
"env",
",",
"after",
")",
";",
"env",
".",
"_fm",
".",
"$push_call",
"(",
"helpers",
".",
"fname",
"(",
"that",
".",
"if_true",
",",
"that",
".",
"if_true",
".",
"fn",
".",
"name",
")",
")",
";",
"that",
".",
"if_true",
".",
"fn",
".",
"apply",
"(",
"null",
",",
"params",
")",
";",
"}",
"else",
"{",
"var",
"params",
"=",
"that",
".",
"handle_args",
"(",
"env",
",",
"that",
".",
"if_false",
",",
"args",
")",
";",
"params",
".",
"unshift",
"(",
"env",
",",
"after",
")",
";",
"env",
".",
"_fm",
".",
"$push_call",
"(",
"helpers",
".",
"fname",
"(",
"that",
".",
"if_false",
",",
"that",
".",
"if_false",
".",
"fn",
".",
"name",
")",
")",
";",
"that",
".",
"if_false",
".",
"fn",
".",
"apply",
"(",
"null",
",",
"params",
")",
";",
"}",
"}",
"catch",
"(",
"e",
")",
"{",
"env",
".",
"$throw",
"(",
"e",
")",
";",
"}",
"}",
")",
";",
"}"
] | This closure handles the response from the condition function | [
"This",
"closure",
"handles",
"the",
"response",
"from",
"the",
"condition",
"function"
] | 567ac39a1f4a74f85465a58fb6fd96d64b1b765f | https://github.com/gmalysa/flux-link/blob/567ac39a1f4a74f85465a58fb6fd96d64b1b765f/lib/flux-link.js#L584-L605 |
55,911 | hal313/html-amend | src/html-amend.js | replaceWith | function replaceWith(input, regex, content) {
// Sanity check
verifyParameterIsDefined(input, 'input', 'replaceWith');
verifyParameterIsDefined(regex, 'regex', 'replaceWith');
return replaceAt(normalizeValue(input), normalizeRegExp(normalizeValue(regex)), normalizeValue(content));
} | javascript | function replaceWith(input, regex, content) {
// Sanity check
verifyParameterIsDefined(input, 'input', 'replaceWith');
verifyParameterIsDefined(regex, 'regex', 'replaceWith');
return replaceAt(normalizeValue(input), normalizeRegExp(normalizeValue(regex)), normalizeValue(content));
} | [
"function",
"replaceWith",
"(",
"input",
",",
"regex",
",",
"content",
")",
"{",
"// Sanity check",
"verifyParameterIsDefined",
"(",
"input",
",",
"'input'",
",",
"'replaceWith'",
")",
";",
"verifyParameterIsDefined",
"(",
"regex",
",",
"'regex'",
",",
"'replaceWith'",
")",
";",
"return",
"replaceAt",
"(",
"normalizeValue",
"(",
"input",
")",
",",
"normalizeRegExp",
"(",
"normalizeValue",
"(",
"regex",
")",
")",
",",
"normalizeValue",
"(",
"content",
")",
")",
";",
"}"
] | Replaces content specified by a regular expression with specified content.
@param {String|Function} input the input to replace
@param {String|RegExp|Function} regEx the regular expression (or string) to replace within the input
@param {String|Function} [content] the content to replace
@return {String} a String which has the first occurrence of the regular expression within input replaced with the content
@throws {String} when input or regex are not defined | [
"Replaces",
"content",
"specified",
"by",
"a",
"regular",
"expression",
"with",
"specified",
"content",
"."
] | a96d1c347a3842cfa5d08870bc383d7925b8a894 | https://github.com/hal313/html-amend/blob/a96d1c347a3842cfa5d08870bc383d7925b8a894/src/html-amend.js#L134-L140 |
55,912 | hal313/html-amend | src/html-amend.js | afterElementOpen | function afterElementOpen(input, element, content) {
// Sanity check
verifyParameterIsDefined(input, 'input', 'afterElementOpen');
verifyParameterIsDefined(element, 'element', 'afterElementOpen');
return insertAfter(normalizeValue(input), normalizeRegExp(`<${normalizeValue(element)}[^\>]*>`), normalizeValue(content));
} | javascript | function afterElementOpen(input, element, content) {
// Sanity check
verifyParameterIsDefined(input, 'input', 'afterElementOpen');
verifyParameterIsDefined(element, 'element', 'afterElementOpen');
return insertAfter(normalizeValue(input), normalizeRegExp(`<${normalizeValue(element)}[^\>]*>`), normalizeValue(content));
} | [
"function",
"afterElementOpen",
"(",
"input",
",",
"element",
",",
"content",
")",
"{",
"// Sanity check",
"verifyParameterIsDefined",
"(",
"input",
",",
"'input'",
",",
"'afterElementOpen'",
")",
";",
"verifyParameterIsDefined",
"(",
"element",
",",
"'element'",
",",
"'afterElementOpen'",
")",
";",
"return",
"insertAfter",
"(",
"normalizeValue",
"(",
"input",
")",
",",
"normalizeRegExp",
"(",
"`",
"${",
"normalizeValue",
"(",
"element",
")",
"}",
"\\>",
"`",
")",
",",
"normalizeValue",
"(",
"content",
")",
")",
";",
"}"
] | Inserts content into the input string after the first occurrence of the element has been opened.
@param {String|Function} input the input to replace
@param {String|Function} element the element to insert after
@param {String|Function} [content] the content to insert within the input string
@return {String} a String which has the content added after the first occurrence of the element open tag within the input string
@throws {String} when input or element are not defined | [
"Inserts",
"content",
"into",
"the",
"input",
"string",
"after",
"the",
"first",
"occurrence",
"of",
"the",
"element",
"has",
"been",
"opened",
"."
] | a96d1c347a3842cfa5d08870bc383d7925b8a894 | https://github.com/hal313/html-amend/blob/a96d1c347a3842cfa5d08870bc383d7925b8a894/src/html-amend.js#L150-L156 |
55,913 | hal313/html-amend | src/html-amend.js | beforeElementClose | function beforeElementClose(input, element, content) {
// Sanity check
verifyParameterIsDefined(input, 'input', beforeElementClose.name);
verifyParameterIsDefined(element, 'element', beforeElementClose.name);
return insertBefore(normalizeValue(input), normalizeRegExp(`<\/${normalizeValue(element)}[^\>]*>`), normalizeValue(content));
} | javascript | function beforeElementClose(input, element, content) {
// Sanity check
verifyParameterIsDefined(input, 'input', beforeElementClose.name);
verifyParameterIsDefined(element, 'element', beforeElementClose.name);
return insertBefore(normalizeValue(input), normalizeRegExp(`<\/${normalizeValue(element)}[^\>]*>`), normalizeValue(content));
} | [
"function",
"beforeElementClose",
"(",
"input",
",",
"element",
",",
"content",
")",
"{",
"// Sanity check",
"verifyParameterIsDefined",
"(",
"input",
",",
"'input'",
",",
"beforeElementClose",
".",
"name",
")",
";",
"verifyParameterIsDefined",
"(",
"element",
",",
"'element'",
",",
"beforeElementClose",
".",
"name",
")",
";",
"return",
"insertBefore",
"(",
"normalizeValue",
"(",
"input",
")",
",",
"normalizeRegExp",
"(",
"`",
"\\/",
"${",
"normalizeValue",
"(",
"element",
")",
"}",
"\\>",
"`",
")",
",",
"normalizeValue",
"(",
"content",
")",
")",
";",
"}"
] | Inserts content into the input string before the first occurrence of the element close tag.
@param {String|Function} input the input to replace
@param {String|Function} element the element to insert before close
@param {String|Function} content the content to replace within the input string
@return {String} a String which has the content added before the first occurrence of the element close tag within the input string
@throws {String} when input or element are not defined | [
"Inserts",
"content",
"into",
"the",
"input",
"string",
"before",
"the",
"first",
"occurrence",
"of",
"the",
"element",
"close",
"tag",
"."
] | a96d1c347a3842cfa5d08870bc383d7925b8a894 | https://github.com/hal313/html-amend/blob/a96d1c347a3842cfa5d08870bc383d7925b8a894/src/html-amend.js#L166-L172 |
55,914 | hal313/html-amend | src/html-amend.js | insertComment | function insertComment(input, element, comment) {
// Sanity check
verifyParameterIsDefined(input, 'input', insertComment.name);
verifyParameterIsDefined(element, 'element', insertComment.name);
return insertAfter(normalizeValue(input), normalizeRegExp(`<\/${normalizeValue(element)}[^\>]*>`), `/* ${normalizeValue(comment)} */`);
} | javascript | function insertComment(input, element, comment) {
// Sanity check
verifyParameterIsDefined(input, 'input', insertComment.name);
verifyParameterIsDefined(element, 'element', insertComment.name);
return insertAfter(normalizeValue(input), normalizeRegExp(`<\/${normalizeValue(element)}[^\>]*>`), `/* ${normalizeValue(comment)} */`);
} | [
"function",
"insertComment",
"(",
"input",
",",
"element",
",",
"comment",
")",
"{",
"// Sanity check",
"verifyParameterIsDefined",
"(",
"input",
",",
"'input'",
",",
"insertComment",
".",
"name",
")",
";",
"verifyParameterIsDefined",
"(",
"element",
",",
"'element'",
",",
"insertComment",
".",
"name",
")",
";",
"return",
"insertAfter",
"(",
"normalizeValue",
"(",
"input",
")",
",",
"normalizeRegExp",
"(",
"`",
"\\/",
"${",
"normalizeValue",
"(",
"element",
")",
"}",
"\\>",
"`",
")",
",",
"`",
"${",
"normalizeValue",
"(",
"comment",
")",
"}",
"`",
")",
";",
"}"
] | Inserts an HTML comment into the input string after the first occurrence of the element close tag.
@param {String|Function} input the input to replace
@param {String|Function} element the element to add the comment after
@param {String|Function} [content] the comment to add.
@return {String} a String which has the comment added after the first occurrence of the element close tag within the input string
@throws {String} when input or element are not defined | [
"Inserts",
"an",
"HTML",
"comment",
"into",
"the",
"input",
"string",
"after",
"the",
"first",
"occurrence",
"of",
"the",
"element",
"close",
"tag",
"."
] | a96d1c347a3842cfa5d08870bc383d7925b8a894 | https://github.com/hal313/html-amend/blob/a96d1c347a3842cfa5d08870bc383d7925b8a894/src/html-amend.js#L182-L188 |
55,915 | hal313/html-amend | src/html-amend.js | insertAttribute | function insertAttribute(input, element, attributeName, attributeValue) {
// Sanity check
verifyParameterIsDefined(input, 'input', insertAttribute.name);
verifyParameterIsDefined(element, 'element', insertAttribute.name);
verifyParameterIsDefined(attributeName, 'attributeName', insertAttribute.name);
return insertAfter(normalizeValue(input), normalizeRegExp(`<${normalizeValue(element)}[^\>]*`), ` ${normalizeValue(attributeName)}="${normalizeValue(attributeValue)}"`);
} | javascript | function insertAttribute(input, element, attributeName, attributeValue) {
// Sanity check
verifyParameterIsDefined(input, 'input', insertAttribute.name);
verifyParameterIsDefined(element, 'element', insertAttribute.name);
verifyParameterIsDefined(attributeName, 'attributeName', insertAttribute.name);
return insertAfter(normalizeValue(input), normalizeRegExp(`<${normalizeValue(element)}[^\>]*`), ` ${normalizeValue(attributeName)}="${normalizeValue(attributeValue)}"`);
} | [
"function",
"insertAttribute",
"(",
"input",
",",
"element",
",",
"attributeName",
",",
"attributeValue",
")",
"{",
"// Sanity check",
"verifyParameterIsDefined",
"(",
"input",
",",
"'input'",
",",
"insertAttribute",
".",
"name",
")",
";",
"verifyParameterIsDefined",
"(",
"element",
",",
"'element'",
",",
"insertAttribute",
".",
"name",
")",
";",
"verifyParameterIsDefined",
"(",
"attributeName",
",",
"'attributeName'",
",",
"insertAttribute",
".",
"name",
")",
";",
"return",
"insertAfter",
"(",
"normalizeValue",
"(",
"input",
")",
",",
"normalizeRegExp",
"(",
"`",
"${",
"normalizeValue",
"(",
"element",
")",
"}",
"\\>",
"`",
")",
",",
"`",
"${",
"normalizeValue",
"(",
"attributeName",
")",
"}",
"${",
"normalizeValue",
"(",
"attributeValue",
")",
"}",
"`",
")",
";",
"}"
] | Inserts an attribute into the input string within the first occurrence of the element open tag.
@param {String|Function} input the input string
@param {String|Function} element the element tag to modify
@param {String|Function} attributeName the attribute name to add
@param {String|Function} [attributeValue] the attribute value to add
@return {String} a String which has the attribute added into the first occurrence of the element open tag
@throws {String} when input, element or attributeName are not defined | [
"Inserts",
"an",
"attribute",
"into",
"the",
"input",
"string",
"within",
"the",
"first",
"occurrence",
"of",
"the",
"element",
"open",
"tag",
"."
] | a96d1c347a3842cfa5d08870bc383d7925b8a894 | https://github.com/hal313/html-amend/blob/a96d1c347a3842cfa5d08870bc383d7925b8a894/src/html-amend.js#L199-L206 |
55,916 | shinout/Struct.js | lib/Struct.js | function(keyname) {
const _ = Struct.PriProp(keyname);
if (_.__proto__) {
_.__proto__ = Struct.prototype;
}
else {
Object.keys(Struct.prototype).forEach(function(p) {
Object.defineProperty(_, p, {
value : Struct.prototype[p],
writable : false
});
}, this);
}
var classFunction;
Object.defineProperties(_, {
requires : {
value: {},
writable: false
},
defaults : {
value: {},
writable: false
},
defaultFuncs : {
value: {},
writable: false
},
views: {
value: {},
writable: false
},
parentProps: {
value: [],
writable: false
},
enumerableDescs: {
value: {},
writable: false
},
classFunction : {
get: function() {
return classFunction;
},
set: function(v) {
if (classFunction === undefined) {
classFunction = v;
}
else if (classFunction !== v) {
throw new Error('cannot change classFunction.');
}
}
},
Modifiers : {
value : Struct.Modifiers,
writable : false
}
});
return _;
} | javascript | function(keyname) {
const _ = Struct.PriProp(keyname);
if (_.__proto__) {
_.__proto__ = Struct.prototype;
}
else {
Object.keys(Struct.prototype).forEach(function(p) {
Object.defineProperty(_, p, {
value : Struct.prototype[p],
writable : false
});
}, this);
}
var classFunction;
Object.defineProperties(_, {
requires : {
value: {},
writable: false
},
defaults : {
value: {},
writable: false
},
defaultFuncs : {
value: {},
writable: false
},
views: {
value: {},
writable: false
},
parentProps: {
value: [],
writable: false
},
enumerableDescs: {
value: {},
writable: false
},
classFunction : {
get: function() {
return classFunction;
},
set: function(v) {
if (classFunction === undefined) {
classFunction = v;
}
else if (classFunction !== v) {
throw new Error('cannot change classFunction.');
}
}
},
Modifiers : {
value : Struct.Modifiers,
writable : false
}
});
return _;
} | [
"function",
"(",
"keyname",
")",
"{",
"const",
"_",
"=",
"Struct",
".",
"PriProp",
"(",
"keyname",
")",
";",
"if",
"(",
"_",
".",
"__proto__",
")",
"{",
"_",
".",
"__proto__",
"=",
"Struct",
".",
"prototype",
";",
"}",
"else",
"{",
"Object",
".",
"keys",
"(",
"Struct",
".",
"prototype",
")",
".",
"forEach",
"(",
"function",
"(",
"p",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"_",
",",
"p",
",",
"{",
"value",
":",
"Struct",
".",
"prototype",
"[",
"p",
"]",
",",
"writable",
":",
"false",
"}",
")",
";",
"}",
",",
"this",
")",
";",
"}",
"var",
"classFunction",
";",
"Object",
".",
"defineProperties",
"(",
"_",
",",
"{",
"requires",
":",
"{",
"value",
":",
"{",
"}",
",",
"writable",
":",
"false",
"}",
",",
"defaults",
":",
"{",
"value",
":",
"{",
"}",
",",
"writable",
":",
"false",
"}",
",",
"defaultFuncs",
":",
"{",
"value",
":",
"{",
"}",
",",
"writable",
":",
"false",
"}",
",",
"views",
":",
"{",
"value",
":",
"{",
"}",
",",
"writable",
":",
"false",
"}",
",",
"parentProps",
":",
"{",
"value",
":",
"[",
"]",
",",
"writable",
":",
"false",
"}",
",",
"enumerableDescs",
":",
"{",
"value",
":",
"{",
"}",
",",
"writable",
":",
"false",
"}",
",",
"classFunction",
":",
"{",
"get",
":",
"function",
"(",
")",
"{",
"return",
"classFunction",
";",
"}",
",",
"set",
":",
"function",
"(",
"v",
")",
"{",
"if",
"(",
"classFunction",
"===",
"undefined",
")",
"{",
"classFunction",
"=",
"v",
";",
"}",
"else",
"if",
"(",
"classFunction",
"!==",
"v",
")",
"{",
"throw",
"new",
"Error",
"(",
"'cannot change classFunction.'",
")",
";",
"}",
"}",
"}",
",",
"Modifiers",
":",
"{",
"value",
":",
"Struct",
".",
"Modifiers",
",",
"writable",
":",
"false",
"}",
"}",
")",
";",
"return",
"_",
";",
"}"
] | Struct.js v0.0.1
Copyright 2011, SHIN Suzuki | [
"Struct",
".",
"js",
"v0",
".",
"0",
".",
"1"
] | 55aff5edcb956d85dcb0b55c8fdfe423aa34f53c | https://github.com/shinout/Struct.js/blob/55aff5edcb956d85dcb0b55c8fdfe423aa34f53c/lib/Struct.js#L8-L73 |
|
55,917 | ianmuninio/jmodel | lib/model.js | Model | function Model(collectionName, attributes, values) {
this.collectionName = collectionName;
this.idAttribute = Model.getId(attributes);
this.attributes = attributeValidator.validate(attributes);
this.values = { };
this.virtuals = { };
// initially add the null value from all attributes
for (var key in this.attributes) {
this.values[key] = undefined;
}
// prevents from modifying values and adding properties
Object.freeze(this.attributes);
// prevents from adding new properties
Object.seal(this.values);
// sets the initial values
this.set(values);
} | javascript | function Model(collectionName, attributes, values) {
this.collectionName = collectionName;
this.idAttribute = Model.getId(attributes);
this.attributes = attributeValidator.validate(attributes);
this.values = { };
this.virtuals = { };
// initially add the null value from all attributes
for (var key in this.attributes) {
this.values[key] = undefined;
}
// prevents from modifying values and adding properties
Object.freeze(this.attributes);
// prevents from adding new properties
Object.seal(this.values);
// sets the initial values
this.set(values);
} | [
"function",
"Model",
"(",
"collectionName",
",",
"attributes",
",",
"values",
")",
"{",
"this",
".",
"collectionName",
"=",
"collectionName",
";",
"this",
".",
"idAttribute",
"=",
"Model",
".",
"getId",
"(",
"attributes",
")",
";",
"this",
".",
"attributes",
"=",
"attributeValidator",
".",
"validate",
"(",
"attributes",
")",
";",
"this",
".",
"values",
"=",
"{",
"}",
";",
"this",
".",
"virtuals",
"=",
"{",
"}",
";",
"// initially add the null value from all attributes",
"for",
"(",
"var",
"key",
"in",
"this",
".",
"attributes",
")",
"{",
"this",
".",
"values",
"[",
"key",
"]",
"=",
"undefined",
";",
"}",
"// prevents from modifying values and adding properties",
"Object",
".",
"freeze",
"(",
"this",
".",
"attributes",
")",
";",
"// prevents from adding new properties",
"Object",
".",
"seal",
"(",
"this",
".",
"values",
")",
";",
"// sets the initial values",
"this",
".",
"set",
"(",
"values",
")",
";",
"}"
] | An entity is a lightweight persistence domain object.
@param {String} collectionName
@param {Object} attributes
@param {Object} values
@returns {Model} | [
"An",
"entity",
"is",
"a",
"lightweight",
"persistence",
"domain",
"object",
"."
] | c118bfc46596f59445604acc43b01ad2b04c31ef | https://github.com/ianmuninio/jmodel/blob/c118bfc46596f59445604acc43b01ad2b04c31ef/lib/model.js#L17-L37 |
55,918 | queckezz/list | lib/drop.js | drop | function drop (n, array) {
return (n < array.length)
? slice(n, array.length, array)
: []
} | javascript | function drop (n, array) {
return (n < array.length)
? slice(n, array.length, array)
: []
} | [
"function",
"drop",
"(",
"n",
",",
"array",
")",
"{",
"return",
"(",
"n",
"<",
"array",
".",
"length",
")",
"?",
"slice",
"(",
"n",
",",
"array",
".",
"length",
",",
"array",
")",
":",
"[",
"]",
"}"
] | Slice `n` items from `array` returning the sliced
elements as a new array.
@param {Int} n How many elements to drop
@param {Array} array Array to drop from
@return {Array} New Array with the dropped items | [
"Slice",
"n",
"items",
"from",
"array",
"returning",
"the",
"sliced",
"elements",
"as",
"a",
"new",
"array",
"."
] | a26130020b447a1aa136f0fed3283821490f7da4 | https://github.com/queckezz/list/blob/a26130020b447a1aa136f0fed3283821490f7da4/lib/drop.js#L13-L17 |
55,919 | Pocketbrain/native-ads-web-ad-library | src/ads/fetchAds.js | _getRequiredAdCountForAdUnit | function _getRequiredAdCountForAdUnit(adUnit) {
var adContainers = page.getAdContainers(adUnit);
if (!adContainers.length) {
return 0;
}
var numberOfAdsToInsert = 0;
for (var i = 0; i < adContainers.length; i++) {
var adContainer = adContainers[i];
numberOfAdsToInsert += adContainer.getNumberOfAdsToInsert();
}
return numberOfAdsToInsert;
} | javascript | function _getRequiredAdCountForAdUnit(adUnit) {
var adContainers = page.getAdContainers(adUnit);
if (!adContainers.length) {
return 0;
}
var numberOfAdsToInsert = 0;
for (var i = 0; i < adContainers.length; i++) {
var adContainer = adContainers[i];
numberOfAdsToInsert += adContainer.getNumberOfAdsToInsert();
}
return numberOfAdsToInsert;
} | [
"function",
"_getRequiredAdCountForAdUnit",
"(",
"adUnit",
")",
"{",
"var",
"adContainers",
"=",
"page",
".",
"getAdContainers",
"(",
"adUnit",
")",
";",
"if",
"(",
"!",
"adContainers",
".",
"length",
")",
"{",
"return",
"0",
";",
"}",
"var",
"numberOfAdsToInsert",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"adContainers",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"adContainer",
"=",
"adContainers",
"[",
"i",
"]",
";",
"numberOfAdsToInsert",
"+=",
"adContainer",
".",
"getNumberOfAdsToInsert",
"(",
")",
";",
"}",
"return",
"numberOfAdsToInsert",
";",
"}"
] | Get the number of ads this unit needs to place all the ads on the page
@param adUnit The ad unit to get the required number of ads for
@returns {number} the number of required ads
@private | [
"Get",
"the",
"number",
"of",
"ads",
"this",
"unit",
"needs",
"to",
"place",
"all",
"the",
"ads",
"on",
"the",
"page"
] | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/ads/fetchAds.js#L17-L31 |
55,920 | Pocketbrain/native-ads-web-ad-library | src/ads/fetchAds.js | _buildImageFields | function _buildImageFields(data){
var newUnits = [];
for (var i = 0, len = data.length; i < len; i++){
adUnit = data[i];
// todo: create adUnit object to encapsulate this logic
if ('images' in adUnit){
if ('banner' in adUnit.images){
adUnit.campaign_banner_url = adUnit.images.banner.url;
}
if ('icon' in adUnit.images){
adUnit.campaign_icon_url = adUnit.images.icon.url;
}
if ('hq_icon' in adUnit.images){
adUnit.campaign_hq_icon_url = adUnit.images.hq_icon.url;
}
}
newUnits.push(adUnit);
}
return newUnits;
} | javascript | function _buildImageFields(data){
var newUnits = [];
for (var i = 0, len = data.length; i < len; i++){
adUnit = data[i];
// todo: create adUnit object to encapsulate this logic
if ('images' in adUnit){
if ('banner' in adUnit.images){
adUnit.campaign_banner_url = adUnit.images.banner.url;
}
if ('icon' in adUnit.images){
adUnit.campaign_icon_url = adUnit.images.icon.url;
}
if ('hq_icon' in adUnit.images){
adUnit.campaign_hq_icon_url = adUnit.images.hq_icon.url;
}
}
newUnits.push(adUnit);
}
return newUnits;
} | [
"function",
"_buildImageFields",
"(",
"data",
")",
"{",
"var",
"newUnits",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"data",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"adUnit",
"=",
"data",
"[",
"i",
"]",
";",
"// todo: create adUnit object to encapsulate this logic",
"if",
"(",
"'images'",
"in",
"adUnit",
")",
"{",
"if",
"(",
"'banner'",
"in",
"adUnit",
".",
"images",
")",
"{",
"adUnit",
".",
"campaign_banner_url",
"=",
"adUnit",
".",
"images",
".",
"banner",
".",
"url",
";",
"}",
"if",
"(",
"'icon'",
"in",
"adUnit",
".",
"images",
")",
"{",
"adUnit",
".",
"campaign_icon_url",
"=",
"adUnit",
".",
"images",
".",
"icon",
".",
"url",
";",
"}",
"if",
"(",
"'hq_icon'",
"in",
"adUnit",
".",
"images",
")",
"{",
"adUnit",
".",
"campaign_hq_icon_url",
"=",
"adUnit",
".",
"images",
".",
"hq_icon",
".",
"url",
";",
"}",
"}",
"newUnits",
".",
"push",
"(",
"adUnit",
")",
";",
"}",
"return",
"newUnits",
";",
"}"
] | Fills some image fields with JSON data
@param data The data coming from the server
@returns processed data
@private | [
"Fills",
"some",
"image",
"fields",
"with",
"JSON",
"data"
] | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/ads/fetchAds.js#L39-L63 |
55,921 | Pocketbrain/native-ads-web-ad-library | src/ads/fetchAds.js | requestAds | function requestAds(adUnit, callback) {
var limit = _getRequiredAdCountForAdUnit(adUnit);
var token = page.getToken();
var imageType = adUnit.imageType;
if (typeof imageType == 'undefined'){
imageType = "hq_icon";
}
var requestQuery = {
"output": "json",
"placement_key": adUnit.placementKey,
"limit": limit,
"token": token,
"auto_device": 1,
"image_type": imageType
};
//noinspection JSUnresolvedVariable
var overrides = appSettings.overrides;
if (overrides && overrides.formFactor && overrides.platform && overrides.fullDeviceName && overrides.version) {
delete requestQuery.auto_device;
requestQuery.os = overrides.platform;
requestQuery.model = overrides.fullDeviceName;
requestQuery.version = overrides.version;
}
ajax.get({
url: appSettings.adApiBaseUrl,
query: requestQuery,
success: function (data) {
if (data.length !== limit) {
logger.warn("Tried to fetch " + limit + " ads, but received " + data.length);
}
data = _buildImageFields(data);
callback(data);
},
error: function (e) {
logger.wtf('An error occurred trying to fetch ads');
}
});
} | javascript | function requestAds(adUnit, callback) {
var limit = _getRequiredAdCountForAdUnit(adUnit);
var token = page.getToken();
var imageType = adUnit.imageType;
if (typeof imageType == 'undefined'){
imageType = "hq_icon";
}
var requestQuery = {
"output": "json",
"placement_key": adUnit.placementKey,
"limit": limit,
"token": token,
"auto_device": 1,
"image_type": imageType
};
//noinspection JSUnresolvedVariable
var overrides = appSettings.overrides;
if (overrides && overrides.formFactor && overrides.platform && overrides.fullDeviceName && overrides.version) {
delete requestQuery.auto_device;
requestQuery.os = overrides.platform;
requestQuery.model = overrides.fullDeviceName;
requestQuery.version = overrides.version;
}
ajax.get({
url: appSettings.adApiBaseUrl,
query: requestQuery,
success: function (data) {
if (data.length !== limit) {
logger.warn("Tried to fetch " + limit + " ads, but received " + data.length);
}
data = _buildImageFields(data);
callback(data);
},
error: function (e) {
logger.wtf('An error occurred trying to fetch ads');
}
});
} | [
"function",
"requestAds",
"(",
"adUnit",
",",
"callback",
")",
"{",
"var",
"limit",
"=",
"_getRequiredAdCountForAdUnit",
"(",
"adUnit",
")",
";",
"var",
"token",
"=",
"page",
".",
"getToken",
"(",
")",
";",
"var",
"imageType",
"=",
"adUnit",
".",
"imageType",
";",
"if",
"(",
"typeof",
"imageType",
"==",
"'undefined'",
")",
"{",
"imageType",
"=",
"\"hq_icon\"",
";",
"}",
"var",
"requestQuery",
"=",
"{",
"\"output\"",
":",
"\"json\"",
",",
"\"placement_key\"",
":",
"adUnit",
".",
"placementKey",
",",
"\"limit\"",
":",
"limit",
",",
"\"token\"",
":",
"token",
",",
"\"auto_device\"",
":",
"1",
",",
"\"image_type\"",
":",
"imageType",
"}",
";",
"//noinspection JSUnresolvedVariable",
"var",
"overrides",
"=",
"appSettings",
".",
"overrides",
";",
"if",
"(",
"overrides",
"&&",
"overrides",
".",
"formFactor",
"&&",
"overrides",
".",
"platform",
"&&",
"overrides",
".",
"fullDeviceName",
"&&",
"overrides",
".",
"version",
")",
"{",
"delete",
"requestQuery",
".",
"auto_device",
";",
"requestQuery",
".",
"os",
"=",
"overrides",
".",
"platform",
";",
"requestQuery",
".",
"model",
"=",
"overrides",
".",
"fullDeviceName",
";",
"requestQuery",
".",
"version",
"=",
"overrides",
".",
"version",
";",
"}",
"ajax",
".",
"get",
"(",
"{",
"url",
":",
"appSettings",
".",
"adApiBaseUrl",
",",
"query",
":",
"requestQuery",
",",
"success",
":",
"function",
"(",
"data",
")",
"{",
"if",
"(",
"data",
".",
"length",
"!==",
"limit",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Tried to fetch \"",
"+",
"limit",
"+",
"\" ads, but received \"",
"+",
"data",
".",
"length",
")",
";",
"}",
"data",
"=",
"_buildImageFields",
"(",
"data",
")",
";",
"callback",
"(",
"data",
")",
";",
"}",
",",
"error",
":",
"function",
"(",
"e",
")",
"{",
"logger",
".",
"wtf",
"(",
"'An error occurred trying to fetch ads'",
")",
";",
"}",
"}",
")",
";",
"}"
] | Request ads from the offerEngine
@param adUnit - The ad Unit that is requesting ads
@param callback - The callback to execute containing the ads | [
"Request",
"ads",
"from",
"the",
"offerEngine"
] | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/ads/fetchAds.js#L70-L109 |
55,922 | FinalDevStudio/fi-security | lib/index.js | clean | function clean(method) {
for (let m of methods) {
if (new RegExp(m, 'i').test(method)) {
return m;
}
}
throw new Error(`Invalid method name: ${method}`);
} | javascript | function clean(method) {
for (let m of methods) {
if (new RegExp(m, 'i').test(method)) {
return m;
}
}
throw new Error(`Invalid method name: ${method}`);
} | [
"function",
"clean",
"(",
"method",
")",
"{",
"for",
"(",
"let",
"m",
"of",
"methods",
")",
"{",
"if",
"(",
"new",
"RegExp",
"(",
"m",
",",
"'i'",
")",
".",
"test",
"(",
"method",
")",
")",
"{",
"return",
"m",
";",
"}",
"}",
"throw",
"new",
"Error",
"(",
"`",
"${",
"method",
"}",
"`",
")",
";",
"}"
] | Returns a clean, lower-case method name.
@param {String} method The method to check and clean.
@returns {String} The clean method name. | [
"Returns",
"a",
"clean",
"lower",
"-",
"case",
"method",
"name",
"."
] | 4673865a2e618138012bc89b1ba7160eb632ab5a | https://github.com/FinalDevStudio/fi-security/blob/4673865a2e618138012bc89b1ba7160eb632ab5a/lib/index.js#L41-L49 |
55,923 | FinalDevStudio/fi-security | lib/index.js | middleware | function middleware(req, res, next) {
req.security.csrf.exclude = true;
next();
} | javascript | function middleware(req, res, next) {
req.security.csrf.exclude = true;
next();
} | [
"function",
"middleware",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"req",
".",
"security",
".",
"csrf",
".",
"exclude",
"=",
"true",
";",
"next",
"(",
")",
";",
"}"
] | Default exclusion middleware.
@type {ExpressMiddlware}
@param {Object} req Express' request object.
@param {Object} res Express' response object.
@param {Function} next Express' next middleware callback. | [
"Default",
"exclusion",
"middleware",
"."
] | 4673865a2e618138012bc89b1ba7160eb632ab5a | https://github.com/FinalDevStudio/fi-security/blob/4673865a2e618138012bc89b1ba7160eb632ab5a/lib/index.js#L60-L63 |
55,924 | FinalDevStudio/fi-security | lib/index.js | onEachExcludedRoute | function onEachExcludedRoute(app, route) {
const normalized = normalize(route);
debug(`Excluding ${(normalized.method || 'all').toUpperCase()} ${normalized.path} from CSRF check...`);
const router = app.route(normalized.path);
if (is.array(normalized.method) && normalized.method.length) {
for (let i = 0, l = normalized.method.length; i < l; i++) {
exclude(router, normalized.method[i]);
}
}
if (is.string(normalized.method)) {
exclude(router, normalized.method);
return;
}
/* Defaults to all */
exclude(router, 'all');
} | javascript | function onEachExcludedRoute(app, route) {
const normalized = normalize(route);
debug(`Excluding ${(normalized.method || 'all').toUpperCase()} ${normalized.path} from CSRF check...`);
const router = app.route(normalized.path);
if (is.array(normalized.method) && normalized.method.length) {
for (let i = 0, l = normalized.method.length; i < l; i++) {
exclude(router, normalized.method[i]);
}
}
if (is.string(normalized.method)) {
exclude(router, normalized.method);
return;
}
/* Defaults to all */
exclude(router, 'all');
} | [
"function",
"onEachExcludedRoute",
"(",
"app",
",",
"route",
")",
"{",
"const",
"normalized",
"=",
"normalize",
"(",
"route",
")",
";",
"debug",
"(",
"`",
"${",
"(",
"normalized",
".",
"method",
"||",
"'all'",
")",
".",
"toUpperCase",
"(",
")",
"}",
"${",
"normalized",
".",
"path",
"}",
"`",
")",
";",
"const",
"router",
"=",
"app",
".",
"route",
"(",
"normalized",
".",
"path",
")",
";",
"if",
"(",
"is",
".",
"array",
"(",
"normalized",
".",
"method",
")",
"&&",
"normalized",
".",
"method",
".",
"length",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"l",
"=",
"normalized",
".",
"method",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"exclude",
"(",
"router",
",",
"normalized",
".",
"method",
"[",
"i",
"]",
")",
";",
"}",
"}",
"if",
"(",
"is",
".",
"string",
"(",
"normalized",
".",
"method",
")",
")",
"{",
"exclude",
"(",
"router",
",",
"normalized",
".",
"method",
")",
";",
"return",
";",
"}",
"/* Defaults to all */",
"exclude",
"(",
"router",
",",
"'all'",
")",
";",
"}"
] | Processes each excluded route.
@param {ExpressApplication} app Your express application instance.
@param {Object} route The route object to process. | [
"Processes",
"each",
"excluded",
"route",
"."
] | 4673865a2e618138012bc89b1ba7160eb632ab5a | https://github.com/FinalDevStudio/fi-security/blob/4673865a2e618138012bc89b1ba7160eb632ab5a/lib/index.js#L110-L130 |
55,925 | MaiaVictor/dattata | Geometries.js | block | function block(w, h, d){
return function(cons, nil){
for (var z=-d; z<=d; ++z)
for (var y=-h; y<=h; ++y)
for (var x=-w; x<=w; ++x)
nil = cons(x, y, z),
nil = cons(x, y, z);
return nil;
};
} | javascript | function block(w, h, d){
return function(cons, nil){
for (var z=-d; z<=d; ++z)
for (var y=-h; y<=h; ++y)
for (var x=-w; x<=w; ++x)
nil = cons(x, y, z),
nil = cons(x, y, z);
return nil;
};
} | [
"function",
"block",
"(",
"w",
",",
"h",
",",
"d",
")",
"{",
"return",
"function",
"(",
"cons",
",",
"nil",
")",
"{",
"for",
"(",
"var",
"z",
"=",
"-",
"d",
";",
"z",
"<=",
"d",
";",
"++",
"z",
")",
"for",
"(",
"var",
"y",
"=",
"-",
"h",
";",
"y",
"<=",
"h",
";",
"++",
"y",
")",
"for",
"(",
"var",
"x",
"=",
"-",
"w",
";",
"x",
"<=",
"w",
";",
"++",
"x",
")",
"nil",
"=",
"cons",
"(",
"x",
",",
"y",
",",
"z",
")",
",",
"nil",
"=",
"cons",
"(",
"x",
",",
"y",
",",
"z",
")",
";",
"return",
"nil",
";",
"}",
";",
"}"
] | Number, Number, Number -> AtomsCList | [
"Number",
"Number",
"Number",
"-",
">",
"AtomsCList"
] | 890d83b89b7193ce8863bb9ac9b296b3510e8db9 | https://github.com/MaiaVictor/dattata/blob/890d83b89b7193ce8863bb9ac9b296b3510e8db9/Geometries.js#L53-L62 |
55,926 | MaiaVictor/dattata | Geometries.js | sphereVoxels | function sphereVoxels(cx, cy, cz, r, col){
return function(cons, nil){
sphere(cx, cy, cz, r)(function(x, y, z, res){
return cons(x, y, z, col, res);
}, nil);
};
} | javascript | function sphereVoxels(cx, cy, cz, r, col){
return function(cons, nil){
sphere(cx, cy, cz, r)(function(x, y, z, res){
return cons(x, y, z, col, res);
}, nil);
};
} | [
"function",
"sphereVoxels",
"(",
"cx",
",",
"cy",
",",
"cz",
",",
"r",
",",
"col",
")",
"{",
"return",
"function",
"(",
"cons",
",",
"nil",
")",
"{",
"sphere",
"(",
"cx",
",",
"cy",
",",
"cz",
",",
"r",
")",
"(",
"function",
"(",
"x",
",",
"y",
",",
"z",
",",
"res",
")",
"{",
"return",
"cons",
"(",
"x",
",",
"y",
",",
"z",
",",
"col",
",",
"res",
")",
";",
"}",
",",
"nil",
")",
";",
"}",
";",
"}"
] | Number, Number, Number, Number, RGBA8 -> Voxels | [
"Number",
"Number",
"Number",
"Number",
"RGBA8",
"-",
">",
"Voxels"
] | 890d83b89b7193ce8863bb9ac9b296b3510e8db9 | https://github.com/MaiaVictor/dattata/blob/890d83b89b7193ce8863bb9ac9b296b3510e8db9/Geometries.js#L66-L72 |
55,927 | wigy/chronicles_of_grunt | tasks/info.js | dumpFiles | function dumpFiles(title, fn) {
var matches = fn();
if (matches.length) {
log.info("");
log.info((title + ":")['green']);
for (var i = 0; i < matches.length; i++) {
if (matches[i].src === matches[i].dst) {
log.info(matches[i].dst);
} else {
log.info(matches[i].dst + ' (from ' + matches[i].src + ')');
}
}
}
} | javascript | function dumpFiles(title, fn) {
var matches = fn();
if (matches.length) {
log.info("");
log.info((title + ":")['green']);
for (var i = 0; i < matches.length; i++) {
if (matches[i].src === matches[i].dst) {
log.info(matches[i].dst);
} else {
log.info(matches[i].dst + ' (from ' + matches[i].src + ')');
}
}
}
} | [
"function",
"dumpFiles",
"(",
"title",
",",
"fn",
")",
"{",
"var",
"matches",
"=",
"fn",
"(",
")",
";",
"if",
"(",
"matches",
".",
"length",
")",
"{",
"log",
".",
"info",
"(",
"\"\"",
")",
";",
"log",
".",
"info",
"(",
"(",
"title",
"+",
"\":\"",
")",
"[",
"'green'",
"]",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"matches",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"matches",
"[",
"i",
"]",
".",
"src",
"===",
"matches",
"[",
"i",
"]",
".",
"dst",
")",
"{",
"log",
".",
"info",
"(",
"matches",
"[",
"i",
"]",
".",
"dst",
")",
";",
"}",
"else",
"{",
"log",
".",
"info",
"(",
"matches",
"[",
"i",
"]",
".",
"dst",
"+",
"' (from '",
"+",
"matches",
"[",
"i",
"]",
".",
"src",
"+",
"')'",
")",
";",
"}",
"}",
"}",
"}"
] | List files returned by the given listing function on screen. | [
"List",
"files",
"returned",
"by",
"the",
"given",
"listing",
"function",
"on",
"screen",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/tasks/info.js#L33-L46 |
55,928 | sydneystockholm/blog.md | lib/loaders/fs.js | FileSystemLoader | function FileSystemLoader(dir, options) {
this.dir = dir.replace(/\/$/, '');
this.options = options || (options = {});
this.posts = [];
this.files = {};
this.ignore = {};
var self = this;
(options.ignore || FileSystemLoader.ignore).forEach(function (file) {
self.ignore[file] = true;
});
process.nextTick(function () {
self.loadPosts();
});
} | javascript | function FileSystemLoader(dir, options) {
this.dir = dir.replace(/\/$/, '');
this.options = options || (options = {});
this.posts = [];
this.files = {};
this.ignore = {};
var self = this;
(options.ignore || FileSystemLoader.ignore).forEach(function (file) {
self.ignore[file] = true;
});
process.nextTick(function () {
self.loadPosts();
});
} | [
"function",
"FileSystemLoader",
"(",
"dir",
",",
"options",
")",
"{",
"this",
".",
"dir",
"=",
"dir",
".",
"replace",
"(",
"/",
"\\/$",
"/",
",",
"''",
")",
";",
"this",
".",
"options",
"=",
"options",
"||",
"(",
"options",
"=",
"{",
"}",
")",
";",
"this",
".",
"posts",
"=",
"[",
"]",
";",
"this",
".",
"files",
"=",
"{",
"}",
";",
"this",
".",
"ignore",
"=",
"{",
"}",
";",
"var",
"self",
"=",
"this",
";",
"(",
"options",
".",
"ignore",
"||",
"FileSystemLoader",
".",
"ignore",
")",
".",
"forEach",
"(",
"function",
"(",
"file",
")",
"{",
"self",
".",
"ignore",
"[",
"file",
"]",
"=",
"true",
";",
"}",
")",
";",
"process",
".",
"nextTick",
"(",
"function",
"(",
")",
"{",
"self",
".",
"loadPosts",
"(",
")",
";",
"}",
")",
";",
"}"
] | Create a new file system loader.
@param {String} dir - the folder containing blog posts
@param {Object} options (optional) | [
"Create",
"a",
"new",
"file",
"system",
"loader",
"."
] | 0b145fa1620cbe8b7296eb242241ee93223db9f9 | https://github.com/sydneystockholm/blog.md/blob/0b145fa1620cbe8b7296eb242241ee93223db9f9/lib/loaders/fs.js#L22-L35 |
55,929 | cameronwp/endpoint | lib/Endpoint.js | Endpoint | function Endpoint() {
var self = this;
const subscriptions = {};
const ps = new Pubsub();
this._publish = ps.publish;
this._subscribe = ps.subscribe;
this.active = false;
this.connections = [];
/**
* Publishes a new connection.
* @function _newConnection
* @private
* @param {string} sID socket ID
* @returns this
*/
this._newConnection = sId => {
self.connections.push(sId || 'unknown');
self.active = true;
self._publish('change', {count: self.connections.length});
return this;
};
/**
* Records a lost connection.
* @function _lostConnection
* @private
* @param {string} sID socket ID
* @returns this
*/
this._lostConnection = sId => {
const index = this.connections.indexOf(sId);
this.connections.splice(index, 1);
if (this.connections.length === 0) {
this.active = false;
}
self._publish('change', {count: self.connections.length});
return this;
};
/**
* Subscribe an action to perform when a message is received.
* @function onmessage
* @param {string} type
* @param {messageResponse}
* @param {boolean} [historical=false] Whether or not to call the listener if this message has been received before this listener was set.
* @returns {subscription}
*/
this.onmessage = (type, cb, historical = false) => {
return self._subscribe(type, cb, historical);
};
/**
* Subscribe an action to perform when the connection changes.
* @function onchange
* @param {changeCallback}
* @returns {subscription}
*/
this.onchange = cb => {
return self._subscribe('change', cb);
};
/**
* Remove all subscriptions to connection events.
* @function clear
*/
this.clear = ps.clear;
} | javascript | function Endpoint() {
var self = this;
const subscriptions = {};
const ps = new Pubsub();
this._publish = ps.publish;
this._subscribe = ps.subscribe;
this.active = false;
this.connections = [];
/**
* Publishes a new connection.
* @function _newConnection
* @private
* @param {string} sID socket ID
* @returns this
*/
this._newConnection = sId => {
self.connections.push(sId || 'unknown');
self.active = true;
self._publish('change', {count: self.connections.length});
return this;
};
/**
* Records a lost connection.
* @function _lostConnection
* @private
* @param {string} sID socket ID
* @returns this
*/
this._lostConnection = sId => {
const index = this.connections.indexOf(sId);
this.connections.splice(index, 1);
if (this.connections.length === 0) {
this.active = false;
}
self._publish('change', {count: self.connections.length});
return this;
};
/**
* Subscribe an action to perform when a message is received.
* @function onmessage
* @param {string} type
* @param {messageResponse}
* @param {boolean} [historical=false] Whether or not to call the listener if this message has been received before this listener was set.
* @returns {subscription}
*/
this.onmessage = (type, cb, historical = false) => {
return self._subscribe(type, cb, historical);
};
/**
* Subscribe an action to perform when the connection changes.
* @function onchange
* @param {changeCallback}
* @returns {subscription}
*/
this.onchange = cb => {
return self._subscribe('change', cb);
};
/**
* Remove all subscriptions to connection events.
* @function clear
*/
this.clear = ps.clear;
} | [
"function",
"Endpoint",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"const",
"subscriptions",
"=",
"{",
"}",
";",
"const",
"ps",
"=",
"new",
"Pubsub",
"(",
")",
";",
"this",
".",
"_publish",
"=",
"ps",
".",
"publish",
";",
"this",
".",
"_subscribe",
"=",
"ps",
".",
"subscribe",
";",
"this",
".",
"active",
"=",
"false",
";",
"this",
".",
"connections",
"=",
"[",
"]",
";",
"/**\n * Publishes a new connection.\n * @function _newConnection\n * @private\n * @param {string} sID socket ID\n * @returns this\n */",
"this",
".",
"_newConnection",
"=",
"sId",
"=>",
"{",
"self",
".",
"connections",
".",
"push",
"(",
"sId",
"||",
"'unknown'",
")",
";",
"self",
".",
"active",
"=",
"true",
";",
"self",
".",
"_publish",
"(",
"'change'",
",",
"{",
"count",
":",
"self",
".",
"connections",
".",
"length",
"}",
")",
";",
"return",
"this",
";",
"}",
";",
"/**\n * Records a lost connection.\n * @function _lostConnection\n * @private\n * @param {string} sID socket ID\n * @returns this\n */",
"this",
".",
"_lostConnection",
"=",
"sId",
"=>",
"{",
"const",
"index",
"=",
"this",
".",
"connections",
".",
"indexOf",
"(",
"sId",
")",
";",
"this",
".",
"connections",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"if",
"(",
"this",
".",
"connections",
".",
"length",
"===",
"0",
")",
"{",
"this",
".",
"active",
"=",
"false",
";",
"}",
"self",
".",
"_publish",
"(",
"'change'",
",",
"{",
"count",
":",
"self",
".",
"connections",
".",
"length",
"}",
")",
";",
"return",
"this",
";",
"}",
";",
"/**\n * Subscribe an action to perform when a message is received.\n * @function onmessage\n * @param {string} type\n * @param {messageResponse}\n * @param {boolean} [historical=false] Whether or not to call the listener if this message has been received before this listener was set.\n * @returns {subscription}\n */",
"this",
".",
"onmessage",
"=",
"(",
"type",
",",
"cb",
",",
"historical",
"=",
"false",
")",
"=>",
"{",
"return",
"self",
".",
"_subscribe",
"(",
"type",
",",
"cb",
",",
"historical",
")",
";",
"}",
";",
"/**\n * Subscribe an action to perform when the connection changes.\n * @function onchange\n * @param {changeCallback}\n * @returns {subscription}\n */",
"this",
".",
"onchange",
"=",
"cb",
"=>",
"{",
"return",
"self",
".",
"_subscribe",
"(",
"'change'",
",",
"cb",
")",
";",
"}",
";",
"/**\n * Remove all subscriptions to connection events.\n * @function clear\n */",
"this",
".",
"clear",
"=",
"ps",
".",
"clear",
";",
"}"
] | Message response callback.
@callback messageResponse
@param {any} response
Base class for handling socket.io connections.
@class Endpoint | [
"Message",
"response",
"callback",
"."
] | 6163756360080aa7e984660f1cede7e4ab627da5 | https://github.com/cameronwp/endpoint/blob/6163756360080aa7e984660f1cede7e4ab627da5/lib/Endpoint.js#L27-L96 |
55,930 | christophercrouzet/pillr | lib/queue.js | find | function find(queue, name) {
const out = queue.findIndex(e => e.name === name);
if (out === -1) {
throw new Error(`${name}: Could not find this function`);
}
return out;
} | javascript | function find(queue, name) {
const out = queue.findIndex(e => e.name === name);
if (out === -1) {
throw new Error(`${name}: Could not find this function`);
}
return out;
} | [
"function",
"find",
"(",
"queue",
",",
"name",
")",
"{",
"const",
"out",
"=",
"queue",
".",
"findIndex",
"(",
"e",
"=>",
"e",
".",
"name",
"===",
"name",
")",
";",
"if",
"(",
"out",
"===",
"-",
"1",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"name",
"}",
"`",
")",
";",
"}",
"return",
"out",
";",
"}"
] | Find the index of a function. | [
"Find",
"the",
"index",
"of",
"a",
"function",
"."
] | 411ccd344a03478776c4e8d2e2f9bdc45dc8ee45 | https://github.com/christophercrouzet/pillr/blob/411ccd344a03478776c4e8d2e2f9bdc45dc8ee45/lib/queue.js#L13-L20 |
55,931 | christophercrouzet/pillr | lib/queue.js | insert | function insert(queue, index, fns, mode = InsertMode.REGULAR) {
fns.forEach(({ fn, name }) => {
if (queue.findIndex(e => e.name === name) !== -1) {
throw new Error(`${name}: A function is already queued with this name`);
} else if (typeof fn !== 'function') {
throw new Error(`${name}: Not a valid function`);
}
});
const deleteCount = mode === InsertMode.REPLACE ? 1 : 0;
queue.splice(index, deleteCount, ...fns);
} | javascript | function insert(queue, index, fns, mode = InsertMode.REGULAR) {
fns.forEach(({ fn, name }) => {
if (queue.findIndex(e => e.name === name) !== -1) {
throw new Error(`${name}: A function is already queued with this name`);
} else if (typeof fn !== 'function') {
throw new Error(`${name}: Not a valid function`);
}
});
const deleteCount = mode === InsertMode.REPLACE ? 1 : 0;
queue.splice(index, deleteCount, ...fns);
} | [
"function",
"insert",
"(",
"queue",
",",
"index",
",",
"fns",
",",
"mode",
"=",
"InsertMode",
".",
"REGULAR",
")",
"{",
"fns",
".",
"forEach",
"(",
"(",
"{",
"fn",
",",
"name",
"}",
")",
"=>",
"{",
"if",
"(",
"queue",
".",
"findIndex",
"(",
"e",
"=>",
"e",
".",
"name",
"===",
"name",
")",
"!==",
"-",
"1",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"name",
"}",
"`",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"fn",
"!==",
"'function'",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"name",
"}",
"`",
")",
";",
"}",
"}",
")",
";",
"const",
"deleteCount",
"=",
"mode",
"===",
"InsertMode",
".",
"REPLACE",
"?",
"1",
":",
"0",
";",
"queue",
".",
"splice",
"(",
"index",
",",
"deleteCount",
",",
"...",
"fns",
")",
";",
"}"
] | Insert a bunch of functions into a queue at a given index. | [
"Insert",
"a",
"bunch",
"of",
"functions",
"into",
"a",
"queue",
"at",
"a",
"given",
"index",
"."
] | 411ccd344a03478776c4e8d2e2f9bdc45dc8ee45 | https://github.com/christophercrouzet/pillr/blob/411ccd344a03478776c4e8d2e2f9bdc45dc8ee45/lib/queue.js#L24-L35 |
55,932 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/htmlparser/fragment.js | addElement | function addElement( element, target, moveCurrent ) {
target = target || currentNode || root;
// Current element might be mangled by fix body below,
// save it for restore later.
var savedCurrent = currentNode;
// Ignore any element that has already been added.
if ( element.previous === undefined ) {
if ( checkAutoParagraphing( target, element ) ) {
// Create a <p> in the fragment.
currentNode = target;
parser.onTagOpen( fixingBlock, {} );
// The new target now is the <p>.
element.returnPoint = target = currentNode;
}
removeTailWhitespace( element );
// Avoid adding empty inline.
if ( !( isRemoveEmpty( element ) && !element.children.length ) )
target.add( element );
if ( element.name == 'pre' )
inPre = false;
if ( element.name == 'textarea' )
inTextarea = false;
}
if ( element.returnPoint ) {
currentNode = element.returnPoint;
delete element.returnPoint;
} else {
currentNode = moveCurrent ? target : savedCurrent;
}
} | javascript | function addElement( element, target, moveCurrent ) {
target = target || currentNode || root;
// Current element might be mangled by fix body below,
// save it for restore later.
var savedCurrent = currentNode;
// Ignore any element that has already been added.
if ( element.previous === undefined ) {
if ( checkAutoParagraphing( target, element ) ) {
// Create a <p> in the fragment.
currentNode = target;
parser.onTagOpen( fixingBlock, {} );
// The new target now is the <p>.
element.returnPoint = target = currentNode;
}
removeTailWhitespace( element );
// Avoid adding empty inline.
if ( !( isRemoveEmpty( element ) && !element.children.length ) )
target.add( element );
if ( element.name == 'pre' )
inPre = false;
if ( element.name == 'textarea' )
inTextarea = false;
}
if ( element.returnPoint ) {
currentNode = element.returnPoint;
delete element.returnPoint;
} else {
currentNode = moveCurrent ? target : savedCurrent;
}
} | [
"function",
"addElement",
"(",
"element",
",",
"target",
",",
"moveCurrent",
")",
"{",
"target",
"=",
"target",
"||",
"currentNode",
"||",
"root",
";",
"// Current element might be mangled by fix body below,",
"// save it for restore later.",
"var",
"savedCurrent",
"=",
"currentNode",
";",
"// Ignore any element that has already been added.",
"if",
"(",
"element",
".",
"previous",
"===",
"undefined",
")",
"{",
"if",
"(",
"checkAutoParagraphing",
"(",
"target",
",",
"element",
")",
")",
"{",
"// Create a <p> in the fragment.",
"currentNode",
"=",
"target",
";",
"parser",
".",
"onTagOpen",
"(",
"fixingBlock",
",",
"{",
"}",
")",
";",
"// The new target now is the <p>.",
"element",
".",
"returnPoint",
"=",
"target",
"=",
"currentNode",
";",
"}",
"removeTailWhitespace",
"(",
"element",
")",
";",
"// Avoid adding empty inline.",
"if",
"(",
"!",
"(",
"isRemoveEmpty",
"(",
"element",
")",
"&&",
"!",
"element",
".",
"children",
".",
"length",
")",
")",
"target",
".",
"add",
"(",
"element",
")",
";",
"if",
"(",
"element",
".",
"name",
"==",
"'pre'",
")",
"inPre",
"=",
"false",
";",
"if",
"(",
"element",
".",
"name",
"==",
"'textarea'",
")",
"inTextarea",
"=",
"false",
";",
"}",
"if",
"(",
"element",
".",
"returnPoint",
")",
"{",
"currentNode",
"=",
"element",
".",
"returnPoint",
";",
"delete",
"element",
".",
"returnPoint",
";",
"}",
"else",
"{",
"currentNode",
"=",
"moveCurrent",
"?",
"target",
":",
"savedCurrent",
";",
"}",
"}"
] | Beside of simply append specified element to target, this function also takes care of other dirty lifts like forcing block in body, trimming spaces at the block boundaries etc. @param {Element} element The element to be added as the last child of {@link target}. @param {Element} target The parent element to relieve the new node. @param {Boolean} [moveCurrent=false] Don't change the "currentNode" global unless there's a return point node specified on the element, otherwise move current onto {@link target} node. | [
"Beside",
"of",
"simply",
"append",
"specified",
"element",
"to",
"target",
"this",
"function",
"also",
"takes",
"care",
"of",
"other",
"dirty",
"lifts",
"like",
"forcing",
"block",
"in",
"body",
"trimming",
"spaces",
"at",
"the",
"block",
"boundaries",
"etc",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/fragment.js#L171-L208 |
55,933 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/htmlparser/fragment.js | checkAutoParagraphing | function checkAutoParagraphing( parent, node ) {
// Check for parent that can contain block.
if ( ( parent == root || parent.name == 'body' ) && fixingBlock &&
( !parent.name || CKEDITOR.dtd[ parent.name ][ fixingBlock ] ) ) {
var name, realName;
if ( node.attributes && ( realName = node.attributes[ 'data-cke-real-element-type' ] ) )
name = realName;
else
name = node.name;
// Text node, inline elements are subjected, except for <script>/<style>.
return name && name in CKEDITOR.dtd.$inline &&
!( name in CKEDITOR.dtd.head ) &&
!node.isOrphan ||
node.type == CKEDITOR.NODE_TEXT;
}
} | javascript | function checkAutoParagraphing( parent, node ) {
// Check for parent that can contain block.
if ( ( parent == root || parent.name == 'body' ) && fixingBlock &&
( !parent.name || CKEDITOR.dtd[ parent.name ][ fixingBlock ] ) ) {
var name, realName;
if ( node.attributes && ( realName = node.attributes[ 'data-cke-real-element-type' ] ) )
name = realName;
else
name = node.name;
// Text node, inline elements are subjected, except for <script>/<style>.
return name && name in CKEDITOR.dtd.$inline &&
!( name in CKEDITOR.dtd.head ) &&
!node.isOrphan ||
node.type == CKEDITOR.NODE_TEXT;
}
} | [
"function",
"checkAutoParagraphing",
"(",
"parent",
",",
"node",
")",
"{",
"// Check for parent that can contain block.",
"if",
"(",
"(",
"parent",
"==",
"root",
"||",
"parent",
".",
"name",
"==",
"'body'",
")",
"&&",
"fixingBlock",
"&&",
"(",
"!",
"parent",
".",
"name",
"||",
"CKEDITOR",
".",
"dtd",
"[",
"parent",
".",
"name",
"]",
"[",
"fixingBlock",
"]",
")",
")",
"{",
"var",
"name",
",",
"realName",
";",
"if",
"(",
"node",
".",
"attributes",
"&&",
"(",
"realName",
"=",
"node",
".",
"attributes",
"[",
"'data-cke-real-element-type'",
"]",
")",
")",
"name",
"=",
"realName",
";",
"else",
"name",
"=",
"node",
".",
"name",
";",
"// Text node, inline elements are subjected, except for <script>/<style>.",
"return",
"name",
"&&",
"name",
"in",
"CKEDITOR",
".",
"dtd",
".",
"$inline",
"&&",
"!",
"(",
"name",
"in",
"CKEDITOR",
".",
"dtd",
".",
"head",
")",
"&&",
"!",
"node",
".",
"isOrphan",
"||",
"node",
".",
"type",
"==",
"CKEDITOR",
".",
"NODE_TEXT",
";",
"}",
"}"
] | Auto paragraphing should happen when inline content enters the root element. | [
"Auto",
"paragraphing",
"should",
"happen",
"when",
"inline",
"content",
"enters",
"the",
"root",
"element",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/fragment.js#L211-L229 |
55,934 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/htmlparser/fragment.js | possiblySibling | function possiblySibling( tag1, tag2 ) {
if ( tag1 in CKEDITOR.dtd.$listItem || tag1 in CKEDITOR.dtd.$tableContent )
return tag1 == tag2 || tag1 == 'dt' && tag2 == 'dd' || tag1 == 'dd' && tag2 == 'dt';
return false;
} | javascript | function possiblySibling( tag1, tag2 ) {
if ( tag1 in CKEDITOR.dtd.$listItem || tag1 in CKEDITOR.dtd.$tableContent )
return tag1 == tag2 || tag1 == 'dt' && tag2 == 'dd' || tag1 == 'dd' && tag2 == 'dt';
return false;
} | [
"function",
"possiblySibling",
"(",
"tag1",
",",
"tag2",
")",
"{",
"if",
"(",
"tag1",
"in",
"CKEDITOR",
".",
"dtd",
".",
"$listItem",
"||",
"tag1",
"in",
"CKEDITOR",
".",
"dtd",
".",
"$tableContent",
")",
"return",
"tag1",
"==",
"tag2",
"||",
"tag1",
"==",
"'dt'",
"&&",
"tag2",
"==",
"'dd'",
"||",
"tag1",
"==",
"'dd'",
"&&",
"tag2",
"==",
"'dt'",
";",
"return",
"false",
";",
"}"
] | Judge whether two element tag names are likely the siblings from the same structural element. | [
"Judge",
"whether",
"two",
"element",
"tag",
"names",
"are",
"likely",
"the",
"siblings",
"from",
"the",
"same",
"structural",
"element",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/fragment.js#L233-L239 |
55,935 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/htmlparser/fragment.js | function( filter, context ) {
context = this.getFilterContext( context );
// Apply the root filter.
filter.onRoot( context, this );
this.filterChildren( filter, false, context );
} | javascript | function( filter, context ) {
context = this.getFilterContext( context );
// Apply the root filter.
filter.onRoot( context, this );
this.filterChildren( filter, false, context );
} | [
"function",
"(",
"filter",
",",
"context",
")",
"{",
"context",
"=",
"this",
".",
"getFilterContext",
"(",
"context",
")",
";",
"// Apply the root filter.",
"filter",
".",
"onRoot",
"(",
"context",
",",
"this",
")",
";",
"this",
".",
"filterChildren",
"(",
"filter",
",",
"false",
",",
"context",
")",
";",
"}"
] | Filter this fragment's content with given filter.
@since 4.1
@param {CKEDITOR.htmlParser.filter} filter | [
"Filter",
"this",
"fragment",
"s",
"content",
"with",
"given",
"filter",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/fragment.js#L513-L520 |
|
55,936 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/htmlparser/fragment.js | function( filter, filterRoot, context ) {
// If this element's children were already filtered
// by current filter, don't filter them 2nd time.
// This situation may occur when filtering bottom-up
// (filterChildren() called manually in element's filter),
// or in unpredictable edge cases when filter
// is manipulating DOM structure.
if ( this.childrenFilteredBy == filter.id )
return;
context = this.getFilterContext( context );
// Filtering root if enforced.
if ( filterRoot && !this.parent )
filter.onRoot( context, this );
this.childrenFilteredBy = filter.id;
// Don't cache anything, children array may be modified by filter rule.
for ( var i = 0; i < this.children.length; i++ ) {
// Stay in place if filter returned false, what means
// that node has been removed.
if ( this.children[ i ].filter( filter, context ) === false )
i--;
}
} | javascript | function( filter, filterRoot, context ) {
// If this element's children were already filtered
// by current filter, don't filter them 2nd time.
// This situation may occur when filtering bottom-up
// (filterChildren() called manually in element's filter),
// or in unpredictable edge cases when filter
// is manipulating DOM structure.
if ( this.childrenFilteredBy == filter.id )
return;
context = this.getFilterContext( context );
// Filtering root if enforced.
if ( filterRoot && !this.parent )
filter.onRoot( context, this );
this.childrenFilteredBy = filter.id;
// Don't cache anything, children array may be modified by filter rule.
for ( var i = 0; i < this.children.length; i++ ) {
// Stay in place if filter returned false, what means
// that node has been removed.
if ( this.children[ i ].filter( filter, context ) === false )
i--;
}
} | [
"function",
"(",
"filter",
",",
"filterRoot",
",",
"context",
")",
"{",
"// If this element's children were already filtered",
"// by current filter, don't filter them 2nd time.",
"// This situation may occur when filtering bottom-up",
"// (filterChildren() called manually in element's filter),",
"// or in unpredictable edge cases when filter",
"// is manipulating DOM structure.",
"if",
"(",
"this",
".",
"childrenFilteredBy",
"==",
"filter",
".",
"id",
")",
"return",
";",
"context",
"=",
"this",
".",
"getFilterContext",
"(",
"context",
")",
";",
"// Filtering root if enforced.",
"if",
"(",
"filterRoot",
"&&",
"!",
"this",
".",
"parent",
")",
"filter",
".",
"onRoot",
"(",
"context",
",",
"this",
")",
";",
"this",
".",
"childrenFilteredBy",
"=",
"filter",
".",
"id",
";",
"// Don't cache anything, children array may be modified by filter rule.",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"children",
".",
"length",
";",
"i",
"++",
")",
"{",
"// Stay in place if filter returned false, what means",
"// that node has been removed.",
"if",
"(",
"this",
".",
"children",
"[",
"i",
"]",
".",
"filter",
"(",
"filter",
",",
"context",
")",
"===",
"false",
")",
"i",
"--",
";",
"}",
"}"
] | Filter this fragment's children with given filter.
Element's children may only be filtered once by one
instance of filter.
@since 4.1
@param {CKEDITOR.htmlParser.filter} filter
@param {Boolean} [filterRoot] Whether to apply the "root" filter rule specified in the `filter`. | [
"Filter",
"this",
"fragment",
"s",
"children",
"with",
"given",
"filter",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/fragment.js#L532-L557 |
|
55,937 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/htmlparser/fragment.js | function( writer, filter, filterRoot ) {
var context = this.getFilterContext();
// Filtering root if enforced.
if ( filterRoot && !this.parent && filter )
filter.onRoot( context, this );
if ( filter )
this.filterChildren( filter, false, context );
for ( var i = 0, children = this.children, l = children.length; i < l; i++ )
children[ i ].writeHtml( writer );
} | javascript | function( writer, filter, filterRoot ) {
var context = this.getFilterContext();
// Filtering root if enforced.
if ( filterRoot && !this.parent && filter )
filter.onRoot( context, this );
if ( filter )
this.filterChildren( filter, false, context );
for ( var i = 0, children = this.children, l = children.length; i < l; i++ )
children[ i ].writeHtml( writer );
} | [
"function",
"(",
"writer",
",",
"filter",
",",
"filterRoot",
")",
"{",
"var",
"context",
"=",
"this",
".",
"getFilterContext",
"(",
")",
";",
"// Filtering root if enforced.",
"if",
"(",
"filterRoot",
"&&",
"!",
"this",
".",
"parent",
"&&",
"filter",
")",
"filter",
".",
"onRoot",
"(",
"context",
",",
"this",
")",
";",
"if",
"(",
"filter",
")",
"this",
".",
"filterChildren",
"(",
"filter",
",",
"false",
",",
"context",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"children",
"=",
"this",
".",
"children",
",",
"l",
"=",
"children",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"children",
"[",
"i",
"]",
".",
"writeHtml",
"(",
"writer",
")",
";",
"}"
] | Write and filtering the child nodes of this fragment.
@param {CKEDITOR.htmlParser.basicWriter} writer The writer to which write the HTML.
@param {CKEDITOR.htmlParser.filter} [filter] The filter to use when writing the HTML.
@param {Boolean} [filterRoot] Whether to apply the "root" filter rule specified in the `filter`. | [
"Write",
"and",
"filtering",
"the",
"child",
"nodes",
"of",
"this",
"fragment",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/fragment.js#L584-L596 |
|
55,938 | yoshuawuyts/myth-request | index.js | mr | function mr(bundler) {
var prevError = null
var pending = null
var buffer = null
build()
// bundler.on('update', update)
return handler
/**
* Build the CSS and pass it to `buffer`.
*
* @api private
*/
function build() {
const p = pending = new Emitter()
buffer = bundler.toString()
if (p !== pending) return
pending.emit('ready', null, pending = false)
}
/**
* Response middleware. Sends `buffer` to
* either `next()` or `res.body()`.
*
* @param {Request} req
* @param {Response} res
* @param {Function} next
* @api private
*/
function handler(req, res, next) {
next = next || send
if (pending) return pending.once('ready', function(err) {
if (err) return next(err)
return handler(req, res, next)
})
if (prevError) return next(prevError)
res.setHeader('content-type', 'text/css')
return next(null, buffer)
function send(err, body) {
if (err) return res.emit(err)
res.end(body)
}
}
} | javascript | function mr(bundler) {
var prevError = null
var pending = null
var buffer = null
build()
// bundler.on('update', update)
return handler
/**
* Build the CSS and pass it to `buffer`.
*
* @api private
*/
function build() {
const p = pending = new Emitter()
buffer = bundler.toString()
if (p !== pending) return
pending.emit('ready', null, pending = false)
}
/**
* Response middleware. Sends `buffer` to
* either `next()` or `res.body()`.
*
* @param {Request} req
* @param {Response} res
* @param {Function} next
* @api private
*/
function handler(req, res, next) {
next = next || send
if (pending) return pending.once('ready', function(err) {
if (err) return next(err)
return handler(req, res, next)
})
if (prevError) return next(prevError)
res.setHeader('content-type', 'text/css')
return next(null, buffer)
function send(err, body) {
if (err) return res.emit(err)
res.end(body)
}
}
} | [
"function",
"mr",
"(",
"bundler",
")",
"{",
"var",
"prevError",
"=",
"null",
"var",
"pending",
"=",
"null",
"var",
"buffer",
"=",
"null",
"build",
"(",
")",
"// bundler.on('update', update)",
"return",
"handler",
"/**\n * Build the CSS and pass it to `buffer`.\n *\n * @api private\n */",
"function",
"build",
"(",
")",
"{",
"const",
"p",
"=",
"pending",
"=",
"new",
"Emitter",
"(",
")",
"buffer",
"=",
"bundler",
".",
"toString",
"(",
")",
"if",
"(",
"p",
"!==",
"pending",
")",
"return",
"pending",
".",
"emit",
"(",
"'ready'",
",",
"null",
",",
"pending",
"=",
"false",
")",
"}",
"/**\n * Response middleware. Sends `buffer` to\n * either `next()` or `res.body()`.\n *\n * @param {Request} req\n * @param {Response} res\n * @param {Function} next\n * @api private\n */",
"function",
"handler",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"next",
"=",
"next",
"||",
"send",
"if",
"(",
"pending",
")",
"return",
"pending",
".",
"once",
"(",
"'ready'",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"return",
"next",
"(",
"err",
")",
"return",
"handler",
"(",
"req",
",",
"res",
",",
"next",
")",
"}",
")",
"if",
"(",
"prevError",
")",
"return",
"next",
"(",
"prevError",
")",
"res",
".",
"setHeader",
"(",
"'content-type'",
",",
"'text/css'",
")",
"return",
"next",
"(",
"null",
",",
"buffer",
")",
"function",
"send",
"(",
"err",
",",
"body",
")",
"{",
"if",
"(",
"err",
")",
"return",
"res",
".",
"emit",
"(",
"err",
")",
"res",
".",
"end",
"(",
"body",
")",
"}",
"}",
"}"
] | Respond myth in an http request.
@param {Function} bundler
@return {Function}
@api public | [
"Respond",
"myth",
"in",
"an",
"http",
"request",
"."
] | 0c70a49e2b8abbfcd6fd0a3735a18064d952992b | https://github.com/yoshuawuyts/myth-request/blob/0c70a49e2b8abbfcd6fd0a3735a18064d952992b/index.js#L12-L61 |
55,939 | yoshuawuyts/myth-request | index.js | build | function build() {
const p = pending = new Emitter()
buffer = bundler.toString()
if (p !== pending) return
pending.emit('ready', null, pending = false)
} | javascript | function build() {
const p = pending = new Emitter()
buffer = bundler.toString()
if (p !== pending) return
pending.emit('ready', null, pending = false)
} | [
"function",
"build",
"(",
")",
"{",
"const",
"p",
"=",
"pending",
"=",
"new",
"Emitter",
"(",
")",
"buffer",
"=",
"bundler",
".",
"toString",
"(",
")",
"if",
"(",
"p",
"!==",
"pending",
")",
"return",
"pending",
".",
"emit",
"(",
"'ready'",
",",
"null",
",",
"pending",
"=",
"false",
")",
"}"
] | Build the CSS and pass it to `buffer`.
@api private | [
"Build",
"the",
"CSS",
"and",
"pass",
"it",
"to",
"buffer",
"."
] | 0c70a49e2b8abbfcd6fd0a3735a18064d952992b | https://github.com/yoshuawuyts/myth-request/blob/0c70a49e2b8abbfcd6fd0a3735a18064d952992b/index.js#L26-L32 |
55,940 | adriancmiranda/dotcfg | dist/dotcfg.amd.js | deletePropertyAt | function deletePropertyAt(object, prop) {
if (object == null) { return object; }
var value = object[prop];
delete object[prop];
return value;
} | javascript | function deletePropertyAt(object, prop) {
if (object == null) { return object; }
var value = object[prop];
delete object[prop];
return value;
} | [
"function",
"deletePropertyAt",
"(",
"object",
",",
"prop",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"return",
"object",
";",
"}",
"var",
"value",
"=",
"object",
"[",
"prop",
"]",
";",
"delete",
"object",
"[",
"prop",
"]",
";",
"return",
"value",
";",
"}"
] | Removes a property from an object; if no more references to the same property
are held, it is eventually released automatically.
@param {Object} object
@param {String} prop | [
"Removes",
"a",
"property",
"from",
"an",
"object",
";",
"if",
"no",
"more",
"references",
"to",
"the",
"same",
"property",
"are",
"held",
"it",
"is",
"eventually",
"released",
"automatically",
"."
] | ef6cca524621c4bffd0b0c95c62f7330070c26eb | https://github.com/adriancmiranda/dotcfg/blob/ef6cca524621c4bffd0b0c95c62f7330070c26eb/dist/dotcfg.amd.js#L455-L460 |
55,941 | adriancmiranda/dotcfg | dist/dotcfg.amd.js | DotCfg | function DotCfg(namespace, scope, strategy) {
if (instanceOf(DotCfg, this)) {
if (exotic(namespace)) {
strategy = scope;
scope = namespace;
namespace = undefined;
}
if (primitive(scope)) {
scope = env;
}
if (string(namespace)) {
scope[namespace] = scope[namespace] || {};
scope = scope[namespace];
}
this.strategy = as(Function, strategy, dotDefault);
this.scope = normalize(scope, this.strategy, false);
this.extends = proxy(assign(this.strategy), this, this.scope);
this.namespace = as(String, namespace, ("dot" + (guid += 1)));
return this;
}
return new DotCfg(namespace, scope, strategy);
} | javascript | function DotCfg(namespace, scope, strategy) {
if (instanceOf(DotCfg, this)) {
if (exotic(namespace)) {
strategy = scope;
scope = namespace;
namespace = undefined;
}
if (primitive(scope)) {
scope = env;
}
if (string(namespace)) {
scope[namespace] = scope[namespace] || {};
scope = scope[namespace];
}
this.strategy = as(Function, strategy, dotDefault);
this.scope = normalize(scope, this.strategy, false);
this.extends = proxy(assign(this.strategy), this, this.scope);
this.namespace = as(String, namespace, ("dot" + (guid += 1)));
return this;
}
return new DotCfg(namespace, scope, strategy);
} | [
"function",
"DotCfg",
"(",
"namespace",
",",
"scope",
",",
"strategy",
")",
"{",
"if",
"(",
"instanceOf",
"(",
"DotCfg",
",",
"this",
")",
")",
"{",
"if",
"(",
"exotic",
"(",
"namespace",
")",
")",
"{",
"strategy",
"=",
"scope",
";",
"scope",
"=",
"namespace",
";",
"namespace",
"=",
"undefined",
";",
"}",
"if",
"(",
"primitive",
"(",
"scope",
")",
")",
"{",
"scope",
"=",
"env",
";",
"}",
"if",
"(",
"string",
"(",
"namespace",
")",
")",
"{",
"scope",
"[",
"namespace",
"]",
"=",
"scope",
"[",
"namespace",
"]",
"||",
"{",
"}",
";",
"scope",
"=",
"scope",
"[",
"namespace",
"]",
";",
"}",
"this",
".",
"strategy",
"=",
"as",
"(",
"Function",
",",
"strategy",
",",
"dotDefault",
")",
";",
"this",
".",
"scope",
"=",
"normalize",
"(",
"scope",
",",
"this",
".",
"strategy",
",",
"false",
")",
";",
"this",
".",
"extends",
"=",
"proxy",
"(",
"assign",
"(",
"this",
".",
"strategy",
")",
",",
"this",
",",
"this",
".",
"scope",
")",
";",
"this",
".",
"namespace",
"=",
"as",
"(",
"String",
",",
"namespace",
",",
"(",
"\"dot\"",
"+",
"(",
"guid",
"+=",
"1",
")",
")",
")",
";",
"return",
"this",
";",
"}",
"return",
"new",
"DotCfg",
"(",
"namespace",
",",
"scope",
",",
"strategy",
")",
";",
"}"
] | Create a instance of `DotCfg`.
@param namespace: A string containing a qualified name to identify objects from.
@param scope: A object that have system-wide relevance.
@param strategy: A function that configures the input values. | [
"Create",
"a",
"instance",
"of",
"DotCfg",
"."
] | ef6cca524621c4bffd0b0c95c62f7330070c26eb | https://github.com/adriancmiranda/dotcfg/blob/ef6cca524621c4bffd0b0c95c62f7330070c26eb/dist/dotcfg.amd.js#L639-L660 |
55,942 | adriancmiranda/dotcfg | dist/dotcfg.amd.js | set | function set(notation, value, strategy) {
var this$1 = this;
var fn = !undef(value) && callable(strategy) ? strategy : this.strategy;
if (object(notation)) {
var context;
for (var key in notation) {
if (ownProperty(notation, key)) {
context = write(this$1.scope, key, notation[key], fn);
}
}
return context;
}
write(this.scope, notation, value, fn);
return this;
} | javascript | function set(notation, value, strategy) {
var this$1 = this;
var fn = !undef(value) && callable(strategy) ? strategy : this.strategy;
if (object(notation)) {
var context;
for (var key in notation) {
if (ownProperty(notation, key)) {
context = write(this$1.scope, key, notation[key], fn);
}
}
return context;
}
write(this.scope, notation, value, fn);
return this;
} | [
"function",
"set",
"(",
"notation",
",",
"value",
",",
"strategy",
")",
"{",
"var",
"this$1",
"=",
"this",
";",
"var",
"fn",
"=",
"!",
"undef",
"(",
"value",
")",
"&&",
"callable",
"(",
"strategy",
")",
"?",
"strategy",
":",
"this",
".",
"strategy",
";",
"if",
"(",
"object",
"(",
"notation",
")",
")",
"{",
"var",
"context",
";",
"for",
"(",
"var",
"key",
"in",
"notation",
")",
"{",
"if",
"(",
"ownProperty",
"(",
"notation",
",",
"key",
")",
")",
"{",
"context",
"=",
"write",
"(",
"this$1",
".",
"scope",
",",
"key",
",",
"notation",
"[",
"key",
"]",
",",
"fn",
")",
";",
"}",
"}",
"return",
"context",
";",
"}",
"write",
"(",
"this",
".",
"scope",
",",
"notation",
",",
"value",
",",
"fn",
")",
";",
"return",
"this",
";",
"}"
] | Write in scope.
@param notation: A object path.
@param value: Arguments for the object.
@param strategy: Arguments for the object.
@returns DotCfg | [
"Write",
"in",
"scope",
"."
] | ef6cca524621c4bffd0b0c95c62f7330070c26eb | https://github.com/adriancmiranda/dotcfg/blob/ef6cca524621c4bffd0b0c95c62f7330070c26eb/dist/dotcfg.amd.js#L703-L718 |
55,943 | adriancmiranda/dotcfg | dist/dotcfg.amd.js | get | function get(notation, defaultValue) {
var value = read(this.scope, notation);
return undef(value) ? defaultValue : value;
} | javascript | function get(notation, defaultValue) {
var value = read(this.scope, notation);
return undef(value) ? defaultValue : value;
} | [
"function",
"get",
"(",
"notation",
",",
"defaultValue",
")",
"{",
"var",
"value",
"=",
"read",
"(",
"this",
".",
"scope",
",",
"notation",
")",
";",
"return",
"undef",
"(",
"value",
")",
"?",
"defaultValue",
":",
"value",
";",
"}"
] | Read scope notation.
@param notation: A object path.
@param defaultValue: A fallback value.
@returns any | [
"Read",
"scope",
"notation",
"."
] | ef6cca524621c4bffd0b0c95c62f7330070c26eb | https://github.com/adriancmiranda/dotcfg/blob/ef6cca524621c4bffd0b0c95c62f7330070c26eb/dist/dotcfg.amd.js#L726-L729 |
55,944 | mar10/grunt-yabs | tasks/yabs.js | makeArrayOpt | function makeArrayOpt(opts, name) {
if( !Array.isArray(opts[name]) ) {
opts[name] = [ opts[name] ];
}
return opts[name];
} | javascript | function makeArrayOpt(opts, name) {
if( !Array.isArray(opts[name]) ) {
opts[name] = [ opts[name] ];
}
return opts[name];
} | [
"function",
"makeArrayOpt",
"(",
"opts",
",",
"name",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"opts",
"[",
"name",
"]",
")",
")",
"{",
"opts",
"[",
"name",
"]",
"=",
"[",
"opts",
"[",
"name",
"]",
"]",
";",
"}",
"return",
"opts",
"[",
"name",
"]",
";",
"}"
] | Convert opts.name to an array if not already. | [
"Convert",
"opts",
".",
"name",
"to",
"an",
"array",
"if",
"not",
"already",
"."
] | 050741679227fc6342fdef17966f04989e34c244 | https://github.com/mar10/grunt-yabs/blob/050741679227fc6342fdef17966f04989e34c244/tasks/yabs.js#L124-L129 |
55,945 | jonschlinkert/rethrow | index.js | rethrow | function rethrow(options) {
var opts = lazy.extend({before: 3, after: 3}, options);
return function (err, filename, lineno, str, expr) {
if (!(err instanceof Error)) throw err;
lineno = lineno >> 0;
var lines = str.split('\n');
var before = Math.max(lineno - (+opts.before), 0);
var after = Math.min(lines.length, lineno + (+opts.after));
// align line numbers
var n = lazy.align(count(lines.length + 1));
lineno++;
var pointer = errorMessage(err, opts);
// Error context
var context = lines.slice(before, after).map(function (line, i) {
var num = i + before + 1;
var msg = style(num, lineno);
return msg(' > ', ' ')
+ n[num] + '| '
+ line + ' ' + msg(expr, '');
}).join('\n');
// Alter exception message
err.path = filename;
err.message = (filename || 'source') + ':'
+ lineno + '\n'
+ context + '\n\n'
+ (pointer ? (pointer + lazy.yellow(filename)) : styleMessage(err.message, opts)) + '\n';
throw err.message;
};
} | javascript | function rethrow(options) {
var opts = lazy.extend({before: 3, after: 3}, options);
return function (err, filename, lineno, str, expr) {
if (!(err instanceof Error)) throw err;
lineno = lineno >> 0;
var lines = str.split('\n');
var before = Math.max(lineno - (+opts.before), 0);
var after = Math.min(lines.length, lineno + (+opts.after));
// align line numbers
var n = lazy.align(count(lines.length + 1));
lineno++;
var pointer = errorMessage(err, opts);
// Error context
var context = lines.slice(before, after).map(function (line, i) {
var num = i + before + 1;
var msg = style(num, lineno);
return msg(' > ', ' ')
+ n[num] + '| '
+ line + ' ' + msg(expr, '');
}).join('\n');
// Alter exception message
err.path = filename;
err.message = (filename || 'source') + ':'
+ lineno + '\n'
+ context + '\n\n'
+ (pointer ? (pointer + lazy.yellow(filename)) : styleMessage(err.message, opts)) + '\n';
throw err.message;
};
} | [
"function",
"rethrow",
"(",
"options",
")",
"{",
"var",
"opts",
"=",
"lazy",
".",
"extend",
"(",
"{",
"before",
":",
"3",
",",
"after",
":",
"3",
"}",
",",
"options",
")",
";",
"return",
"function",
"(",
"err",
",",
"filename",
",",
"lineno",
",",
"str",
",",
"expr",
")",
"{",
"if",
"(",
"!",
"(",
"err",
"instanceof",
"Error",
")",
")",
"throw",
"err",
";",
"lineno",
"=",
"lineno",
">>",
"0",
";",
"var",
"lines",
"=",
"str",
".",
"split",
"(",
"'\\n'",
")",
";",
"var",
"before",
"=",
"Math",
".",
"max",
"(",
"lineno",
"-",
"(",
"+",
"opts",
".",
"before",
")",
",",
"0",
")",
";",
"var",
"after",
"=",
"Math",
".",
"min",
"(",
"lines",
".",
"length",
",",
"lineno",
"+",
"(",
"+",
"opts",
".",
"after",
")",
")",
";",
"// align line numbers",
"var",
"n",
"=",
"lazy",
".",
"align",
"(",
"count",
"(",
"lines",
".",
"length",
"+",
"1",
")",
")",
";",
"lineno",
"++",
";",
"var",
"pointer",
"=",
"errorMessage",
"(",
"err",
",",
"opts",
")",
";",
"// Error context",
"var",
"context",
"=",
"lines",
".",
"slice",
"(",
"before",
",",
"after",
")",
".",
"map",
"(",
"function",
"(",
"line",
",",
"i",
")",
"{",
"var",
"num",
"=",
"i",
"+",
"before",
"+",
"1",
";",
"var",
"msg",
"=",
"style",
"(",
"num",
",",
"lineno",
")",
";",
"return",
"msg",
"(",
"' > '",
",",
"' '",
")",
"+",
"n",
"[",
"num",
"]",
"+",
"'| '",
"+",
"line",
"+",
"' '",
"+",
"msg",
"(",
"expr",
",",
"''",
")",
";",
"}",
")",
".",
"join",
"(",
"'\\n'",
")",
";",
"// Alter exception message",
"err",
".",
"path",
"=",
"filename",
";",
"err",
".",
"message",
"=",
"(",
"filename",
"||",
"'source'",
")",
"+",
"':'",
"+",
"lineno",
"+",
"'\\n'",
"+",
"context",
"+",
"'\\n\\n'",
"+",
"(",
"pointer",
"?",
"(",
"pointer",
"+",
"lazy",
".",
"yellow",
"(",
"filename",
")",
")",
":",
"styleMessage",
"(",
"err",
".",
"message",
",",
"opts",
")",
")",
"+",
"'\\n'",
";",
"throw",
"err",
".",
"message",
";",
"}",
";",
"}"
] | Re-throw the given `err` in context to the offending
template expression in `filename` at the given `lineno`.
@param {Error} `err` Error object
@param {String} `filename` The file path of the template
@param {String} `lineno` The line number of the expression causing the error.
@param {String} `str` Template string
@api public | [
"Re",
"-",
"throw",
"the",
"given",
"err",
"in",
"context",
"to",
"the",
"offending",
"template",
"expression",
"in",
"filename",
"at",
"the",
"given",
"lineno",
"."
] | 2ab061ed114e7ab076f76b39fae749146d8c4a3c | https://github.com/jonschlinkert/rethrow/blob/2ab061ed114e7ab076f76b39fae749146d8c4a3c/index.js#L28-L63 |
55,946 | mamboer/cssutil | pather.js | processRelativePath | function processRelativePath(cssPath, importCssPath, importCssText) {
cssPath = cssPath.split('\\');
importCssPath = importCssPath.split('/');
var isSibling = importCssPath.length == 1;
return importCssText.replace(reg, function(css, before, imgPath, after) {
if (/^http\S/.test(imgPath) || /^\/\S/.test(imgPath) || isSibling) { //绝对路径or同级跳过
return css;
}
imgPath = imgPath.split('/');
imgPath = getRelativePath(cssPath, importCssPath, imgPath);
return before + imgPath + after;
});
} | javascript | function processRelativePath(cssPath, importCssPath, importCssText) {
cssPath = cssPath.split('\\');
importCssPath = importCssPath.split('/');
var isSibling = importCssPath.length == 1;
return importCssText.replace(reg, function(css, before, imgPath, after) {
if (/^http\S/.test(imgPath) || /^\/\S/.test(imgPath) || isSibling) { //绝对路径or同级跳过
return css;
}
imgPath = imgPath.split('/');
imgPath = getRelativePath(cssPath, importCssPath, imgPath);
return before + imgPath + after;
});
} | [
"function",
"processRelativePath",
"(",
"cssPath",
",",
"importCssPath",
",",
"importCssText",
")",
"{",
"cssPath",
"=",
"cssPath",
".",
"split",
"(",
"'\\\\'",
")",
";",
"importCssPath",
"=",
"importCssPath",
".",
"split",
"(",
"'/'",
")",
";",
"var",
"isSibling",
"=",
"importCssPath",
".",
"length",
"==",
"1",
";",
"return",
"importCssText",
".",
"replace",
"(",
"reg",
",",
"function",
"(",
"css",
",",
"before",
",",
"imgPath",
",",
"after",
")",
"{",
"if",
"(",
"/",
"^http\\S",
"/",
".",
"test",
"(",
"imgPath",
")",
"||",
"/",
"^\\/\\S",
"/",
".",
"test",
"(",
"imgPath",
")",
"||",
"isSibling",
")",
"{",
"//绝对路径or同级跳过",
"return",
"css",
";",
"}",
"imgPath",
"=",
"imgPath",
".",
"split",
"(",
"'/'",
")",
";",
"imgPath",
"=",
"getRelativePath",
"(",
"cssPath",
",",
"importCssPath",
",",
"imgPath",
")",
";",
"return",
"before",
"+",
"imgPath",
"+",
"after",
";",
"}",
")",
";",
"}"
] | process relative image pathes in specified imported css
@param {String} cssPath css absolute file path
@param {String} importCssPath relative imported css file path
@param {String} importCssText contents of the imported css file | [
"process",
"relative",
"image",
"pathes",
"in",
"specified",
"imported",
"css"
] | 430cc26bea5cdb195411b5b4d1db3c4c4d817246 | https://github.com/mamboer/cssutil/blob/430cc26bea5cdb195411b5b4d1db3c4c4d817246/pather.js#L10-L22 |
55,947 | mamboer/cssutil | pather.js | getRelativePath | function getRelativePath(cssPath, importCssPath, imgPath) {
var count1 = 0,
count2 = 0,
result = '';
importCssPath = getFilePath(cssPath, importCssPath);
imgPath = getFilePath(importCssPath, imgPath);
for (var i = 0, length = cssPath.length; i < length; i++) {
if (cssPath[i] == imgPath[i]) {
count1++;
} else {
break;
}
}
count2 = cssPath.length - count1 - 1;
for (var i = 0; i < count2; i++) {
result += '../';
}
result = result + imgPath.splice(count1).join('/');
return result;
} | javascript | function getRelativePath(cssPath, importCssPath, imgPath) {
var count1 = 0,
count2 = 0,
result = '';
importCssPath = getFilePath(cssPath, importCssPath);
imgPath = getFilePath(importCssPath, imgPath);
for (var i = 0, length = cssPath.length; i < length; i++) {
if (cssPath[i] == imgPath[i]) {
count1++;
} else {
break;
}
}
count2 = cssPath.length - count1 - 1;
for (var i = 0; i < count2; i++) {
result += '../';
}
result = result + imgPath.splice(count1).join('/');
return result;
} | [
"function",
"getRelativePath",
"(",
"cssPath",
",",
"importCssPath",
",",
"imgPath",
")",
"{",
"var",
"count1",
"=",
"0",
",",
"count2",
"=",
"0",
",",
"result",
"=",
"''",
";",
"importCssPath",
"=",
"getFilePath",
"(",
"cssPath",
",",
"importCssPath",
")",
";",
"imgPath",
"=",
"getFilePath",
"(",
"importCssPath",
",",
"imgPath",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"length",
"=",
"cssPath",
".",
"length",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"cssPath",
"[",
"i",
"]",
"==",
"imgPath",
"[",
"i",
"]",
")",
"{",
"count1",
"++",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"count2",
"=",
"cssPath",
".",
"length",
"-",
"count1",
"-",
"1",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"count2",
";",
"i",
"++",
")",
"{",
"result",
"+=",
"'../'",
";",
"}",
"result",
"=",
"result",
"+",
"imgPath",
".",
"splice",
"(",
"count1",
")",
".",
"join",
"(",
"'/'",
")",
";",
"return",
"result",
";",
"}"
] | get images' relative path after css merging
@param {String} cssPath css absolute file path
@param {String} importCssPath relative imported css file path
@param {String} imgPath raw image relative path | [
"get",
"images",
"relative",
"path",
"after",
"css",
"merging"
] | 430cc26bea5cdb195411b5b4d1db3c4c4d817246 | https://github.com/mamboer/cssutil/blob/430cc26bea5cdb195411b5b4d1db3c4c4d817246/pather.js#L29-L48 |
55,948 | mamboer/cssutil | pather.js | getFilePath | function getFilePath(basePath, relativePath) {
var count = 0,
array1, array2;
for (var i = 0, length = relativePath.length; i < length; i++) {
if (relativePath[i] == '..') {
count++;
}
}
array1 = basePath.slice(0, basePath.length - 1 - count);
array2 = relativePath.slice(count);
return array1.concat(array2);
} | javascript | function getFilePath(basePath, relativePath) {
var count = 0,
array1, array2;
for (var i = 0, length = relativePath.length; i < length; i++) {
if (relativePath[i] == '..') {
count++;
}
}
array1 = basePath.slice(0, basePath.length - 1 - count);
array2 = relativePath.slice(count);
return array1.concat(array2);
} | [
"function",
"getFilePath",
"(",
"basePath",
",",
"relativePath",
")",
"{",
"var",
"count",
"=",
"0",
",",
"array1",
",",
"array2",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"length",
"=",
"relativePath",
".",
"length",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"relativePath",
"[",
"i",
"]",
"==",
"'..'",
")",
"{",
"count",
"++",
";",
"}",
"}",
"array1",
"=",
"basePath",
".",
"slice",
"(",
"0",
",",
"basePath",
".",
"length",
"-",
"1",
"-",
"count",
")",
";",
"array2",
"=",
"relativePath",
".",
"slice",
"(",
"count",
")",
";",
"return",
"array1",
".",
"concat",
"(",
"array2",
")",
";",
"}"
] | get relative file path basing on its containing file path and its relative path
@param {String} basePath containing file path
@param {String} relative path | [
"get",
"relative",
"file",
"path",
"basing",
"on",
"its",
"containing",
"file",
"path",
"and",
"its",
"relative",
"path"
] | 430cc26bea5cdb195411b5b4d1db3c4c4d817246 | https://github.com/mamboer/cssutil/blob/430cc26bea5cdb195411b5b4d1db3c4c4d817246/pather.js#L54-L65 |
55,949 | byu-oit/sans-server | bin/util.js | copy | function copy(obj, map) {
if (map.has(obj)) {
return map.get(obj);
} else if (Array.isArray(obj)) {
const result = [];
map.set(obj, result);
obj.forEach(item => {
result.push(copy(item, map));
});
return result;
} else if (typeof obj === 'object' && obj) {
const result = {};
map.set(obj, result);
Object.keys(obj).forEach(key => {
result[key] = copy(obj[key], map);
});
return result;
} else {
return obj;
}
} | javascript | function copy(obj, map) {
if (map.has(obj)) {
return map.get(obj);
} else if (Array.isArray(obj)) {
const result = [];
map.set(obj, result);
obj.forEach(item => {
result.push(copy(item, map));
});
return result;
} else if (typeof obj === 'object' && obj) {
const result = {};
map.set(obj, result);
Object.keys(obj).forEach(key => {
result[key] = copy(obj[key], map);
});
return result;
} else {
return obj;
}
} | [
"function",
"copy",
"(",
"obj",
",",
"map",
")",
"{",
"if",
"(",
"map",
".",
"has",
"(",
"obj",
")",
")",
"{",
"return",
"map",
".",
"get",
"(",
"obj",
")",
";",
"}",
"else",
"if",
"(",
"Array",
".",
"isArray",
"(",
"obj",
")",
")",
"{",
"const",
"result",
"=",
"[",
"]",
";",
"map",
".",
"set",
"(",
"obj",
",",
"result",
")",
";",
"obj",
".",
"forEach",
"(",
"item",
"=>",
"{",
"result",
".",
"push",
"(",
"copy",
"(",
"item",
",",
"map",
")",
")",
";",
"}",
")",
";",
"return",
"result",
";",
"}",
"else",
"if",
"(",
"typeof",
"obj",
"===",
"'object'",
"&&",
"obj",
")",
"{",
"const",
"result",
"=",
"{",
"}",
";",
"map",
".",
"set",
"(",
"obj",
",",
"result",
")",
";",
"Object",
".",
"keys",
"(",
"obj",
")",
".",
"forEach",
"(",
"key",
"=>",
"{",
"result",
"[",
"key",
"]",
"=",
"copy",
"(",
"obj",
"[",
"key",
"]",
",",
"map",
")",
";",
"}",
")",
";",
"return",
"result",
";",
"}",
"else",
"{",
"return",
"obj",
";",
"}",
"}"
] | Perform a deep copy of a value.
@param {*} obj
@param {WeakMap} [map]
@returns {*} | [
"Perform",
"a",
"deep",
"copy",
"of",
"a",
"value",
"."
] | 022bcf7b47321e6e8aa20467cd96a6a84a457ec8 | https://github.com/byu-oit/sans-server/blob/022bcf7b47321e6e8aa20467cd96a6a84a457ec8/bin/util.js#L73-L93 |
55,950 | kuhnza/node-tubesio | examples/javascript/beatport-charts.js | parseSearchResults | function parseSearchResults(err, body) {
if (err) { return tubesio.finish(err); }
var result = [];
jsdom.env({
html: body,
scripts: [
'http://code.jquery.com/jquery-1.5.min.js'
]
}, function (err, window) {
if (err) { return tubesio.finish(err); }
var $ = window.jQuery;
$('table.track-grid-top-100 tr').each(function (i) {
if (i === 0) { return; } // Skip header row
var $row = $(this);
result.push({
position: parseInt($row.find('td:nth-child(1)').text()),
trackName: $row.find('td:nth-child(4) > a').text(),
artists: $row.find('td:nth-child(5) > a').text(),
remixers: $row.find('td:nth-child(6) > a').text(),
label: $row.find('td:nth-child(7) > a').text(),
genre: $row.find('td:nth-child(8) > a').text(),
releaseDate: Date.parse($row.find('td:nth-child(9)').text())
});
});
return tubesio.finish(result);
});
} | javascript | function parseSearchResults(err, body) {
if (err) { return tubesio.finish(err); }
var result = [];
jsdom.env({
html: body,
scripts: [
'http://code.jquery.com/jquery-1.5.min.js'
]
}, function (err, window) {
if (err) { return tubesio.finish(err); }
var $ = window.jQuery;
$('table.track-grid-top-100 tr').each(function (i) {
if (i === 0) { return; } // Skip header row
var $row = $(this);
result.push({
position: parseInt($row.find('td:nth-child(1)').text()),
trackName: $row.find('td:nth-child(4) > a').text(),
artists: $row.find('td:nth-child(5) > a').text(),
remixers: $row.find('td:nth-child(6) > a').text(),
label: $row.find('td:nth-child(7) > a').text(),
genre: $row.find('td:nth-child(8) > a').text(),
releaseDate: Date.parse($row.find('td:nth-child(9)').text())
});
});
return tubesio.finish(result);
});
} | [
"function",
"parseSearchResults",
"(",
"err",
",",
"body",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"tubesio",
".",
"finish",
"(",
"err",
")",
";",
"}",
"var",
"result",
"=",
"[",
"]",
";",
"jsdom",
".",
"env",
"(",
"{",
"html",
":",
"body",
",",
"scripts",
":",
"[",
"'http://code.jquery.com/jquery-1.5.min.js'",
"]",
"}",
",",
"function",
"(",
"err",
",",
"window",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"tubesio",
".",
"finish",
"(",
"err",
")",
";",
"}",
"var",
"$",
"=",
"window",
".",
"jQuery",
";",
"$",
"(",
"'table.track-grid-top-100 tr'",
")",
".",
"each",
"(",
"function",
"(",
"i",
")",
"{",
"if",
"(",
"i",
"===",
"0",
")",
"{",
"return",
";",
"}",
"// Skip header row",
"var",
"$row",
"=",
"$",
"(",
"this",
")",
";",
"result",
".",
"push",
"(",
"{",
"position",
":",
"parseInt",
"(",
"$row",
".",
"find",
"(",
"'td:nth-child(1)'",
")",
".",
"text",
"(",
")",
")",
",",
"trackName",
":",
"$row",
".",
"find",
"(",
"'td:nth-child(4) > a'",
")",
".",
"text",
"(",
")",
",",
"artists",
":",
"$row",
".",
"find",
"(",
"'td:nth-child(5) > a'",
")",
".",
"text",
"(",
")",
",",
"remixers",
":",
"$row",
".",
"find",
"(",
"'td:nth-child(6) > a'",
")",
".",
"text",
"(",
")",
",",
"label",
":",
"$row",
".",
"find",
"(",
"'td:nth-child(7) > a'",
")",
".",
"text",
"(",
")",
",",
"genre",
":",
"$row",
".",
"find",
"(",
"'td:nth-child(8) > a'",
")",
".",
"text",
"(",
")",
",",
"releaseDate",
":",
"Date",
".",
"parse",
"(",
"$row",
".",
"find",
"(",
"'td:nth-child(9)'",
")",
".",
"text",
"(",
")",
")",
"}",
")",
";",
"}",
")",
";",
"return",
"tubesio",
".",
"finish",
"(",
"result",
")",
";",
"}",
")",
";",
"}"
] | Parses search results into an array. | [
"Parses",
"search",
"results",
"into",
"an",
"array",
"."
] | 198d005de764480485fe038d1832ccb0f6e0596e | https://github.com/kuhnza/node-tubesio/blob/198d005de764480485fe038d1832ccb0f6e0596e/examples/javascript/beatport-charts.js#L18-L51 |
55,951 | snowyu/inherits-ex.js | src/inherits.js | inherits | function inherits(ctor, superCtor, staticInherit) {
var v = (ctor.hasOwnProperty('super_') && ctor.super_) || getPrototypeOf(ctor);
var mixinCtor = ctor.mixinCtor_;
if (mixinCtor && v === mixinCtor) {
ctor = mixinCtor;
v = (ctor.hasOwnProperty('super_') && ctor.super_) || getPrototypeOf(ctor);
}
var result = false;
if (!isInheritedFrom(ctor, superCtor) && !isInheritedFrom(superCtor, ctor)) {
inheritsDirectly(ctor, superCtor, staticInherit);
// patch the missing prototype chain if exists ctor.super.
while (v != null && v !== objectSuperCtor && superCtor !== v) {
ctor = superCtor;
superCtor = v;
inheritsDirectly(ctor, superCtor, staticInherit);
v = (ctor.hasOwnProperty('super_') && ctor.super_) || getPrototypeOf(ctor);
}
result = true;
}
return result;
} | javascript | function inherits(ctor, superCtor, staticInherit) {
var v = (ctor.hasOwnProperty('super_') && ctor.super_) || getPrototypeOf(ctor);
var mixinCtor = ctor.mixinCtor_;
if (mixinCtor && v === mixinCtor) {
ctor = mixinCtor;
v = (ctor.hasOwnProperty('super_') && ctor.super_) || getPrototypeOf(ctor);
}
var result = false;
if (!isInheritedFrom(ctor, superCtor) && !isInheritedFrom(superCtor, ctor)) {
inheritsDirectly(ctor, superCtor, staticInherit);
// patch the missing prototype chain if exists ctor.super.
while (v != null && v !== objectSuperCtor && superCtor !== v) {
ctor = superCtor;
superCtor = v;
inheritsDirectly(ctor, superCtor, staticInherit);
v = (ctor.hasOwnProperty('super_') && ctor.super_) || getPrototypeOf(ctor);
}
result = true;
}
return result;
} | [
"function",
"inherits",
"(",
"ctor",
",",
"superCtor",
",",
"staticInherit",
")",
"{",
"var",
"v",
"=",
"(",
"ctor",
".",
"hasOwnProperty",
"(",
"'super_'",
")",
"&&",
"ctor",
".",
"super_",
")",
"||",
"getPrototypeOf",
"(",
"ctor",
")",
";",
"var",
"mixinCtor",
"=",
"ctor",
".",
"mixinCtor_",
";",
"if",
"(",
"mixinCtor",
"&&",
"v",
"===",
"mixinCtor",
")",
"{",
"ctor",
"=",
"mixinCtor",
";",
"v",
"=",
"(",
"ctor",
".",
"hasOwnProperty",
"(",
"'super_'",
")",
"&&",
"ctor",
".",
"super_",
")",
"||",
"getPrototypeOf",
"(",
"ctor",
")",
";",
"}",
"var",
"result",
"=",
"false",
";",
"if",
"(",
"!",
"isInheritedFrom",
"(",
"ctor",
",",
"superCtor",
")",
"&&",
"!",
"isInheritedFrom",
"(",
"superCtor",
",",
"ctor",
")",
")",
"{",
"inheritsDirectly",
"(",
"ctor",
",",
"superCtor",
",",
"staticInherit",
")",
";",
"// patch the missing prototype chain if exists ctor.super.",
"while",
"(",
"v",
"!=",
"null",
"&&",
"v",
"!==",
"objectSuperCtor",
"&&",
"superCtor",
"!==",
"v",
")",
"{",
"ctor",
"=",
"superCtor",
";",
"superCtor",
"=",
"v",
";",
"inheritsDirectly",
"(",
"ctor",
",",
"superCtor",
",",
"staticInherit",
")",
";",
"v",
"=",
"(",
"ctor",
".",
"hasOwnProperty",
"(",
"'super_'",
")",
"&&",
"ctor",
".",
"super_",
")",
"||",
"getPrototypeOf",
"(",
"ctor",
")",
";",
"}",
"result",
"=",
"true",
";",
"}",
"return",
"result",
";",
"}"
] | Inherit the prototype methods from one constructor into another.
The Function.prototype.inherits from lang.js rewritten as a standalone
function (not on Function.prototype). NOTE: If this file is to be loaded
during bootstrapping this function needs to be rewritten using some native
functions as prototype setup using normal JavaScript does not work as
expected during bootstrapping (see mirror.js in r114903).
@param {function} ctor Constructor function which needs to inherit the
prototype.
@param {function} superCtor Constructor function to inherit prototype from.
@param {boolean} staticInherit whether static inheritance,defaults to true. | [
"Inherit",
"the",
"prototype",
"methods",
"from",
"one",
"constructor",
"into",
"another",
"."
] | 09f10e8400bd2b16943ec0dea01d0d9b79abea74 | https://github.com/snowyu/inherits-ex.js/blob/09f10e8400bd2b16943ec0dea01d0d9b79abea74/src/inherits.js#L22-L42 |
55,952 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/dom/element.js | function( text ) {
if ( this.$.text != null )
this.$.text += text;
else
this.append( new CKEDITOR.dom.text( text ) );
} | javascript | function( text ) {
if ( this.$.text != null )
this.$.text += text;
else
this.append( new CKEDITOR.dom.text( text ) );
} | [
"function",
"(",
"text",
")",
"{",
"if",
"(",
"this",
".",
"$",
".",
"text",
"!=",
"null",
")",
"this",
".",
"$",
".",
"text",
"+=",
"text",
";",
"else",
"this",
".",
"append",
"(",
"new",
"CKEDITOR",
".",
"dom",
".",
"text",
"(",
"text",
")",
")",
";",
"}"
] | Append text to this element.
var p = new CKEDITOR.dom.element( 'p' );
p.appendText( 'This is' );
p.appendText( ' some text' );
// Result: '<p>This is some text</p>'
@param {String} text The text to be appended.
@returns {CKEDITOR.dom.node} The appended node. | [
"Append",
"text",
"to",
"this",
"element",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/dom/element.js#L248-L253 |
|
55,953 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/dom/element.js | function( parent ) {
var range = new CKEDITOR.dom.range( this.getDocument() );
// We'll be extracting part of this element, so let's use our
// range to get the correct piece.
range.setStartAfter( this );
range.setEndAfter( parent );
// Extract it.
var docFrag = range.extractContents();
// Move the element outside the broken element.
range.insertNode( this.remove() );
// Re-insert the extracted piece after the element.
docFrag.insertAfterNode( this );
} | javascript | function( parent ) {
var range = new CKEDITOR.dom.range( this.getDocument() );
// We'll be extracting part of this element, so let's use our
// range to get the correct piece.
range.setStartAfter( this );
range.setEndAfter( parent );
// Extract it.
var docFrag = range.extractContents();
// Move the element outside the broken element.
range.insertNode( this.remove() );
// Re-insert the extracted piece after the element.
docFrag.insertAfterNode( this );
} | [
"function",
"(",
"parent",
")",
"{",
"var",
"range",
"=",
"new",
"CKEDITOR",
".",
"dom",
".",
"range",
"(",
"this",
".",
"getDocument",
"(",
")",
")",
";",
"// We'll be extracting part of this element, so let's use our",
"// range to get the correct piece.",
"range",
".",
"setStartAfter",
"(",
"this",
")",
";",
"range",
".",
"setEndAfter",
"(",
"parent",
")",
";",
"// Extract it.",
"var",
"docFrag",
"=",
"range",
".",
"extractContents",
"(",
")",
";",
"// Move the element outside the broken element.",
"range",
".",
"insertNode",
"(",
"this",
".",
"remove",
"(",
")",
")",
";",
"// Re-insert the extracted piece after the element.",
"docFrag",
".",
"insertAfterNode",
"(",
"this",
")",
";",
"}"
] | Breaks one of the ancestor element in the element position, moving
this element between the broken parts.
// Before breaking:
// <b>This <i>is some<span /> sample</i> test text</b>
// If "element" is <span /> and "parent" is <i>:
// <b>This <i>is some</i><span /><i> sample</i> test text</b>
element.breakParent( parent );
// Before breaking:
// <b>This <i>is some<span /> sample</i> test text</b>
// If "element" is <span /> and "parent" is <b>:
// <b>This <i>is some</i></b><span /><b><i> sample</i> test text</b>
element.breakParent( parent );
@param {CKEDITOR.dom.element} parent The anscestor element to get broken. | [
"Breaks",
"one",
"of",
"the",
"ancestor",
"element",
"in",
"the",
"element",
"position",
"moving",
"this",
"element",
"between",
"the",
"broken",
"parts",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/dom/element.js#L298-L314 |
|
55,954 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/dom/element.js | function() {
// http://help.dottoro.com/ljvmcrrn.php
var rect = CKEDITOR.tools.extend( {}, this.$.getBoundingClientRect() );
!rect.width && ( rect.width = rect.right - rect.left );
!rect.height && ( rect.height = rect.bottom - rect.top );
return rect;
} | javascript | function() {
// http://help.dottoro.com/ljvmcrrn.php
var rect = CKEDITOR.tools.extend( {}, this.$.getBoundingClientRect() );
!rect.width && ( rect.width = rect.right - rect.left );
!rect.height && ( rect.height = rect.bottom - rect.top );
return rect;
} | [
"function",
"(",
")",
"{",
"// http://help.dottoro.com/ljvmcrrn.php",
"var",
"rect",
"=",
"CKEDITOR",
".",
"tools",
".",
"extend",
"(",
"{",
"}",
",",
"this",
".",
"$",
".",
"getBoundingClientRect",
"(",
")",
")",
";",
"!",
"rect",
".",
"width",
"&&",
"(",
"rect",
".",
"width",
"=",
"rect",
".",
"right",
"-",
"rect",
".",
"left",
")",
";",
"!",
"rect",
".",
"height",
"&&",
"(",
"rect",
".",
"height",
"=",
"rect",
".",
"bottom",
"-",
"rect",
".",
"top",
")",
";",
"return",
"rect",
";",
"}"
] | Retrieve the bounding rectangle of the current element, in pixels,
relative to the upper-left corner of the browser's client area.
@returns {Object} The dimensions of the DOM element including
`left`, `top`, `right`, `bottom`, `width` and `height`. | [
"Retrieve",
"the",
"bounding",
"rectangle",
"of",
"the",
"current",
"element",
"in",
"pixels",
"relative",
"to",
"the",
"upper",
"-",
"left",
"corner",
"of",
"the",
"browser",
"s",
"client",
"area",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/dom/element.js#L399-L407 |
|
55,955 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/dom/element.js | function( otherElement ) {
// do shallow clones, but with IDs
var thisEl = this.clone( 0, 1 ),
otherEl = otherElement.clone( 0, 1 );
// Remove distractions.
thisEl.removeAttributes( [ '_moz_dirty', 'data-cke-expando', 'data-cke-saved-href', 'data-cke-saved-name' ] );
otherEl.removeAttributes( [ '_moz_dirty', 'data-cke-expando', 'data-cke-saved-href', 'data-cke-saved-name' ] );
// Native comparison available.
if ( thisEl.$.isEqualNode ) {
// Styles order matters.
thisEl.$.style.cssText = CKEDITOR.tools.normalizeCssText( thisEl.$.style.cssText );
otherEl.$.style.cssText = CKEDITOR.tools.normalizeCssText( otherEl.$.style.cssText );
return thisEl.$.isEqualNode( otherEl.$ );
} else {
thisEl = thisEl.getOuterHtml();
otherEl = otherEl.getOuterHtml();
// Fix tiny difference between link href in older IEs.
if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 && this.is( 'a' ) ) {
var parent = this.getParent();
if ( parent.type == CKEDITOR.NODE_ELEMENT ) {
var el = parent.clone();
el.setHtml( thisEl ), thisEl = el.getHtml();
el.setHtml( otherEl ), otherEl = el.getHtml();
}
}
return thisEl == otherEl;
}
} | javascript | function( otherElement ) {
// do shallow clones, but with IDs
var thisEl = this.clone( 0, 1 ),
otherEl = otherElement.clone( 0, 1 );
// Remove distractions.
thisEl.removeAttributes( [ '_moz_dirty', 'data-cke-expando', 'data-cke-saved-href', 'data-cke-saved-name' ] );
otherEl.removeAttributes( [ '_moz_dirty', 'data-cke-expando', 'data-cke-saved-href', 'data-cke-saved-name' ] );
// Native comparison available.
if ( thisEl.$.isEqualNode ) {
// Styles order matters.
thisEl.$.style.cssText = CKEDITOR.tools.normalizeCssText( thisEl.$.style.cssText );
otherEl.$.style.cssText = CKEDITOR.tools.normalizeCssText( otherEl.$.style.cssText );
return thisEl.$.isEqualNode( otherEl.$ );
} else {
thisEl = thisEl.getOuterHtml();
otherEl = otherEl.getOuterHtml();
// Fix tiny difference between link href in older IEs.
if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 && this.is( 'a' ) ) {
var parent = this.getParent();
if ( parent.type == CKEDITOR.NODE_ELEMENT ) {
var el = parent.clone();
el.setHtml( thisEl ), thisEl = el.getHtml();
el.setHtml( otherEl ), otherEl = el.getHtml();
}
}
return thisEl == otherEl;
}
} | [
"function",
"(",
"otherElement",
")",
"{",
"// do shallow clones, but with IDs",
"var",
"thisEl",
"=",
"this",
".",
"clone",
"(",
"0",
",",
"1",
")",
",",
"otherEl",
"=",
"otherElement",
".",
"clone",
"(",
"0",
",",
"1",
")",
";",
"// Remove distractions.",
"thisEl",
".",
"removeAttributes",
"(",
"[",
"'_moz_dirty'",
",",
"'data-cke-expando'",
",",
"'data-cke-saved-href'",
",",
"'data-cke-saved-name'",
"]",
")",
";",
"otherEl",
".",
"removeAttributes",
"(",
"[",
"'_moz_dirty'",
",",
"'data-cke-expando'",
",",
"'data-cke-saved-href'",
",",
"'data-cke-saved-name'",
"]",
")",
";",
"// Native comparison available.",
"if",
"(",
"thisEl",
".",
"$",
".",
"isEqualNode",
")",
"{",
"// Styles order matters.",
"thisEl",
".",
"$",
".",
"style",
".",
"cssText",
"=",
"CKEDITOR",
".",
"tools",
".",
"normalizeCssText",
"(",
"thisEl",
".",
"$",
".",
"style",
".",
"cssText",
")",
";",
"otherEl",
".",
"$",
".",
"style",
".",
"cssText",
"=",
"CKEDITOR",
".",
"tools",
".",
"normalizeCssText",
"(",
"otherEl",
".",
"$",
".",
"style",
".",
"cssText",
")",
";",
"return",
"thisEl",
".",
"$",
".",
"isEqualNode",
"(",
"otherEl",
".",
"$",
")",
";",
"}",
"else",
"{",
"thisEl",
"=",
"thisEl",
".",
"getOuterHtml",
"(",
")",
";",
"otherEl",
"=",
"otherEl",
".",
"getOuterHtml",
"(",
")",
";",
"// Fix tiny difference between link href in older IEs.",
"if",
"(",
"CKEDITOR",
".",
"env",
".",
"ie",
"&&",
"CKEDITOR",
".",
"env",
".",
"version",
"<",
"9",
"&&",
"this",
".",
"is",
"(",
"'a'",
")",
")",
"{",
"var",
"parent",
"=",
"this",
".",
"getParent",
"(",
")",
";",
"if",
"(",
"parent",
".",
"type",
"==",
"CKEDITOR",
".",
"NODE_ELEMENT",
")",
"{",
"var",
"el",
"=",
"parent",
".",
"clone",
"(",
")",
";",
"el",
".",
"setHtml",
"(",
"thisEl",
")",
",",
"thisEl",
"=",
"el",
".",
"getHtml",
"(",
")",
";",
"el",
".",
"setHtml",
"(",
"otherEl",
")",
",",
"otherEl",
"=",
"el",
".",
"getHtml",
"(",
")",
";",
"}",
"}",
"return",
"thisEl",
"==",
"otherEl",
";",
"}",
"}"
] | Compare this element's inner html, tag name, attributes, etc. with other one.
See [W3C's DOM Level 3 spec - node#isEqualNode](http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-isEqualNode)
for more details.
@param {CKEDITOR.dom.element} otherElement Element to compare.
@returns {Boolean} | [
"Compare",
"this",
"element",
"s",
"inner",
"html",
"tag",
"name",
"attributes",
"etc",
".",
"with",
"other",
"one",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/dom/element.js#L843-L874 |
|
55,956 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/dom/element.js | function() {
// CSS unselectable.
this.setStyles( CKEDITOR.tools.cssVendorPrefix( 'user-select', 'none' ) );
// For IE/Opera which doesn't support for the above CSS style,
// the unselectable="on" attribute only specifies the selection
// process cannot start in the element itself, and it doesn't inherit.
if ( CKEDITOR.env.ie ) {
this.setAttribute( 'unselectable', 'on' );
var element,
elements = this.getElementsByTag( '*' );
for ( var i = 0, count = elements.count() ; i < count ; i++ ) {
element = elements.getItem( i );
element.setAttribute( 'unselectable', 'on' );
}
}
} | javascript | function() {
// CSS unselectable.
this.setStyles( CKEDITOR.tools.cssVendorPrefix( 'user-select', 'none' ) );
// For IE/Opera which doesn't support for the above CSS style,
// the unselectable="on" attribute only specifies the selection
// process cannot start in the element itself, and it doesn't inherit.
if ( CKEDITOR.env.ie ) {
this.setAttribute( 'unselectable', 'on' );
var element,
elements = this.getElementsByTag( '*' );
for ( var i = 0, count = elements.count() ; i < count ; i++ ) {
element = elements.getItem( i );
element.setAttribute( 'unselectable', 'on' );
}
}
} | [
"function",
"(",
")",
"{",
"// CSS unselectable.",
"this",
".",
"setStyles",
"(",
"CKEDITOR",
".",
"tools",
".",
"cssVendorPrefix",
"(",
"'user-select'",
",",
"'none'",
")",
")",
";",
"// For IE/Opera which doesn't support for the above CSS style,",
"// the unselectable=\"on\" attribute only specifies the selection",
"// process cannot start in the element itself, and it doesn't inherit.",
"if",
"(",
"CKEDITOR",
".",
"env",
".",
"ie",
")",
"{",
"this",
".",
"setAttribute",
"(",
"'unselectable'",
",",
"'on'",
")",
";",
"var",
"element",
",",
"elements",
"=",
"this",
".",
"getElementsByTag",
"(",
"'*'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"count",
"=",
"elements",
".",
"count",
"(",
")",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"element",
"=",
"elements",
".",
"getItem",
"(",
"i",
")",
";",
"element",
".",
"setAttribute",
"(",
"'unselectable'",
",",
"'on'",
")",
";",
"}",
"}",
"}"
] | Makes the element and its children unselectable.
var element = CKEDITOR.document.getById( 'myElement' );
element.unselectable();
@method | [
"Makes",
"the",
"element",
"and",
"its",
"children",
"unselectable",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/dom/element.js#L1351-L1369 |
|
55,957 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/dom/element.js | function( alignToTop ) {
var parent = this.getParent();
if ( !parent )
return;
// Scroll the element into parent container from the inner out.
do {
// Check ancestors that overflows.
var overflowed =
parent.$.clientWidth && parent.$.clientWidth < parent.$.scrollWidth ||
parent.$.clientHeight && parent.$.clientHeight < parent.$.scrollHeight;
// Skip body element, which will report wrong clientHeight when containing
// floated content. (#9523)
if ( overflowed && !parent.is( 'body' ) )
this.scrollIntoParent( parent, alignToTop, 1 );
// Walk across the frame.
if ( parent.is( 'html' ) ) {
var win = parent.getWindow();
// Avoid security error.
try {
var iframe = win.$.frameElement;
iframe && ( parent = new CKEDITOR.dom.element( iframe ) );
} catch ( er ) {}
}
}
while ( ( parent = parent.getParent() ) );
} | javascript | function( alignToTop ) {
var parent = this.getParent();
if ( !parent )
return;
// Scroll the element into parent container from the inner out.
do {
// Check ancestors that overflows.
var overflowed =
parent.$.clientWidth && parent.$.clientWidth < parent.$.scrollWidth ||
parent.$.clientHeight && parent.$.clientHeight < parent.$.scrollHeight;
// Skip body element, which will report wrong clientHeight when containing
// floated content. (#9523)
if ( overflowed && !parent.is( 'body' ) )
this.scrollIntoParent( parent, alignToTop, 1 );
// Walk across the frame.
if ( parent.is( 'html' ) ) {
var win = parent.getWindow();
// Avoid security error.
try {
var iframe = win.$.frameElement;
iframe && ( parent = new CKEDITOR.dom.element( iframe ) );
} catch ( er ) {}
}
}
while ( ( parent = parent.getParent() ) );
} | [
"function",
"(",
"alignToTop",
")",
"{",
"var",
"parent",
"=",
"this",
".",
"getParent",
"(",
")",
";",
"if",
"(",
"!",
"parent",
")",
"return",
";",
"// Scroll the element into parent container from the inner out.",
"do",
"{",
"// Check ancestors that overflows.",
"var",
"overflowed",
"=",
"parent",
".",
"$",
".",
"clientWidth",
"&&",
"parent",
".",
"$",
".",
"clientWidth",
"<",
"parent",
".",
"$",
".",
"scrollWidth",
"||",
"parent",
".",
"$",
".",
"clientHeight",
"&&",
"parent",
".",
"$",
".",
"clientHeight",
"<",
"parent",
".",
"$",
".",
"scrollHeight",
";",
"// Skip body element, which will report wrong clientHeight when containing",
"// floated content. (#9523)",
"if",
"(",
"overflowed",
"&&",
"!",
"parent",
".",
"is",
"(",
"'body'",
")",
")",
"this",
".",
"scrollIntoParent",
"(",
"parent",
",",
"alignToTop",
",",
"1",
")",
";",
"// Walk across the frame.",
"if",
"(",
"parent",
".",
"is",
"(",
"'html'",
")",
")",
"{",
"var",
"win",
"=",
"parent",
".",
"getWindow",
"(",
")",
";",
"// Avoid security error.",
"try",
"{",
"var",
"iframe",
"=",
"win",
".",
"$",
".",
"frameElement",
";",
"iframe",
"&&",
"(",
"parent",
"=",
"new",
"CKEDITOR",
".",
"dom",
".",
"element",
"(",
"iframe",
")",
")",
";",
"}",
"catch",
"(",
"er",
")",
"{",
"}",
"}",
"}",
"while",
"(",
"(",
"parent",
"=",
"parent",
".",
"getParent",
"(",
")",
")",
")",
";",
"}"
] | Make any page element visible inside the browser viewport.
@param {Boolean} [alignToTop=false] | [
"Make",
"any",
"page",
"element",
"visible",
"inside",
"the",
"browser",
"viewport",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/dom/element.js#L1488-L1517 |
|
55,958 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/dom/element.js | scrollBy | function scrollBy( x, y ) {
// Webkit doesn't support "scrollTop/scrollLeft"
// on documentElement/body element.
if ( /body|html/.test( parent.getName() ) )
parent.getWindow().$.scrollBy( x, y );
else {
parent.$.scrollLeft += x;
parent.$.scrollTop += y;
}
} | javascript | function scrollBy( x, y ) {
// Webkit doesn't support "scrollTop/scrollLeft"
// on documentElement/body element.
if ( /body|html/.test( parent.getName() ) )
parent.getWindow().$.scrollBy( x, y );
else {
parent.$.scrollLeft += x;
parent.$.scrollTop += y;
}
} | [
"function",
"scrollBy",
"(",
"x",
",",
"y",
")",
"{",
"// Webkit doesn't support \"scrollTop/scrollLeft\"",
"// on documentElement/body element.",
"if",
"(",
"/",
"body|html",
"/",
".",
"test",
"(",
"parent",
".",
"getName",
"(",
")",
")",
")",
"parent",
".",
"getWindow",
"(",
")",
".",
"$",
".",
"scrollBy",
"(",
"x",
",",
"y",
")",
";",
"else",
"{",
"parent",
".",
"$",
".",
"scrollLeft",
"+=",
"x",
";",
"parent",
".",
"$",
".",
"scrollTop",
"+=",
"y",
";",
"}",
"}"
] | Scroll the parent by the specified amount. | [
"Scroll",
"the",
"parent",
"by",
"the",
"specified",
"amount",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/dom/element.js#L1540-L1549 |
55,959 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/dom/element.js | screenPos | function screenPos( element, refWin ) {
var pos = { x: 0, y: 0 };
if ( !( element.is( isQuirks ? 'body' : 'html' ) ) ) {
var box = element.$.getBoundingClientRect();
pos.x = box.left, pos.y = box.top;
}
var win = element.getWindow();
if ( !win.equals( refWin ) ) {
var outerPos = screenPos( CKEDITOR.dom.element.get( win.$.frameElement ), refWin );
pos.x += outerPos.x, pos.y += outerPos.y;
}
return pos;
} | javascript | function screenPos( element, refWin ) {
var pos = { x: 0, y: 0 };
if ( !( element.is( isQuirks ? 'body' : 'html' ) ) ) {
var box = element.$.getBoundingClientRect();
pos.x = box.left, pos.y = box.top;
}
var win = element.getWindow();
if ( !win.equals( refWin ) ) {
var outerPos = screenPos( CKEDITOR.dom.element.get( win.$.frameElement ), refWin );
pos.x += outerPos.x, pos.y += outerPos.y;
}
return pos;
} | [
"function",
"screenPos",
"(",
"element",
",",
"refWin",
")",
"{",
"var",
"pos",
"=",
"{",
"x",
":",
"0",
",",
"y",
":",
"0",
"}",
";",
"if",
"(",
"!",
"(",
"element",
".",
"is",
"(",
"isQuirks",
"?",
"'body'",
":",
"'html'",
")",
")",
")",
"{",
"var",
"box",
"=",
"element",
".",
"$",
".",
"getBoundingClientRect",
"(",
")",
";",
"pos",
".",
"x",
"=",
"box",
".",
"left",
",",
"pos",
".",
"y",
"=",
"box",
".",
"top",
";",
"}",
"var",
"win",
"=",
"element",
".",
"getWindow",
"(",
")",
";",
"if",
"(",
"!",
"win",
".",
"equals",
"(",
"refWin",
")",
")",
"{",
"var",
"outerPos",
"=",
"screenPos",
"(",
"CKEDITOR",
".",
"dom",
".",
"element",
".",
"get",
"(",
"win",
".",
"$",
".",
"frameElement",
")",
",",
"refWin",
")",
";",
"pos",
".",
"x",
"+=",
"outerPos",
".",
"x",
",",
"pos",
".",
"y",
"+=",
"outerPos",
".",
"y",
";",
"}",
"return",
"pos",
";",
"}"
] | Figure out the element position relative to the specified window. | [
"Figure",
"out",
"the",
"element",
"position",
"relative",
"to",
"the",
"specified",
"window",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/dom/element.js#L1552-L1567 |
55,960 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/dom/element.js | function( selector ) {
var removeTmpId = createTmpId( this ),
list = new CKEDITOR.dom.nodeList(
this.$.querySelectorAll( getContextualizedSelector( this, selector ) )
);
removeTmpId();
return list;
} | javascript | function( selector ) {
var removeTmpId = createTmpId( this ),
list = new CKEDITOR.dom.nodeList(
this.$.querySelectorAll( getContextualizedSelector( this, selector ) )
);
removeTmpId();
return list;
} | [
"function",
"(",
"selector",
")",
"{",
"var",
"removeTmpId",
"=",
"createTmpId",
"(",
"this",
")",
",",
"list",
"=",
"new",
"CKEDITOR",
".",
"dom",
".",
"nodeList",
"(",
"this",
".",
"$",
".",
"querySelectorAll",
"(",
"getContextualizedSelector",
"(",
"this",
",",
"selector",
")",
")",
")",
";",
"removeTmpId",
"(",
")",
";",
"return",
"list",
";",
"}"
] | Returns list of elements within this element that match specified `selector`.
**Notes:**
* Not available in IE7.
* Returned list is not a live collection (like a result of native `querySelectorAll`).
* Unlike native `querySelectorAll` this method ensures selector contextualization. This is:
HTML: '<body><div><i>foo</i></div></body>'
Native: div.querySelectorAll( 'body i' ) // -> [ <i>foo</i> ]
Method: div.find( 'body i' ) // -> []
div.find( 'i' ) // -> [ <i>foo</i> ]
@since 4.3
@param {String} selector
@returns {CKEDITOR.dom.nodeList} | [
"Returns",
"list",
"of",
"elements",
"within",
"this",
"element",
"that",
"match",
"specified",
"selector",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/dom/element.js#L1882-L1891 |
|
55,961 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/dom/element.js | function( selector ) {
var removeTmpId = createTmpId( this ),
found = this.$.querySelector( getContextualizedSelector( this, selector ) );
removeTmpId();
return found ? new CKEDITOR.dom.element( found ) : null;
} | javascript | function( selector ) {
var removeTmpId = createTmpId( this ),
found = this.$.querySelector( getContextualizedSelector( this, selector ) );
removeTmpId();
return found ? new CKEDITOR.dom.element( found ) : null;
} | [
"function",
"(",
"selector",
")",
"{",
"var",
"removeTmpId",
"=",
"createTmpId",
"(",
"this",
")",
",",
"found",
"=",
"this",
".",
"$",
".",
"querySelector",
"(",
"getContextualizedSelector",
"(",
"this",
",",
"selector",
")",
")",
";",
"removeTmpId",
"(",
")",
";",
"return",
"found",
"?",
"new",
"CKEDITOR",
".",
"dom",
".",
"element",
"(",
"found",
")",
":",
"null",
";",
"}"
] | Returns first element within this element that matches specified `selector`.
**Notes:**
* Not available in IE7.
* Unlike native `querySelectorAll` this method ensures selector contextualization. This is:
HTML: '<body><div><i>foo</i></div></body>'
Native: div.querySelector( 'body i' ) // -> <i>foo</i>
Method: div.findOne( 'body i' ) // -> null
div.findOne( 'i' ) // -> <i>foo</i>
@since 4.3
@param {String} selector
@returns {CKEDITOR.dom.element} | [
"Returns",
"first",
"element",
"within",
"this",
"element",
"that",
"matches",
"specified",
"selector",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/dom/element.js#L1910-L1917 |
|
55,962 | Mindfor/gulp-bundle-file | index.js | pushTo | function pushTo(array) {
return map(function (file, cb) {
array.push(file);
cb(null, file);
});
} | javascript | function pushTo(array) {
return map(function (file, cb) {
array.push(file);
cb(null, file);
});
} | [
"function",
"pushTo",
"(",
"array",
")",
"{",
"return",
"map",
"(",
"function",
"(",
"file",
",",
"cb",
")",
"{",
"array",
".",
"push",
"(",
"file",
")",
";",
"cb",
"(",
"null",
",",
"file",
")",
";",
"}",
")",
";",
"}"
] | pushes files from pipe to array | [
"pushes",
"files",
"from",
"pipe",
"to",
"array"
] | c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6 | https://github.com/Mindfor/gulp-bundle-file/blob/c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6/index.js#L14-L19 |
55,963 | Mindfor/gulp-bundle-file | index.js | processBundleFile | function processBundleFile(file, bundleExt, variables, bundleHandler, errorCallback) {
// get bundle files
var lines = file.contents.toString().split('\n');
var resultFilePaths = [];
lines.forEach(function (line) {
var filePath = getFilePathFromLine(file, line, variables);
if (filePath)
resultFilePaths.push(filePath);
});
if (!errorCallback)
errorCallback = function () { };
// find files and send to buffer
var bundleSrc = fs.src(resultFilePaths)
.on('error', errorCallback) // handle file not found errors
.pipe(plumber(errorCallback)) // handle other errors inside pipeline
.pipe(recursiveBundle(bundleExt, variables, errorCallback));
if (bundleHandler && typeof bundleHandler === 'function')
bundleSrc = bundleHandler(bundleSrc);
return bundleSrc.pipe(plumber.stop());
} | javascript | function processBundleFile(file, bundleExt, variables, bundleHandler, errorCallback) {
// get bundle files
var lines = file.contents.toString().split('\n');
var resultFilePaths = [];
lines.forEach(function (line) {
var filePath = getFilePathFromLine(file, line, variables);
if (filePath)
resultFilePaths.push(filePath);
});
if (!errorCallback)
errorCallback = function () { };
// find files and send to buffer
var bundleSrc = fs.src(resultFilePaths)
.on('error', errorCallback) // handle file not found errors
.pipe(plumber(errorCallback)) // handle other errors inside pipeline
.pipe(recursiveBundle(bundleExt, variables, errorCallback));
if (bundleHandler && typeof bundleHandler === 'function')
bundleSrc = bundleHandler(bundleSrc);
return bundleSrc.pipe(plumber.stop());
} | [
"function",
"processBundleFile",
"(",
"file",
",",
"bundleExt",
",",
"variables",
",",
"bundleHandler",
",",
"errorCallback",
")",
"{",
"// get bundle files",
"var",
"lines",
"=",
"file",
".",
"contents",
".",
"toString",
"(",
")",
".",
"split",
"(",
"'\\n'",
")",
";",
"var",
"resultFilePaths",
"=",
"[",
"]",
";",
"lines",
".",
"forEach",
"(",
"function",
"(",
"line",
")",
"{",
"var",
"filePath",
"=",
"getFilePathFromLine",
"(",
"file",
",",
"line",
",",
"variables",
")",
";",
"if",
"(",
"filePath",
")",
"resultFilePaths",
".",
"push",
"(",
"filePath",
")",
";",
"}",
")",
";",
"if",
"(",
"!",
"errorCallback",
")",
"errorCallback",
"=",
"function",
"(",
")",
"{",
"}",
";",
"// find files and send to buffer",
"var",
"bundleSrc",
"=",
"fs",
".",
"src",
"(",
"resultFilePaths",
")",
".",
"on",
"(",
"'error'",
",",
"errorCallback",
")",
"// handle file not found errors",
".",
"pipe",
"(",
"plumber",
"(",
"errorCallback",
")",
")",
"// handle other errors inside pipeline ",
".",
"pipe",
"(",
"recursiveBundle",
"(",
"bundleExt",
",",
"variables",
",",
"errorCallback",
")",
")",
";",
"if",
"(",
"bundleHandler",
"&&",
"typeof",
"bundleHandler",
"===",
"'function'",
")",
"bundleSrc",
"=",
"bundleHandler",
"(",
"bundleSrc",
")",
";",
"return",
"bundleSrc",
".",
"pipe",
"(",
"plumber",
".",
"stop",
"(",
")",
")",
";",
"}"
] | creates new pipe for files from bundle | [
"creates",
"new",
"pipe",
"for",
"files",
"from",
"bundle"
] | c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6 | https://github.com/Mindfor/gulp-bundle-file/blob/c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6/index.js#L35-L57 |
55,964 | Mindfor/gulp-bundle-file | index.js | getFilePathFromLine | function getFilePathFromLine(bundleFile, line, variables) {
// handle variables
var varRegex = /@{([^}]+)}/;
var match;
while (match = line.match(varRegex)) {
var varName = match[1];
if (!variables || typeof (variables[varName]) === 'undefined')
throw new gutil.PluginError(pluginName, bundleFile.path + ': variable "' + varName + '" is not specified');
var varValue = variables[varName];
line = line.substr(0, match.index) + varValue + line.substr(match.index + match[0].length);
}
if (line === '')
return null;
// handle `!` negated file paths
var negative = line[0] === '!';
if (negative)
line = line.substr(1);
// get file path for line
var filePath;
if (line.indexOf('./') === 0)
filePath = path.resolve(bundleFile.cwd, line);
else
filePath = path.resolve(bundleFile.base, line);
// return path
if (negative)
return '!' + filePath;
return filePath;
} | javascript | function getFilePathFromLine(bundleFile, line, variables) {
// handle variables
var varRegex = /@{([^}]+)}/;
var match;
while (match = line.match(varRegex)) {
var varName = match[1];
if (!variables || typeof (variables[varName]) === 'undefined')
throw new gutil.PluginError(pluginName, bundleFile.path + ': variable "' + varName + '" is not specified');
var varValue = variables[varName];
line = line.substr(0, match.index) + varValue + line.substr(match.index + match[0].length);
}
if (line === '')
return null;
// handle `!` negated file paths
var negative = line[0] === '!';
if (negative)
line = line.substr(1);
// get file path for line
var filePath;
if (line.indexOf('./') === 0)
filePath = path.resolve(bundleFile.cwd, line);
else
filePath = path.resolve(bundleFile.base, line);
// return path
if (negative)
return '!' + filePath;
return filePath;
} | [
"function",
"getFilePathFromLine",
"(",
"bundleFile",
",",
"line",
",",
"variables",
")",
"{",
"// handle variables",
"var",
"varRegex",
"=",
"/",
"@{([^}]+)}",
"/",
";",
"var",
"match",
";",
"while",
"(",
"match",
"=",
"line",
".",
"match",
"(",
"varRegex",
")",
")",
"{",
"var",
"varName",
"=",
"match",
"[",
"1",
"]",
";",
"if",
"(",
"!",
"variables",
"||",
"typeof",
"(",
"variables",
"[",
"varName",
"]",
")",
"===",
"'undefined'",
")",
"throw",
"new",
"gutil",
".",
"PluginError",
"(",
"pluginName",
",",
"bundleFile",
".",
"path",
"+",
"': variable \"'",
"+",
"varName",
"+",
"'\" is not specified'",
")",
";",
"var",
"varValue",
"=",
"variables",
"[",
"varName",
"]",
";",
"line",
"=",
"line",
".",
"substr",
"(",
"0",
",",
"match",
".",
"index",
")",
"+",
"varValue",
"+",
"line",
".",
"substr",
"(",
"match",
".",
"index",
"+",
"match",
"[",
"0",
"]",
".",
"length",
")",
";",
"}",
"if",
"(",
"line",
"===",
"''",
")",
"return",
"null",
";",
"// handle `!` negated file paths",
"var",
"negative",
"=",
"line",
"[",
"0",
"]",
"===",
"'!'",
";",
"if",
"(",
"negative",
")",
"line",
"=",
"line",
".",
"substr",
"(",
"1",
")",
";",
"// get file path for line",
"var",
"filePath",
";",
"if",
"(",
"line",
".",
"indexOf",
"(",
"'./'",
")",
"===",
"0",
")",
"filePath",
"=",
"path",
".",
"resolve",
"(",
"bundleFile",
".",
"cwd",
",",
"line",
")",
";",
"else",
"filePath",
"=",
"path",
".",
"resolve",
"(",
"bundleFile",
".",
"base",
",",
"line",
")",
";",
"// return path",
"if",
"(",
"negative",
")",
"return",
"'!'",
"+",
"filePath",
";",
"return",
"filePath",
";",
"}"
] | parses file path from line in bundle file | [
"parses",
"file",
"path",
"from",
"line",
"in",
"bundle",
"file"
] | c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6 | https://github.com/Mindfor/gulp-bundle-file/blob/c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6/index.js#L60-L92 |
55,965 | Mindfor/gulp-bundle-file | index.js | recursiveBundle | function recursiveBundle(bundleExt, variables, errorCallback) {
return through2.obj(function (file, enc, cb) {
if (!checkFile(file, cb))
return;
// standart file push to callback
if (path.extname(file.path).toLowerCase() != bundleExt)
return cb(null, file);
// bundle file should be parsed
processBundleFile(file, bundleExt, variables, null, errorCallback)
.pipe(pushTo(this))
.on('end', cb);
});
} | javascript | function recursiveBundle(bundleExt, variables, errorCallback) {
return through2.obj(function (file, enc, cb) {
if (!checkFile(file, cb))
return;
// standart file push to callback
if (path.extname(file.path).toLowerCase() != bundleExt)
return cb(null, file);
// bundle file should be parsed
processBundleFile(file, bundleExt, variables, null, errorCallback)
.pipe(pushTo(this))
.on('end', cb);
});
} | [
"function",
"recursiveBundle",
"(",
"bundleExt",
",",
"variables",
",",
"errorCallback",
")",
"{",
"return",
"through2",
".",
"obj",
"(",
"function",
"(",
"file",
",",
"enc",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"checkFile",
"(",
"file",
",",
"cb",
")",
")",
"return",
";",
"// standart file push to callback",
"if",
"(",
"path",
".",
"extname",
"(",
"file",
".",
"path",
")",
".",
"toLowerCase",
"(",
")",
"!=",
"bundleExt",
")",
"return",
"cb",
"(",
"null",
",",
"file",
")",
";",
"// bundle file should be parsed",
"processBundleFile",
"(",
"file",
",",
"bundleExt",
",",
"variables",
",",
"null",
",",
"errorCallback",
")",
".",
"pipe",
"(",
"pushTo",
"(",
"this",
")",
")",
".",
"on",
"(",
"'end'",
",",
"cb",
")",
";",
"}",
")",
";",
"}"
] | recursively processes files and unwraps bundle files | [
"recursively",
"processes",
"files",
"and",
"unwraps",
"bundle",
"files"
] | c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6 | https://github.com/Mindfor/gulp-bundle-file/blob/c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6/index.js#L95-L109 |
55,966 | Mindfor/gulp-bundle-file | index.js | function (variables, bundleHandler) {
// handle if bundleHandler specified in first argument
if (!bundleHandler && typeof (variables) === 'function') {
bundleHandler = variables;
variables = null;
}
return through2.obj(function (file, enc, cb) {
if (!checkFile(file, cb))
return;
var ext = path.extname(file.path).toLowerCase();
var resultFileName = path.basename(file.path, ext);
var bundleFiles = processBundleFile(file, ext, variables, bundleHandler, cb);
if (file.sourceMap)
bundleFiles = bundleFiles.pipe(sourcemaps.init());
bundleFiles
.pipe(concat(resultFileName))
.pipe(pushTo(this))
.on('end', cb);
});
} | javascript | function (variables, bundleHandler) {
// handle if bundleHandler specified in first argument
if (!bundleHandler && typeof (variables) === 'function') {
bundleHandler = variables;
variables = null;
}
return through2.obj(function (file, enc, cb) {
if (!checkFile(file, cb))
return;
var ext = path.extname(file.path).toLowerCase();
var resultFileName = path.basename(file.path, ext);
var bundleFiles = processBundleFile(file, ext, variables, bundleHandler, cb);
if (file.sourceMap)
bundleFiles = bundleFiles.pipe(sourcemaps.init());
bundleFiles
.pipe(concat(resultFileName))
.pipe(pushTo(this))
.on('end', cb);
});
} | [
"function",
"(",
"variables",
",",
"bundleHandler",
")",
"{",
"// handle if bundleHandler specified in first argument",
"if",
"(",
"!",
"bundleHandler",
"&&",
"typeof",
"(",
"variables",
")",
"===",
"'function'",
")",
"{",
"bundleHandler",
"=",
"variables",
";",
"variables",
"=",
"null",
";",
"}",
"return",
"through2",
".",
"obj",
"(",
"function",
"(",
"file",
",",
"enc",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"checkFile",
"(",
"file",
",",
"cb",
")",
")",
"return",
";",
"var",
"ext",
"=",
"path",
".",
"extname",
"(",
"file",
".",
"path",
")",
".",
"toLowerCase",
"(",
")",
";",
"var",
"resultFileName",
"=",
"path",
".",
"basename",
"(",
"file",
".",
"path",
",",
"ext",
")",
";",
"var",
"bundleFiles",
"=",
"processBundleFile",
"(",
"file",
",",
"ext",
",",
"variables",
",",
"bundleHandler",
",",
"cb",
")",
";",
"if",
"(",
"file",
".",
"sourceMap",
")",
"bundleFiles",
"=",
"bundleFiles",
".",
"pipe",
"(",
"sourcemaps",
".",
"init",
"(",
")",
")",
";",
"bundleFiles",
".",
"pipe",
"(",
"concat",
"(",
"resultFileName",
")",
")",
".",
"pipe",
"(",
"pushTo",
"(",
"this",
")",
")",
".",
"on",
"(",
"'end'",
",",
"cb",
")",
";",
"}",
")",
";",
"}"
] | concatenates files from bundle and replaces bundle file in current pipe first parameter is function that handles source stream for each bundle | [
"concatenates",
"files",
"from",
"bundle",
"and",
"replaces",
"bundle",
"file",
"in",
"current",
"pipe",
"first",
"parameter",
"is",
"function",
"that",
"handles",
"source",
"stream",
"for",
"each",
"bundle"
] | c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6 | https://github.com/Mindfor/gulp-bundle-file/blob/c4d8a80d869c528d3d7e51d0b9944dbb1bcfecf6/index.js#L127-L149 |
|
55,967 | uugolab/sycle | lib/errors/dispatch-error.js | DispatchError | function DispatchError(message) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'DispatchError';
this.message = message;
} | javascript | function DispatchError(message) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'DispatchError';
this.message = message;
} | [
"function",
"DispatchError",
"(",
"message",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"arguments",
".",
"callee",
")",
";",
"this",
".",
"name",
"=",
"'DispatchError'",
";",
"this",
".",
"message",
"=",
"message",
";",
"}"
] | `DispatchError` error.
@api private | [
"DispatchError",
"error",
"."
] | 90902246537860adee22664a584c66d72826b5bb | https://github.com/uugolab/sycle/blob/90902246537860adee22664a584c66d72826b5bb/lib/errors/dispatch-error.js#L6-L11 |
55,968 | tunnckoCore/kind-error | index.js | delegateOptional | function delegateOptional (self) {
if (hasOwn(self, 'actual') && hasOwn(self, 'expected')) {
var kindOf = tryRequire('kind-of-extra', 'kind-error')
delegate(self, {
orig: {
actual: self.actual,
expected: self.expected
},
type: {
actual: kindOf(self.actual),
expected: kindOf(self.expected)
},
inspect: {
actual: util.inspect(self.actual),
expected: util.inspect(self.expected)
}
})
if (typeof self.message === 'function') {
self.message = self.message.call(self, self.type, self.inspect) // eslint-disable-line no-useless-call
}
}
return self
} | javascript | function delegateOptional (self) {
if (hasOwn(self, 'actual') && hasOwn(self, 'expected')) {
var kindOf = tryRequire('kind-of-extra', 'kind-error')
delegate(self, {
orig: {
actual: self.actual,
expected: self.expected
},
type: {
actual: kindOf(self.actual),
expected: kindOf(self.expected)
},
inspect: {
actual: util.inspect(self.actual),
expected: util.inspect(self.expected)
}
})
if (typeof self.message === 'function') {
self.message = self.message.call(self, self.type, self.inspect) // eslint-disable-line no-useless-call
}
}
return self
} | [
"function",
"delegateOptional",
"(",
"self",
")",
"{",
"if",
"(",
"hasOwn",
"(",
"self",
",",
"'actual'",
")",
"&&",
"hasOwn",
"(",
"self",
",",
"'expected'",
")",
")",
"{",
"var",
"kindOf",
"=",
"tryRequire",
"(",
"'kind-of-extra'",
",",
"'kind-error'",
")",
"delegate",
"(",
"self",
",",
"{",
"orig",
":",
"{",
"actual",
":",
"self",
".",
"actual",
",",
"expected",
":",
"self",
".",
"expected",
"}",
",",
"type",
":",
"{",
"actual",
":",
"kindOf",
"(",
"self",
".",
"actual",
")",
",",
"expected",
":",
"kindOf",
"(",
"self",
".",
"expected",
")",
"}",
",",
"inspect",
":",
"{",
"actual",
":",
"util",
".",
"inspect",
"(",
"self",
".",
"actual",
")",
",",
"expected",
":",
"util",
".",
"inspect",
"(",
"self",
".",
"expected",
")",
"}",
"}",
")",
"if",
"(",
"typeof",
"self",
".",
"message",
"===",
"'function'",
")",
"{",
"self",
".",
"message",
"=",
"self",
".",
"message",
".",
"call",
"(",
"self",
",",
"self",
".",
"type",
",",
"self",
".",
"inspect",
")",
"// eslint-disable-line no-useless-call",
"}",
"}",
"return",
"self",
"}"
] | > Delegate additional optional properties to the `KindError` class.
If `actual` and `expected` properties given in `options` object.
@param {Object} `self`
@return {Object} | [
">",
"Delegate",
"additional",
"optional",
"properties",
"to",
"the",
"KindError",
"class",
".",
"If",
"actual",
"and",
"expected",
"properties",
"given",
"in",
"options",
"object",
"."
] | 3ab0e42a4bc6d42d8b7803027419e4f68e332027 | https://github.com/tunnckoCore/kind-error/blob/3ab0e42a4bc6d42d8b7803027419e4f68e332027/index.js#L72-L94 |
55,969 | tunnckoCore/kind-error | index.js | messageFormat | function messageFormat (type, inspect) {
var msg = this.detailed
? 'expect %s `%s`, but %s `%s` given'
: 'expect `%s`, but `%s` given'
return this.detailed
? util.format(msg, type.expected, inspect.expected, type.actual, inspect.actual)
: util.format(msg, type.expected, type.actual)
} | javascript | function messageFormat (type, inspect) {
var msg = this.detailed
? 'expect %s `%s`, but %s `%s` given'
: 'expect `%s`, but `%s` given'
return this.detailed
? util.format(msg, type.expected, inspect.expected, type.actual, inspect.actual)
: util.format(msg, type.expected, type.actual)
} | [
"function",
"messageFormat",
"(",
"type",
",",
"inspect",
")",
"{",
"var",
"msg",
"=",
"this",
".",
"detailed",
"?",
"'expect %s `%s`, but %s `%s` given'",
":",
"'expect `%s`, but `%s` given'",
"return",
"this",
".",
"detailed",
"?",
"util",
".",
"format",
"(",
"msg",
",",
"type",
".",
"expected",
",",
"inspect",
".",
"expected",
",",
"type",
".",
"actual",
",",
"inspect",
".",
"actual",
")",
":",
"util",
".",
"format",
"(",
"msg",
",",
"type",
".",
"expected",
",",
"type",
".",
"actual",
")",
"}"
] | > Default message formatting function.
@param {Object} `type`
@param {Object} `inspect`
@return {String} | [
">",
"Default",
"message",
"formatting",
"function",
"."
] | 3ab0e42a4bc6d42d8b7803027419e4f68e332027 | https://github.com/tunnckoCore/kind-error/blob/3ab0e42a4bc6d42d8b7803027419e4f68e332027/index.js#L124-L131 |
55,970 | wilmoore/regexp-map.js | index.js | remap | function remap (map, str) {
str = string.call(str) === '[object String]' ? str : ''
for (var key in map) {
if (str.match(new RegExp(key, 'i'))) return map[key]
}
return ''
} | javascript | function remap (map, str) {
str = string.call(str) === '[object String]' ? str : ''
for (var key in map) {
if (str.match(new RegExp(key, 'i'))) return map[key]
}
return ''
} | [
"function",
"remap",
"(",
"map",
",",
"str",
")",
"{",
"str",
"=",
"string",
".",
"call",
"(",
"str",
")",
"===",
"'[object String]'",
"?",
"str",
":",
"''",
"for",
"(",
"var",
"key",
"in",
"map",
")",
"{",
"if",
"(",
"str",
".",
"match",
"(",
"new",
"RegExp",
"(",
"key",
",",
"'i'",
")",
")",
")",
"return",
"map",
"[",
"key",
"]",
"}",
"return",
"''",
"}"
] | Curried function which takes a map of `RegExp` string keys which when successfully matched given string, resolves to mapped value.
@param {Object.<string, string>} map
Map of `RegExp` strings which when matched against string successfully, resolves to mapped value.
@param {String} str
String to search.
@return {String}
When matched returns corresponding mapped value; otherwise, an empty string. | [
"Curried",
"function",
"which",
"takes",
"a",
"map",
"of",
"RegExp",
"string",
"keys",
"which",
"when",
"successfully",
"matched",
"given",
"string",
"resolves",
"to",
"mapped",
"value",
"."
] | 2d40aad44c4cd36a2e6af0070534c599d00f7109 | https://github.com/wilmoore/regexp-map.js/blob/2d40aad44c4cd36a2e6af0070534c599d00f7109/index.js#L29-L37 |
55,971 | danigb/music.operator | index.js | add | function add (a, b) {
var fifths = a[0] + b[0]
var octaves = a[1] === null || b[1] === null ? null : a[1] + b[1]
return [fifths, octaves]
} | javascript | function add (a, b) {
var fifths = a[0] + b[0]
var octaves = a[1] === null || b[1] === null ? null : a[1] + b[1]
return [fifths, octaves]
} | [
"function",
"add",
"(",
"a",
",",
"b",
")",
"{",
"var",
"fifths",
"=",
"a",
"[",
"0",
"]",
"+",
"b",
"[",
"0",
"]",
"var",
"octaves",
"=",
"a",
"[",
"1",
"]",
"===",
"null",
"||",
"b",
"[",
"1",
"]",
"===",
"null",
"?",
"null",
":",
"a",
"[",
"1",
"]",
"+",
"b",
"[",
"1",
"]",
"return",
"[",
"fifths",
",",
"octaves",
"]",
"}"
] | Add two pitches. Can be used to tranpose pitches.
@param {Array} first - first pitch
@param {Array} second - second pitch
@return {Array} both pitches added
@example
operator.add([3, 0, 0], [4, 0, 0]) // => [0, 0, 1] | [
"Add",
"two",
"pitches",
".",
"Can",
"be",
"used",
"to",
"tranpose",
"pitches",
"."
] | 5da2c1528ba704dea0ca10065fda4b91aadc8b0d | https://github.com/danigb/music.operator/blob/5da2c1528ba704dea0ca10065fda4b91aadc8b0d/index.js#L178-L182 |
55,972 | danigb/music.operator | index.js | subtract | function subtract (a, b) {
var fifths = b[0] - a[0]
var octaves = a[1] !== null && b[1] !== null ? b[1] - a[1] : null
return [fifths, octaves]
} | javascript | function subtract (a, b) {
var fifths = b[0] - a[0]
var octaves = a[1] !== null && b[1] !== null ? b[1] - a[1] : null
return [fifths, octaves]
} | [
"function",
"subtract",
"(",
"a",
",",
"b",
")",
"{",
"var",
"fifths",
"=",
"b",
"[",
"0",
"]",
"-",
"a",
"[",
"0",
"]",
"var",
"octaves",
"=",
"a",
"[",
"1",
"]",
"!==",
"null",
"&&",
"b",
"[",
"1",
"]",
"!==",
"null",
"?",
"b",
"[",
"1",
"]",
"-",
"a",
"[",
"1",
"]",
":",
"null",
"return",
"[",
"fifths",
",",
"octaves",
"]",
"}"
] | Subtract two pitches or intervals. Can be used to find the distance between pitches.
@name subtract
@function
@param {Array} a - one pitch or interval in [pitch-array](https://github.com/danigb/pitch-array) format
@param {Array} b - the other pitch or interval in [pitch-array](https://github.com/danigb/pitch-array) format
@return {Array} both pitches or intervals substracted [pitch-array](https://github.com/danigb/pitch-array) format
@example
operator.subtract([4, 0, 0], [3, 0, 0]) // => [1, 0, 0] | [
"Subtract",
"two",
"pitches",
"or",
"intervals",
".",
"Can",
"be",
"used",
"to",
"find",
"the",
"distance",
"between",
"pitches",
"."
] | 5da2c1528ba704dea0ca10065fda4b91aadc8b0d | https://github.com/danigb/music.operator/blob/5da2c1528ba704dea0ca10065fda4b91aadc8b0d/index.js#L205-L209 |
55,973 | queckezz/list | lib/nth.js | nth | function nth (n, array) {
return n < 0 ? array[array.length + n] : array[n]
} | javascript | function nth (n, array) {
return n < 0 ? array[array.length + n] : array[n]
} | [
"function",
"nth",
"(",
"n",
",",
"array",
")",
"{",
"return",
"n",
"<",
"0",
"?",
"array",
"[",
"array",
".",
"length",
"+",
"n",
"]",
":",
"array",
"[",
"n",
"]",
"}"
] | Returns the `n`th element in the given `array`.
@param {Int} n Index
@param {Array} array Array to operate on
@return {Any} `n`th element | [
"Returns",
"the",
"n",
"th",
"element",
"in",
"the",
"given",
"array",
"."
] | a26130020b447a1aa136f0fed3283821490f7da4 | https://github.com/queckezz/list/blob/a26130020b447a1aa136f0fed3283821490f7da4/lib/nth.js#L11-L13 |
55,974 | YahooArchive/mojito-cli-jslint | lib/lintifier.js | scanErr | function scanErr(err, pathname) {
log.debug(err);
if ('ENOENT' === err.code) {
callback(pathname + ' does not exist.');
} else {
callback('Unexpected error.');
}
// cli does process.exit() in callback, but unit tests don't.
callback = function () {};
} | javascript | function scanErr(err, pathname) {
log.debug(err);
if ('ENOENT' === err.code) {
callback(pathname + ' does not exist.');
} else {
callback('Unexpected error.');
}
// cli does process.exit() in callback, but unit tests don't.
callback = function () {};
} | [
"function",
"scanErr",
"(",
"err",
",",
"pathname",
")",
"{",
"log",
".",
"debug",
"(",
"err",
")",
";",
"if",
"(",
"'ENOENT'",
"===",
"err",
".",
"code",
")",
"{",
"callback",
"(",
"pathname",
"+",
"' does not exist.'",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"'Unexpected error.'",
")",
";",
"}",
"// cli does process.exit() in callback, but unit tests don't.",
"callback",
"=",
"function",
"(",
")",
"{",
"}",
";",
"}"
] | scanfs error callback | [
"scanfs",
"error",
"callback"
] | cc6f90352534689a9e8c524c4cce825215bb5186 | https://github.com/YahooArchive/mojito-cli-jslint/blob/cc6f90352534689a9e8c524c4cce825215bb5186/lib/lintifier.js#L21-L31 |
55,975 | gropox/golos-addons | golos.js | getCurrentServerTimeAndBlock | async function getCurrentServerTimeAndBlock() {
await retrieveDynGlobProps();
if(props.time) {
lastCommitedBlock = props.last_irreversible_block_num;
trace("lastCommitedBlock = " + lastCommitedBlock + ", headBlock = " + props.head_block_number);
return {
time : Date.parse(props.time),
block : props.head_block_number,
commited_block : props.last_irreversible_block_num
};
}
throw "Current time could not be retrieved";
} | javascript | async function getCurrentServerTimeAndBlock() {
await retrieveDynGlobProps();
if(props.time) {
lastCommitedBlock = props.last_irreversible_block_num;
trace("lastCommitedBlock = " + lastCommitedBlock + ", headBlock = " + props.head_block_number);
return {
time : Date.parse(props.time),
block : props.head_block_number,
commited_block : props.last_irreversible_block_num
};
}
throw "Current time could not be retrieved";
} | [
"async",
"function",
"getCurrentServerTimeAndBlock",
"(",
")",
"{",
"await",
"retrieveDynGlobProps",
"(",
")",
";",
"if",
"(",
"props",
".",
"time",
")",
"{",
"lastCommitedBlock",
"=",
"props",
".",
"last_irreversible_block_num",
";",
"trace",
"(",
"\"lastCommitedBlock = \"",
"+",
"lastCommitedBlock",
"+",
"\", headBlock = \"",
"+",
"props",
".",
"head_block_number",
")",
";",
"return",
"{",
"time",
":",
"Date",
".",
"parse",
"(",
"props",
".",
"time",
")",
",",
"block",
":",
"props",
".",
"head_block_number",
",",
"commited_block",
":",
"props",
".",
"last_irreversible_block_num",
"}",
";",
"}",
"throw",
"\"Current time could not be retrieved\"",
";",
"}"
] | time in milliseconds | [
"time",
"in",
"milliseconds"
] | 14b132e7aa89d82db12cf2614faaddbec7e1cb9f | https://github.com/gropox/golos-addons/blob/14b132e7aa89d82db12cf2614faaddbec7e1cb9f/golos.js#L37-L49 |
55,976 | guileen/node-formconv | scheme.js | filter | function filter(obj) {
var result = {}, fieldDefine, value;
for(var field in options) {
fieldDefine = options[field];
value = obj[field];
if(!fieldDefine.private && value !== undefined) {
result[field] = value;
}
}
return result;
} | javascript | function filter(obj) {
var result = {}, fieldDefine, value;
for(var field in options) {
fieldDefine = options[field];
value = obj[field];
if(!fieldDefine.private && value !== undefined) {
result[field] = value;
}
}
return result;
} | [
"function",
"filter",
"(",
"obj",
")",
"{",
"var",
"result",
"=",
"{",
"}",
",",
"fieldDefine",
",",
"value",
";",
"for",
"(",
"var",
"field",
"in",
"options",
")",
"{",
"fieldDefine",
"=",
"options",
"[",
"field",
"]",
";",
"value",
"=",
"obj",
"[",
"field",
"]",
";",
"if",
"(",
"!",
"fieldDefine",
".",
"private",
"&&",
"value",
"!==",
"undefined",
")",
"{",
"result",
"[",
"field",
"]",
"=",
"value",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | filter private fields | [
"filter",
"private",
"fields"
] | b2eb725a4fd5643540c59c8ce27a78a8a8c91335 | https://github.com/guileen/node-formconv/blob/b2eb725a4fd5643540c59c8ce27a78a8a8c91335/scheme.js#L124-L134 |
55,977 | hpcloud/hpcloud-js | lib/objectstorage/container.js | Container | function Container(name, token, url) {
this._name = name;
this._url = url;
this._token = token;
this.isNew = false;
} | javascript | function Container(name, token, url) {
this._name = name;
this._url = url;
this._token = token;
this.isNew = false;
} | [
"function",
"Container",
"(",
"name",
",",
"token",
",",
"url",
")",
"{",
"this",
".",
"_name",
"=",
"name",
";",
"this",
".",
"_url",
"=",
"url",
";",
"this",
".",
"_token",
"=",
"token",
";",
"this",
".",
"isNew",
"=",
"false",
";",
"}"
] | Create a new container.
When a new container is created, no check is done against the server
to ensure that the container exists. Thus, it is possible to have a
local container object that does not point to a legitimate
server-side container.
@class Container
@constructor
@param {String} name The name of the container.
@param {String} token An authentication token.
@param {String} url The URL of the container. | [
"Create",
"a",
"new",
"container",
"."
] | c457ea3ee6a21e361d1af0af70d64622b6910208 | https://github.com/hpcloud/hpcloud-js/blob/c457ea3ee6a21e361d1af0af70d64622b6910208/lib/objectstorage/container.js#L58-L63 |
55,978 | ForbesLindesay-Unmaintained/sauce-test | lib/wait-for-job-to-finish.js | waitForJobToFinish | function waitForJobToFinish(driver, options) {
return new Promise(function (resolve, reject) {
var start = Date.now();
var timingOut = false;
function check() {
var checkedForExceptions;
if (options.allowExceptions) {
checkedForExceptions = Promise.resolve(null);
} else {
checkedForExceptions = driver.browser().activeWindow()
.execute('return window.ERROR_HAS_OCCURED;').then(function (errorHasOcucured) {
if (!errorHasOcucured) return;
return driver.browser().activeWindow()
.execute('return window.FIRST_ERROR;').then(function (err) {
var loc = location.getOriginalLocation(err.url, err.line);
var clientError = new Error(err.msg + ' (' + loc.source + ' line ' + loc.line + ')');
clientError.isClientError = true;
throw clientError;
}, function () {
throw new Error('Unknown error was thrown and not caught in the browser.');
});
}, function () {});
}
checkedForExceptions.then(function () {
return retry(function () {
if (typeof options.testComplete === 'string') {
return driver.browser().activeWindow().execute(options.testComplete);
} else {
return Promise.resolve(options.testComplete(driver));
}
}, 5, '500ms', {debug: options.debug});
}).done(function (complete) {
if (complete) resolve();
else {
if (timingOut) return reject(new Error('Test timed out'));
if (Date.now() - start > ms('' + (options.timeout || '20s'))) timingOut = true;
setTimeout(check, 500);
}
}, reject);
}
check();
});
} | javascript | function waitForJobToFinish(driver, options) {
return new Promise(function (resolve, reject) {
var start = Date.now();
var timingOut = false;
function check() {
var checkedForExceptions;
if (options.allowExceptions) {
checkedForExceptions = Promise.resolve(null);
} else {
checkedForExceptions = driver.browser().activeWindow()
.execute('return window.ERROR_HAS_OCCURED;').then(function (errorHasOcucured) {
if (!errorHasOcucured) return;
return driver.browser().activeWindow()
.execute('return window.FIRST_ERROR;').then(function (err) {
var loc = location.getOriginalLocation(err.url, err.line);
var clientError = new Error(err.msg + ' (' + loc.source + ' line ' + loc.line + ')');
clientError.isClientError = true;
throw clientError;
}, function () {
throw new Error('Unknown error was thrown and not caught in the browser.');
});
}, function () {});
}
checkedForExceptions.then(function () {
return retry(function () {
if (typeof options.testComplete === 'string') {
return driver.browser().activeWindow().execute(options.testComplete);
} else {
return Promise.resolve(options.testComplete(driver));
}
}, 5, '500ms', {debug: options.debug});
}).done(function (complete) {
if (complete) resolve();
else {
if (timingOut) return reject(new Error('Test timed out'));
if (Date.now() - start > ms('' + (options.timeout || '20s'))) timingOut = true;
setTimeout(check, 500);
}
}, reject);
}
check();
});
} | [
"function",
"waitForJobToFinish",
"(",
"driver",
",",
"options",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"var",
"start",
"=",
"Date",
".",
"now",
"(",
")",
";",
"var",
"timingOut",
"=",
"false",
";",
"function",
"check",
"(",
")",
"{",
"var",
"checkedForExceptions",
";",
"if",
"(",
"options",
".",
"allowExceptions",
")",
"{",
"checkedForExceptions",
"=",
"Promise",
".",
"resolve",
"(",
"null",
")",
";",
"}",
"else",
"{",
"checkedForExceptions",
"=",
"driver",
".",
"browser",
"(",
")",
".",
"activeWindow",
"(",
")",
".",
"execute",
"(",
"'return window.ERROR_HAS_OCCURED;'",
")",
".",
"then",
"(",
"function",
"(",
"errorHasOcucured",
")",
"{",
"if",
"(",
"!",
"errorHasOcucured",
")",
"return",
";",
"return",
"driver",
".",
"browser",
"(",
")",
".",
"activeWindow",
"(",
")",
".",
"execute",
"(",
"'return window.FIRST_ERROR;'",
")",
".",
"then",
"(",
"function",
"(",
"err",
")",
"{",
"var",
"loc",
"=",
"location",
".",
"getOriginalLocation",
"(",
"err",
".",
"url",
",",
"err",
".",
"line",
")",
";",
"var",
"clientError",
"=",
"new",
"Error",
"(",
"err",
".",
"msg",
"+",
"' ('",
"+",
"loc",
".",
"source",
"+",
"' line '",
"+",
"loc",
".",
"line",
"+",
"')'",
")",
";",
"clientError",
".",
"isClientError",
"=",
"true",
";",
"throw",
"clientError",
";",
"}",
",",
"function",
"(",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Unknown error was thrown and not caught in the browser.'",
")",
";",
"}",
")",
";",
"}",
",",
"function",
"(",
")",
"{",
"}",
")",
";",
"}",
"checkedForExceptions",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"retry",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"typeof",
"options",
".",
"testComplete",
"===",
"'string'",
")",
"{",
"return",
"driver",
".",
"browser",
"(",
")",
".",
"activeWindow",
"(",
")",
".",
"execute",
"(",
"options",
".",
"testComplete",
")",
";",
"}",
"else",
"{",
"return",
"Promise",
".",
"resolve",
"(",
"options",
".",
"testComplete",
"(",
"driver",
")",
")",
";",
"}",
"}",
",",
"5",
",",
"'500ms'",
",",
"{",
"debug",
":",
"options",
".",
"debug",
"}",
")",
";",
"}",
")",
".",
"done",
"(",
"function",
"(",
"complete",
")",
"{",
"if",
"(",
"complete",
")",
"resolve",
"(",
")",
";",
"else",
"{",
"if",
"(",
"timingOut",
")",
"return",
"reject",
"(",
"new",
"Error",
"(",
"'Test timed out'",
")",
")",
";",
"if",
"(",
"Date",
".",
"now",
"(",
")",
"-",
"start",
">",
"ms",
"(",
"''",
"+",
"(",
"options",
".",
"timeout",
"||",
"'20s'",
")",
")",
")",
"timingOut",
"=",
"true",
";",
"setTimeout",
"(",
"check",
",",
"500",
")",
";",
"}",
"}",
",",
"reject",
")",
";",
"}",
"check",
"(",
")",
";",
"}",
")",
";",
"}"
] | Wait for a driver that has a running job to finish its job
@option {Boolean} allowExceptions Set to `true` to skip the check for `window.onerror`
@option {String|Function} testComplete A function to test if the job is complete
@option {String} timeout The timeout (gets passed to ms)
@param {Cabbie} driver
@param {Options} options
@returns {Promise} | [
"Wait",
"for",
"a",
"driver",
"that",
"has",
"a",
"running",
"job",
"to",
"finish",
"its",
"job"
] | 7c671b3321dc63aefc00c1c8d49e943ead2e7f5e | https://github.com/ForbesLindesay-Unmaintained/sauce-test/blob/7c671b3321dc63aefc00c1c8d49e943ead2e7f5e/lib/wait-for-job-to-finish.js#L20-L62 |
55,979 | Tjatse/range | index.js | Range | function Range(){
if (!(this instanceof Range)) {
return new Range();
}
// maximize int.
var max = Math.pow(2, 32) - 1;
// default options.
this.options = {
min: -max,
max: max,
res: {
range : /^[\s\d\-~,]+$/,
blank : /\s+/g,
number : /^\-?\d+$/,
min2num: /^~\-?\d+$/,
num2max: /^\-?\d+~$/,
num2num: /^\-?\d+~\-?\d+$/
}
};
Object.freeze(this.options);
} | javascript | function Range(){
if (!(this instanceof Range)) {
return new Range();
}
// maximize int.
var max = Math.pow(2, 32) - 1;
// default options.
this.options = {
min: -max,
max: max,
res: {
range : /^[\s\d\-~,]+$/,
blank : /\s+/g,
number : /^\-?\d+$/,
min2num: /^~\-?\d+$/,
num2max: /^\-?\d+~$/,
num2num: /^\-?\d+~\-?\d+$/
}
};
Object.freeze(this.options);
} | [
"function",
"Range",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Range",
")",
")",
"{",
"return",
"new",
"Range",
"(",
")",
";",
"}",
"// maximize int.",
"var",
"max",
"=",
"Math",
".",
"pow",
"(",
"2",
",",
"32",
")",
"-",
"1",
";",
"// default options.",
"this",
".",
"options",
"=",
"{",
"min",
":",
"-",
"max",
",",
"max",
":",
"max",
",",
"res",
":",
"{",
"range",
":",
"/",
"^[\\s\\d\\-~,]+$",
"/",
",",
"blank",
":",
"/",
"\\s+",
"/",
"g",
",",
"number",
":",
"/",
"^\\-?\\d+$",
"/",
",",
"min2num",
":",
"/",
"^~\\-?\\d+$",
"/",
",",
"num2max",
":",
"/",
"^\\-?\\d+~$",
"/",
",",
"num2num",
":",
"/",
"^\\-?\\d+~\\-?\\d+$",
"/",
"}",
"}",
";",
"Object",
".",
"freeze",
"(",
"this",
".",
"options",
")",
";",
"}"
] | Range parser.
@returns {Range}
@constructor | [
"Range",
"parser",
"."
] | ad806642189ca7df22f8b0d16432a3ca68e071c7 | https://github.com/Tjatse/range/blob/ad806642189ca7df22f8b0d16432a3ca68e071c7/index.js#L11-L33 |
55,980 | Tjatse/range | index.js | function(s, opts){
var r = s.split('~').map(function(d){
return parseFloat(d);
});
// number at position 1 must greater than position 0.
if (r[0] > r[1]) {
return r.reverse();
}
return r;
} | javascript | function(s, opts){
var r = s.split('~').map(function(d){
return parseFloat(d);
});
// number at position 1 must greater than position 0.
if (r[0] > r[1]) {
return r.reverse();
}
return r;
} | [
"function",
"(",
"s",
",",
"opts",
")",
"{",
"var",
"r",
"=",
"s",
".",
"split",
"(",
"'~'",
")",
".",
"map",
"(",
"function",
"(",
"d",
")",
"{",
"return",
"parseFloat",
"(",
"d",
")",
";",
"}",
")",
";",
"// number at position 1 must greater than position 0.",
"if",
"(",
"r",
"[",
"0",
"]",
">",
"r",
"[",
"1",
"]",
")",
"{",
"return",
"r",
".",
"reverse",
"(",
")",
";",
"}",
"return",
"r",
";",
"}"
] | String like `1~2`, `5~8`, it means a range from a specific number to another.
@param {String} s
@param {Object} opts
@returns {*} | [
"String",
"like",
"1~2",
"5~8",
"it",
"means",
"a",
"range",
"from",
"a",
"specific",
"number",
"to",
"another",
"."
] | ad806642189ca7df22f8b0d16432a3ca68e071c7 | https://github.com/Tjatse/range/blob/ad806642189ca7df22f8b0d16432a3ca68e071c7/index.js#L146-L155 |
|
55,981 | jkroso/rename-variables | index.js | rename | function rename(node, it, to){
switch (node.type) {
case 'VariableDeclaration':
return node.declarations.forEach(function(dec){
if (dec.id.name == it) dec.id.name = to
if (dec.init) rename(dec.init, it, to)
})
case 'FunctionDeclaration':
if (node.id.name == it) node.id.name = to // falls through
case 'FunctionExpression':
var isIt = function(id){ return id.name == it }
return isIt(node.id)
|| node.params.some(isIt)
|| freshVars(node.body).some(isIt)
|| rename(node.body, it, to)
case 'CatchClause':
if (node.param.name == it) return
return rename(node.body, it, to)
case 'Identifier':
return node.name == it && (node.name = to)
}
children(node).forEach(function(child){
rename(child, it, to)
})
return node
} | javascript | function rename(node, it, to){
switch (node.type) {
case 'VariableDeclaration':
return node.declarations.forEach(function(dec){
if (dec.id.name == it) dec.id.name = to
if (dec.init) rename(dec.init, it, to)
})
case 'FunctionDeclaration':
if (node.id.name == it) node.id.name = to // falls through
case 'FunctionExpression':
var isIt = function(id){ return id.name == it }
return isIt(node.id)
|| node.params.some(isIt)
|| freshVars(node.body).some(isIt)
|| rename(node.body, it, to)
case 'CatchClause':
if (node.param.name == it) return
return rename(node.body, it, to)
case 'Identifier':
return node.name == it && (node.name = to)
}
children(node).forEach(function(child){
rename(child, it, to)
})
return node
} | [
"function",
"rename",
"(",
"node",
",",
"it",
",",
"to",
")",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"case",
"'VariableDeclaration'",
":",
"return",
"node",
".",
"declarations",
".",
"forEach",
"(",
"function",
"(",
"dec",
")",
"{",
"if",
"(",
"dec",
".",
"id",
".",
"name",
"==",
"it",
")",
"dec",
".",
"id",
".",
"name",
"=",
"to",
"if",
"(",
"dec",
".",
"init",
")",
"rename",
"(",
"dec",
".",
"init",
",",
"it",
",",
"to",
")",
"}",
")",
"case",
"'FunctionDeclaration'",
":",
"if",
"(",
"node",
".",
"id",
".",
"name",
"==",
"it",
")",
"node",
".",
"id",
".",
"name",
"=",
"to",
"// falls through",
"case",
"'FunctionExpression'",
":",
"var",
"isIt",
"=",
"function",
"(",
"id",
")",
"{",
"return",
"id",
".",
"name",
"==",
"it",
"}",
"return",
"isIt",
"(",
"node",
".",
"id",
")",
"||",
"node",
".",
"params",
".",
"some",
"(",
"isIt",
")",
"||",
"freshVars",
"(",
"node",
".",
"body",
")",
".",
"some",
"(",
"isIt",
")",
"||",
"rename",
"(",
"node",
".",
"body",
",",
"it",
",",
"to",
")",
"case",
"'CatchClause'",
":",
"if",
"(",
"node",
".",
"param",
".",
"name",
"==",
"it",
")",
"return",
"return",
"rename",
"(",
"node",
".",
"body",
",",
"it",
",",
"to",
")",
"case",
"'Identifier'",
":",
"return",
"node",
".",
"name",
"==",
"it",
"&&",
"(",
"node",
".",
"name",
"=",
"to",
")",
"}",
"children",
"(",
"node",
")",
".",
"forEach",
"(",
"function",
"(",
"child",
")",
"{",
"rename",
"(",
"child",
",",
"it",
",",
"to",
")",
"}",
")",
"return",
"node",
"}"
] | rename all references to `it` in or below `nodes`'s
scope to `to`
@param {AST} node
@param {String} it
@param {String} to | [
"rename",
"all",
"references",
"to",
"it",
"in",
"or",
"below",
"nodes",
"s",
"scope",
"to",
"to"
] | b1ade439b857367f27f7b85bd1b024a6b01bc4be | https://github.com/jkroso/rename-variables/blob/b1ade439b857367f27f7b85bd1b024a6b01bc4be/index.js#L14-L39 |
55,982 | jkroso/rename-variables | index.js | freshVars | function freshVars(node){
switch (node.type) {
case 'VariableDeclaration':
return node.declarations.map(function(n){ return n.id })
case 'FunctionExpression': return [] // early exit
case 'FunctionDeclaration':
return [node.id]
}
return children(node)
.map(freshVars)
.reduce(concat, [])
} | javascript | function freshVars(node){
switch (node.type) {
case 'VariableDeclaration':
return node.declarations.map(function(n){ return n.id })
case 'FunctionExpression': return [] // early exit
case 'FunctionDeclaration':
return [node.id]
}
return children(node)
.map(freshVars)
.reduce(concat, [])
} | [
"function",
"freshVars",
"(",
"node",
")",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"case",
"'VariableDeclaration'",
":",
"return",
"node",
".",
"declarations",
".",
"map",
"(",
"function",
"(",
"n",
")",
"{",
"return",
"n",
".",
"id",
"}",
")",
"case",
"'FunctionExpression'",
":",
"return",
"[",
"]",
"// early exit",
"case",
"'FunctionDeclaration'",
":",
"return",
"[",
"node",
".",
"id",
"]",
"}",
"return",
"children",
"(",
"node",
")",
".",
"map",
"(",
"freshVars",
")",
".",
"reduce",
"(",
"concat",
",",
"[",
"]",
")",
"}"
] | get all declared variables within `node`'s scope
@param {AST} node
@return {Array} | [
"get",
"all",
"declared",
"variables",
"within",
"node",
"s",
"scope"
] | b1ade439b857367f27f7b85bd1b024a6b01bc4be | https://github.com/jkroso/rename-variables/blob/b1ade439b857367f27f7b85bd1b024a6b01bc4be/index.js#L48-L59 |
55,983 | kfranqueiro/node-irssi-log-parser | Parser.js | function (filename) {
var resume = filename === true; // should only ever be set by resume calls
var fd = this._fd = resume ? this._fd : fs.openSync(filename, 'r');
var buffer = new Buffer(4096);
var bytesRead;
var current = '';
var remainder = resume ? this._remainder : '';
while (!this._paused && (bytesRead = fs.readSync(fd, buffer, 0, buffer.length))) {
current = buffer.toString('utf-8');
if (current.length > bytesRead) {
current = current.slice(0, bytesRead);
}
remainder = this._remainder = this._parseLines(remainder + current);
}
// The loop will end either when EOF is reached, or pause was called.
// In the former case, close the file; in the latter case, leave it
// open with the expectation that we'll pick up where we left off.
if (!this._paused) {
fs.closeSync(fd);
}
} | javascript | function (filename) {
var resume = filename === true; // should only ever be set by resume calls
var fd = this._fd = resume ? this._fd : fs.openSync(filename, 'r');
var buffer = new Buffer(4096);
var bytesRead;
var current = '';
var remainder = resume ? this._remainder : '';
while (!this._paused && (bytesRead = fs.readSync(fd, buffer, 0, buffer.length))) {
current = buffer.toString('utf-8');
if (current.length > bytesRead) {
current = current.slice(0, bytesRead);
}
remainder = this._remainder = this._parseLines(remainder + current);
}
// The loop will end either when EOF is reached, or pause was called.
// In the former case, close the file; in the latter case, leave it
// open with the expectation that we'll pick up where we left off.
if (!this._paused) {
fs.closeSync(fd);
}
} | [
"function",
"(",
"filename",
")",
"{",
"var",
"resume",
"=",
"filename",
"===",
"true",
";",
"// should only ever be set by resume calls",
"var",
"fd",
"=",
"this",
".",
"_fd",
"=",
"resume",
"?",
"this",
".",
"_fd",
":",
"fs",
".",
"openSync",
"(",
"filename",
",",
"'r'",
")",
";",
"var",
"buffer",
"=",
"new",
"Buffer",
"(",
"4096",
")",
";",
"var",
"bytesRead",
";",
"var",
"current",
"=",
"''",
";",
"var",
"remainder",
"=",
"resume",
"?",
"this",
".",
"_remainder",
":",
"''",
";",
"while",
"(",
"!",
"this",
".",
"_paused",
"&&",
"(",
"bytesRead",
"=",
"fs",
".",
"readSync",
"(",
"fd",
",",
"buffer",
",",
"0",
",",
"buffer",
".",
"length",
")",
")",
")",
"{",
"current",
"=",
"buffer",
".",
"toString",
"(",
"'utf-8'",
")",
";",
"if",
"(",
"current",
".",
"length",
">",
"bytesRead",
")",
"{",
"current",
"=",
"current",
".",
"slice",
"(",
"0",
",",
"bytesRead",
")",
";",
"}",
"remainder",
"=",
"this",
".",
"_remainder",
"=",
"this",
".",
"_parseLines",
"(",
"remainder",
"+",
"current",
")",
";",
"}",
"// The loop will end either when EOF is reached, or pause was called.",
"// In the former case, close the file; in the latter case, leave it",
"// open with the expectation that we'll pick up where we left off.",
"if",
"(",
"!",
"this",
".",
"_paused",
")",
"{",
"fs",
".",
"closeSync",
"(",
"fd",
")",
";",
"}",
"}"
] | Parses the given log file.
@param {string} filename File to parse | [
"Parses",
"the",
"given",
"log",
"file",
"."
] | 7088868462a636b2473b2b0efdb3c1002c26b43c | https://github.com/kfranqueiro/node-irssi-log-parser/blob/7088868462a636b2473b2b0efdb3c1002c26b43c/Parser.js#L301-L323 |
|
55,984 | llucbrell/audrey2 | index.js | init | function init(){
//modules load
terminal.colors.default= chalk.white.bold;
terminal.default="";
//set the colors of the terminal
checkUserColors(terminal.colors);
bool=true;
//to control the view properties and colors
properties= Object.getOwnPropertyNames(terminal);
colors=Object.getOwnPropertyNames(terminal.colors);
} | javascript | function init(){
//modules load
terminal.colors.default= chalk.white.bold;
terminal.default="";
//set the colors of the terminal
checkUserColors(terminal.colors);
bool=true;
//to control the view properties and colors
properties= Object.getOwnPropertyNames(terminal);
colors=Object.getOwnPropertyNames(terminal.colors);
} | [
"function",
"init",
"(",
")",
"{",
"//modules load",
"terminal",
".",
"colors",
".",
"default",
"=",
"chalk",
".",
"white",
".",
"bold",
";",
"terminal",
".",
"default",
"=",
"\"\"",
";",
"//set the colors of the terminal",
"checkUserColors",
"(",
"terminal",
".",
"colors",
")",
";",
"bool",
"=",
"true",
";",
"//to control the view properties and colors",
"properties",
"=",
"Object",
".",
"getOwnPropertyNames",
"(",
"terminal",
")",
";",
"colors",
"=",
"Object",
".",
"getOwnPropertyNames",
"(",
"terminal",
".",
"colors",
")",
";",
"}"
] | to reinit the audrey view when is updated | [
"to",
"reinit",
"the",
"audrey",
"view",
"when",
"is",
"updated"
] | eb683b25a6b1b05a9f832e85707fb7274542a1e5 | https://github.com/llucbrell/audrey2/blob/eb683b25a6b1b05a9f832e85707fb7274542a1e5/index.js#L154-L164 |
55,985 | llucbrell/audrey2 | index.js | fertilise | function fertilise(objectName, value, color, blockPos){
if(!blockPos) throw new Error("incorrect call to fertilise method");
var name= objectName.slice(2);
terminal[name]=value;
terminal.colors[name]=color;
setOnBlock(objectName, blockPos);
checkUserColors(terminal.colors);
init();
} | javascript | function fertilise(objectName, value, color, blockPos){
if(!blockPos) throw new Error("incorrect call to fertilise method");
var name= objectName.slice(2);
terminal[name]=value;
terminal.colors[name]=color;
setOnBlock(objectName, blockPos);
checkUserColors(terminal.colors);
init();
} | [
"function",
"fertilise",
"(",
"objectName",
",",
"value",
",",
"color",
",",
"blockPos",
")",
"{",
"if",
"(",
"!",
"blockPos",
")",
"throw",
"new",
"Error",
"(",
"\"incorrect call to fertilise method\"",
")",
";",
"var",
"name",
"=",
"objectName",
".",
"slice",
"(",
"2",
")",
";",
"terminal",
"[",
"name",
"]",
"=",
"value",
";",
"terminal",
".",
"colors",
"[",
"name",
"]",
"=",
"color",
";",
"setOnBlock",
"(",
"objectName",
",",
"blockPos",
")",
";",
"checkUserColors",
"(",
"terminal",
".",
"colors",
")",
";",
"init",
"(",
")",
";",
"}"
] | by name, value,color block | [
"by",
"name",
"value",
"color",
"block"
] | eb683b25a6b1b05a9f832e85707fb7274542a1e5 | https://github.com/llucbrell/audrey2/blob/eb683b25a6b1b05a9f832e85707fb7274542a1e5/index.js#L203-L211 |
55,986 | llucbrell/audrey2 | index.js | checkUserColors | function checkUserColors(colorUser){
if(terminal.colors){
for(var name in colorUser){
colorUser[name]= setUserColor(colorUser[name]);
}
}
else{
throw new Error("There is no colors object defined");
}
} | javascript | function checkUserColors(colorUser){
if(terminal.colors){
for(var name in colorUser){
colorUser[name]= setUserColor(colorUser[name]);
}
}
else{
throw new Error("There is no colors object defined");
}
} | [
"function",
"checkUserColors",
"(",
"colorUser",
")",
"{",
"if",
"(",
"terminal",
".",
"colors",
")",
"{",
"for",
"(",
"var",
"name",
"in",
"colorUser",
")",
"{",
"colorUser",
"[",
"name",
"]",
"=",
"setUserColor",
"(",
"colorUser",
"[",
"name",
"]",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"\"There is no colors object defined\"",
")",
";",
"}",
"}"
] | FUNCTIONS FOR THE CLI RESPONSE.. check if there is defined object colors if not, throw error | [
"FUNCTIONS",
"FOR",
"THE",
"CLI",
"RESPONSE",
"..",
"check",
"if",
"there",
"is",
"defined",
"object",
"colors",
"if",
"not",
"throw",
"error"
] | eb683b25a6b1b05a9f832e85707fb7274542a1e5 | https://github.com/llucbrell/audrey2/blob/eb683b25a6b1b05a9f832e85707fb7274542a1e5/index.js#L215-L224 |
55,987 | llucbrell/audrey2 | index.js | setOnBlock | function setOnBlock(objectName, blockPos){
switch(blockPos){//check where to add in the structure
case 'header':
terminal.header.push(objectName);
break;
case 'body':
terminal.body.push(objectName);
break;
case 'footer':
terminal.footer.push(objectName);
break;
}
} | javascript | function setOnBlock(objectName, blockPos){
switch(blockPos){//check where to add in the structure
case 'header':
terminal.header.push(objectName);
break;
case 'body':
terminal.body.push(objectName);
break;
case 'footer':
terminal.footer.push(objectName);
break;
}
} | [
"function",
"setOnBlock",
"(",
"objectName",
",",
"blockPos",
")",
"{",
"switch",
"(",
"blockPos",
")",
"{",
"//check where to add in the structure",
"case",
"'header'",
":",
"terminal",
".",
"header",
".",
"push",
"(",
"objectName",
")",
";",
"break",
";",
"case",
"'body'",
":",
"terminal",
".",
"body",
".",
"push",
"(",
"objectName",
")",
";",
"break",
";",
"case",
"'footer'",
":",
"terminal",
".",
"footer",
".",
"push",
"(",
"objectName",
")",
";",
"break",
";",
"}",
"}"
] | adds new object to list of print | [
"adds",
"new",
"object",
"to",
"list",
"of",
"print"
] | eb683b25a6b1b05a9f832e85707fb7274542a1e5 | https://github.com/llucbrell/audrey2/blob/eb683b25a6b1b05a9f832e85707fb7274542a1e5/index.js#L226-L238 |
55,988 | llucbrell/audrey2 | index.js | checkColors | function checkColors(name){
var colors=Object.getOwnPropertyNames(terminal.colors);
var bul=false; // boolean to control if its defined the property
for(var i=0; i<colors.length; i++){//iterate over prop names
if(colors[i] === name){//if it is
bul=true;
}
}
if(bul!==true){//if its finded the statement of the tag
terminal.colors[name]=terminal.colors.default;
}
} | javascript | function checkColors(name){
var colors=Object.getOwnPropertyNames(terminal.colors);
var bul=false; // boolean to control if its defined the property
for(var i=0; i<colors.length; i++){//iterate over prop names
if(colors[i] === name){//if it is
bul=true;
}
}
if(bul!==true){//if its finded the statement of the tag
terminal.colors[name]=terminal.colors.default;
}
} | [
"function",
"checkColors",
"(",
"name",
")",
"{",
"var",
"colors",
"=",
"Object",
".",
"getOwnPropertyNames",
"(",
"terminal",
".",
"colors",
")",
";",
"var",
"bul",
"=",
"false",
";",
"// boolean to control if its defined the property",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"colors",
".",
"length",
";",
"i",
"++",
")",
"{",
"//iterate over prop names",
"if",
"(",
"colors",
"[",
"i",
"]",
"===",
"name",
")",
"{",
"//if it is",
"bul",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"bul",
"!==",
"true",
")",
"{",
"//if its finded the statement of the tag",
"terminal",
".",
"colors",
"[",
"name",
"]",
"=",
"terminal",
".",
"colors",
".",
"default",
";",
"}",
"}"
] | checks the colors in printBrand | [
"checks",
"the",
"colors",
"in",
"printBrand"
] | eb683b25a6b1b05a9f832e85707fb7274542a1e5 | https://github.com/llucbrell/audrey2/blob/eb683b25a6b1b05a9f832e85707fb7274542a1e5/index.js#L269-L282 |
55,989 | llucbrell/audrey2 | index.js | checkProperties | function checkProperties(name){
var bul=false; // boolean to control if its defined the property
for(var i=0; i<properties.length; i++){//iterate over prop names
if(properties[i] === name){//if it is
bul=true;
}
}
if(bul!==true){// it isn't finded the statement of the tag
throw new Error('Not defined '+name);
}
} | javascript | function checkProperties(name){
var bul=false; // boolean to control if its defined the property
for(var i=0; i<properties.length; i++){//iterate over prop names
if(properties[i] === name){//if it is
bul=true;
}
}
if(bul!==true){// it isn't finded the statement of the tag
throw new Error('Not defined '+name);
}
} | [
"function",
"checkProperties",
"(",
"name",
")",
"{",
"var",
"bul",
"=",
"false",
";",
"// boolean to control if its defined the property",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"properties",
".",
"length",
";",
"i",
"++",
")",
"{",
"//iterate over prop names",
"if",
"(",
"properties",
"[",
"i",
"]",
"===",
"name",
")",
"{",
"//if it is",
"bul",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"bul",
"!==",
"true",
")",
"{",
"// it isn't finded the statement of the tag",
"throw",
"new",
"Error",
"(",
"'Not defined '",
"+",
"name",
")",
";",
"}",
"}"
] | control if the view has the correct properties if not throw error | [
"control",
"if",
"the",
"view",
"has",
"the",
"correct",
"properties",
"if",
"not",
"throw",
"error"
] | eb683b25a6b1b05a9f832e85707fb7274542a1e5 | https://github.com/llucbrell/audrey2/blob/eb683b25a6b1b05a9f832e85707fb7274542a1e5/index.js#L470-L481 |
55,990 | llucbrell/audrey2 | index.js | aError | function aError(errorObject){
if(!terminal.symbolProgress) terminal.symbolProgress="? ";
if(errorObject.aux){
if(!terminal.colors.aux) terminal.colors.aux= chalk.white;
console.log(terminal.colors.error(terminal.symbolProgress+" Error: "+errorObject.message)+ " " +terminal.colors.aux(errorObject.aux));
console.log();
}
else{
console.log(terminal.colors.error(terminal.symbolProgress+" Error: "+errorObject.message));
console.log();
}
} | javascript | function aError(errorObject){
if(!terminal.symbolProgress) terminal.symbolProgress="? ";
if(errorObject.aux){
if(!terminal.colors.aux) terminal.colors.aux= chalk.white;
console.log(terminal.colors.error(terminal.symbolProgress+" Error: "+errorObject.message)+ " " +terminal.colors.aux(errorObject.aux));
console.log();
}
else{
console.log(terminal.colors.error(terminal.symbolProgress+" Error: "+errorObject.message));
console.log();
}
} | [
"function",
"aError",
"(",
"errorObject",
")",
"{",
"if",
"(",
"!",
"terminal",
".",
"symbolProgress",
")",
"terminal",
".",
"symbolProgress",
"=",
"\"? \"",
";",
"if",
"(",
"errorObject",
".",
"aux",
")",
"{",
"if",
"(",
"!",
"terminal",
".",
"colors",
".",
"aux",
")",
"terminal",
".",
"colors",
".",
"aux",
"=",
"chalk",
".",
"white",
";",
"console",
".",
"log",
"(",
"terminal",
".",
"colors",
".",
"error",
"(",
"terminal",
".",
"symbolProgress",
"+",
"\" Error: \"",
"+",
"errorObject",
".",
"message",
")",
"+",
"\" \"",
"+",
"terminal",
".",
"colors",
".",
"aux",
"(",
"errorObject",
".",
"aux",
")",
")",
";",
"console",
".",
"log",
"(",
")",
";",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"terminal",
".",
"colors",
".",
"error",
"(",
"terminal",
".",
"symbolProgress",
"+",
"\" Error: \"",
"+",
"errorObject",
".",
"message",
")",
")",
";",
"console",
".",
"log",
"(",
")",
";",
"}",
"}"
] | FUNCTIONS FOR PRINTING ON SCREEN print error message for debug | [
"FUNCTIONS",
"FOR",
"PRINTING",
"ON",
"SCREEN",
"print",
"error",
"message",
"for",
"debug"
] | eb683b25a6b1b05a9f832e85707fb7274542a1e5 | https://github.com/llucbrell/audrey2/blob/eb683b25a6b1b05a9f832e85707fb7274542a1e5/index.js#L486-L497 |
55,991 | llucbrell/audrey2 | index.js | aSuccess | function aSuccess(errorObject){
if(!terminal.symbolProgress) terminal.symbolProgress="? ";
if(errorObject.aux){
if(!terminal.colors.aux) terminal.colors.aux= chalk.white;
console.log(terminal.colors.success(terminal.symbolProgress+" Success: "+errorObject.message) +" " +terminal.colors.aux(errorObject.aux));
console.log();
}
else{
console.log(terminal.colors.success(terminal.symbolProgress+" Success: "+errorObject.message));
console.log();
}
} | javascript | function aSuccess(errorObject){
if(!terminal.symbolProgress) terminal.symbolProgress="? ";
if(errorObject.aux){
if(!terminal.colors.aux) terminal.colors.aux= chalk.white;
console.log(terminal.colors.success(terminal.symbolProgress+" Success: "+errorObject.message) +" " +terminal.colors.aux(errorObject.aux));
console.log();
}
else{
console.log(terminal.colors.success(terminal.symbolProgress+" Success: "+errorObject.message));
console.log();
}
} | [
"function",
"aSuccess",
"(",
"errorObject",
")",
"{",
"if",
"(",
"!",
"terminal",
".",
"symbolProgress",
")",
"terminal",
".",
"symbolProgress",
"=",
"\"? \"",
";",
"if",
"(",
"errorObject",
".",
"aux",
")",
"{",
"if",
"(",
"!",
"terminal",
".",
"colors",
".",
"aux",
")",
"terminal",
".",
"colors",
".",
"aux",
"=",
"chalk",
".",
"white",
";",
"console",
".",
"log",
"(",
"terminal",
".",
"colors",
".",
"success",
"(",
"terminal",
".",
"symbolProgress",
"+",
"\" Success: \"",
"+",
"errorObject",
".",
"message",
")",
"+",
"\" \"",
"+",
"terminal",
".",
"colors",
".",
"aux",
"(",
"errorObject",
".",
"aux",
")",
")",
";",
"console",
".",
"log",
"(",
")",
";",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"terminal",
".",
"colors",
".",
"success",
"(",
"terminal",
".",
"symbolProgress",
"+",
"\" Success: \"",
"+",
"errorObject",
".",
"message",
")",
")",
";",
"console",
".",
"log",
"(",
")",
";",
"}",
"}"
] | print success error for debug | [
"print",
"success",
"error",
"for",
"debug"
] | eb683b25a6b1b05a9f832e85707fb7274542a1e5 | https://github.com/llucbrell/audrey2/blob/eb683b25a6b1b05a9f832e85707fb7274542a1e5/index.js#L499-L510 |
55,992 | llucbrell/audrey2 | index.js | aWarning | function aWarning(errorObject){
if(!terminal.symbolProgress) terminal.symbolProgress="? ";
if(errorObject.aux){
if(!terminal.colors.aux) terminal.colors.aux= chalk.white;
console.log(terminal.colors.warning(terminal.symbolProgress+" Warning: "+errorObject.message)+" " +terminal.colors.aux(errorObject.aux));
console.log();
}
else{
console.log(terminal.colors.warning(terminal.symbolProgress+" Warning: "+errorObject.message));
console.log();
}
} | javascript | function aWarning(errorObject){
if(!terminal.symbolProgress) terminal.symbolProgress="? ";
if(errorObject.aux){
if(!terminal.colors.aux) terminal.colors.aux= chalk.white;
console.log(terminal.colors.warning(terminal.symbolProgress+" Warning: "+errorObject.message)+" " +terminal.colors.aux(errorObject.aux));
console.log();
}
else{
console.log(terminal.colors.warning(terminal.symbolProgress+" Warning: "+errorObject.message));
console.log();
}
} | [
"function",
"aWarning",
"(",
"errorObject",
")",
"{",
"if",
"(",
"!",
"terminal",
".",
"symbolProgress",
")",
"terminal",
".",
"symbolProgress",
"=",
"\"? \"",
";",
"if",
"(",
"errorObject",
".",
"aux",
")",
"{",
"if",
"(",
"!",
"terminal",
".",
"colors",
".",
"aux",
")",
"terminal",
".",
"colors",
".",
"aux",
"=",
"chalk",
".",
"white",
";",
"console",
".",
"log",
"(",
"terminal",
".",
"colors",
".",
"warning",
"(",
"terminal",
".",
"symbolProgress",
"+",
"\" Warning: \"",
"+",
"errorObject",
".",
"message",
")",
"+",
"\" \"",
"+",
"terminal",
".",
"colors",
".",
"aux",
"(",
"errorObject",
".",
"aux",
")",
")",
";",
"console",
".",
"log",
"(",
")",
";",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"terminal",
".",
"colors",
".",
"warning",
"(",
"terminal",
".",
"symbolProgress",
"+",
"\" Warning: \"",
"+",
"errorObject",
".",
"message",
")",
")",
";",
"console",
".",
"log",
"(",
")",
";",
"}",
"}"
] | print warning error for debug | [
"print",
"warning",
"error",
"for",
"debug"
] | eb683b25a6b1b05a9f832e85707fb7274542a1e5 | https://github.com/llucbrell/audrey2/blob/eb683b25a6b1b05a9f832e85707fb7274542a1e5/index.js#L512-L523 |
55,993 | transomjs/transom-scaffold | lib/scaffoldHandler.js | addStaticAssetRoute | function addStaticAssetRoute(server, scaffold) {
assert(scaffold.path, `TransomScaffold staticRoute requires "path" to be specified.`);
const contentFolder = scaffold.folder || path.sep;
const serveStatic = scaffold.serveStatic || restify.plugins.serveStatic;
const defaultAsset = scaffold.defaultAsset || 'index.html';
const appendRequestPath = (scaffold.appendRequestPath === false ? false : true); // default true
// When we are running tests, the path to our assets will be different.
// We create the path using NODE_ENV which should be set to TESTING.
let directory = path.join(__dirname, '..', '..', '..', '..', contentFolder);
if ((process.env.NODE_ENV || '').toUpperCase() === 'TESTING') {
directory = path.join(__dirname, "..", contentFolder);
}
debug(`Path ${scaffold.path} is serving static assets from ${directory}`);
server.get(scaffold.path, serveStatic({
directory,
appendRequestPath,
default: defaultAsset
}));
} | javascript | function addStaticAssetRoute(server, scaffold) {
assert(scaffold.path, `TransomScaffold staticRoute requires "path" to be specified.`);
const contentFolder = scaffold.folder || path.sep;
const serveStatic = scaffold.serveStatic || restify.plugins.serveStatic;
const defaultAsset = scaffold.defaultAsset || 'index.html';
const appendRequestPath = (scaffold.appendRequestPath === false ? false : true); // default true
// When we are running tests, the path to our assets will be different.
// We create the path using NODE_ENV which should be set to TESTING.
let directory = path.join(__dirname, '..', '..', '..', '..', contentFolder);
if ((process.env.NODE_ENV || '').toUpperCase() === 'TESTING') {
directory = path.join(__dirname, "..", contentFolder);
}
debug(`Path ${scaffold.path} is serving static assets from ${directory}`);
server.get(scaffold.path, serveStatic({
directory,
appendRequestPath,
default: defaultAsset
}));
} | [
"function",
"addStaticAssetRoute",
"(",
"server",
",",
"scaffold",
")",
"{",
"assert",
"(",
"scaffold",
".",
"path",
",",
"`",
"`",
")",
";",
"const",
"contentFolder",
"=",
"scaffold",
".",
"folder",
"||",
"path",
".",
"sep",
";",
"const",
"serveStatic",
"=",
"scaffold",
".",
"serveStatic",
"||",
"restify",
".",
"plugins",
".",
"serveStatic",
";",
"const",
"defaultAsset",
"=",
"scaffold",
".",
"defaultAsset",
"||",
"'index.html'",
";",
"const",
"appendRequestPath",
"=",
"(",
"scaffold",
".",
"appendRequestPath",
"===",
"false",
"?",
"false",
":",
"true",
")",
";",
"// default true",
"// When we are running tests, the path to our assets will be different. ",
"// We create the path using NODE_ENV which should be set to TESTING.",
"let",
"directory",
"=",
"path",
".",
"join",
"(",
"__dirname",
",",
"'..'",
",",
"'..'",
",",
"'..'",
",",
"'..'",
",",
"contentFolder",
")",
";",
"if",
"(",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
"||",
"''",
")",
".",
"toUpperCase",
"(",
")",
"===",
"'TESTING'",
")",
"{",
"directory",
"=",
"path",
".",
"join",
"(",
"__dirname",
",",
"\"..\"",
",",
"contentFolder",
")",
";",
"}",
"debug",
"(",
"`",
"${",
"scaffold",
".",
"path",
"}",
"${",
"directory",
"}",
"`",
")",
";",
"server",
".",
"get",
"(",
"scaffold",
".",
"path",
",",
"serveStatic",
"(",
"{",
"directory",
",",
"appendRequestPath",
",",
"default",
":",
"defaultAsset",
"}",
")",
")",
";",
"}"
] | Add a GET route to the server to handle static assets.
@param {*} server - Restify server instance
@param {*} scaffold - Object from the staticRoutes array. | [
"Add",
"a",
"GET",
"route",
"to",
"the",
"server",
"to",
"handle",
"static",
"assets",
"."
] | 07550492282f972438b9af4d52c0befa4ba3b454 | https://github.com/transomjs/transom-scaffold/blob/07550492282f972438b9af4d52c0befa4ba3b454/lib/scaffoldHandler.js#L15-L36 |
55,994 | transomjs/transom-scaffold | lib/scaffoldHandler.js | addRedirectRoute | function addRedirectRoute(server, scaffold) {
assert(scaffold.path && scaffold.target, `TransomScaffold redirectRoute requires 'path' and 'target' to be specified.`);
server.get(scaffold.path, function (req, res, next) {
res.redirect(scaffold.target, next);
});
} | javascript | function addRedirectRoute(server, scaffold) {
assert(scaffold.path && scaffold.target, `TransomScaffold redirectRoute requires 'path' and 'target' to be specified.`);
server.get(scaffold.path, function (req, res, next) {
res.redirect(scaffold.target, next);
});
} | [
"function",
"addRedirectRoute",
"(",
"server",
",",
"scaffold",
")",
"{",
"assert",
"(",
"scaffold",
".",
"path",
"&&",
"scaffold",
".",
"target",
",",
"`",
"`",
")",
";",
"server",
".",
"get",
"(",
"scaffold",
".",
"path",
",",
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"res",
".",
"redirect",
"(",
"scaffold",
".",
"target",
",",
"next",
")",
";",
"}",
")",
";",
"}"
] | Add a GET route that redirects to another URI.
@param {*} server - Restify server instance
@param {*} scaffold - Object from the redirectRoutes array. | [
"Add",
"a",
"GET",
"route",
"that",
"redirects",
"to",
"another",
"URI",
"."
] | 07550492282f972438b9af4d52c0befa4ba3b454 | https://github.com/transomjs/transom-scaffold/blob/07550492282f972438b9af4d52c0befa4ba3b454/lib/scaffoldHandler.js#L44-L50 |
55,995 | transomjs/transom-scaffold | lib/scaffoldHandler.js | addTemplateRoute | function addTemplateRoute(server, scaffold) {
server.get(scaffold.path, function (req, res, next) {
const transomTemplate = server.registry.get(scaffold.templateHandler);
const contentType = scaffold.contentType || 'text/html';
const p = new Promise(function (resolve, reject) {
// Push request headers and params into the data going to the template.
const data = scaffold.data || {};
data.headers = req.headers;
data.params = req.params;
resolve(transomTemplate.renderHtmlTemplate(scaffold.templateName, data));
}).then(function (pageData) {
res.setHeader('content-type', contentType);
res.end(pageData);
next(false); // false stops the chain.
}).catch(function (err) {
next(err);
});
});
} | javascript | function addTemplateRoute(server, scaffold) {
server.get(scaffold.path, function (req, res, next) {
const transomTemplate = server.registry.get(scaffold.templateHandler);
const contentType = scaffold.contentType || 'text/html';
const p = new Promise(function (resolve, reject) {
// Push request headers and params into the data going to the template.
const data = scaffold.data || {};
data.headers = req.headers;
data.params = req.params;
resolve(transomTemplate.renderHtmlTemplate(scaffold.templateName, data));
}).then(function (pageData) {
res.setHeader('content-type', contentType);
res.end(pageData);
next(false); // false stops the chain.
}).catch(function (err) {
next(err);
});
});
} | [
"function",
"addTemplateRoute",
"(",
"server",
",",
"scaffold",
")",
"{",
"server",
".",
"get",
"(",
"scaffold",
".",
"path",
",",
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"const",
"transomTemplate",
"=",
"server",
".",
"registry",
".",
"get",
"(",
"scaffold",
".",
"templateHandler",
")",
";",
"const",
"contentType",
"=",
"scaffold",
".",
"contentType",
"||",
"'text/html'",
";",
"const",
"p",
"=",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"// Push request headers and params into the data going to the template.",
"const",
"data",
"=",
"scaffold",
".",
"data",
"||",
"{",
"}",
";",
"data",
".",
"headers",
"=",
"req",
".",
"headers",
";",
"data",
".",
"params",
"=",
"req",
".",
"params",
";",
"resolve",
"(",
"transomTemplate",
".",
"renderHtmlTemplate",
"(",
"scaffold",
".",
"templateName",
",",
"data",
")",
")",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
"pageData",
")",
"{",
"res",
".",
"setHeader",
"(",
"'content-type'",
",",
"contentType",
")",
";",
"res",
".",
"end",
"(",
"pageData",
")",
";",
"next",
"(",
"false",
")",
";",
"// false stops the chain.",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"err",
")",
"{",
"next",
"(",
"err",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Add a GET route that is handled with a template.
@param {*} server - Restify server instance
@param {*} scaffold | [
"Add",
"a",
"GET",
"route",
"that",
"is",
"handled",
"with",
"a",
"template",
"."
] | 07550492282f972438b9af4d52c0befa4ba3b454 | https://github.com/transomjs/transom-scaffold/blob/07550492282f972438b9af4d52c0befa4ba3b454/lib/scaffoldHandler.js#L58-L78 |
55,996 | joelahoover/nomv | index.js | resolveNodeSkel | function resolveNodeSkel(index, nodeName) {
var idx = +graph.nameToIndex[nodeName];
argh = [idx, +index]
if(Number.isNaN(idx)) {
throw "Unable to get index for node '" + nodeName + "'. (Is the node name misspelled?)";
}
if(index !== undefined && idx > +index) {
throw "Unable to get index for node '" + nodeName + "'. (Are the nodes out of order?)";
}
if(index !== undefined && idx == +index) {
throw "Unable to get index for node '" + nodeName + "'. (Is the node trying to reference itself?)";
}
return (dataContext) => dataContext.values[idx];
} | javascript | function resolveNodeSkel(index, nodeName) {
var idx = +graph.nameToIndex[nodeName];
argh = [idx, +index]
if(Number.isNaN(idx)) {
throw "Unable to get index for node '" + nodeName + "'. (Is the node name misspelled?)";
}
if(index !== undefined && idx > +index) {
throw "Unable to get index for node '" + nodeName + "'. (Are the nodes out of order?)";
}
if(index !== undefined && idx == +index) {
throw "Unable to get index for node '" + nodeName + "'. (Is the node trying to reference itself?)";
}
return (dataContext) => dataContext.values[idx];
} | [
"function",
"resolveNodeSkel",
"(",
"index",
",",
"nodeName",
")",
"{",
"var",
"idx",
"=",
"+",
"graph",
".",
"nameToIndex",
"[",
"nodeName",
"]",
";",
"argh",
"=",
"[",
"idx",
",",
"+",
"index",
"]",
"if",
"(",
"Number",
".",
"isNaN",
"(",
"idx",
")",
")",
"{",
"throw",
"\"Unable to get index for node '\"",
"+",
"nodeName",
"+",
"\"'. (Is the node name misspelled?)\"",
";",
"}",
"if",
"(",
"index",
"!==",
"undefined",
"&&",
"idx",
">",
"+",
"index",
")",
"{",
"throw",
"\"Unable to get index for node '\"",
"+",
"nodeName",
"+",
"\"'. (Are the nodes out of order?)\"",
";",
"}",
"if",
"(",
"index",
"!==",
"undefined",
"&&",
"idx",
"==",
"+",
"index",
")",
"{",
"throw",
"\"Unable to get index for node '\"",
"+",
"nodeName",
"+",
"\"'. (Is the node trying to reference itself?)\"",
";",
"}",
"return",
"(",
"dataContext",
")",
"=>",
"dataContext",
".",
"values",
"[",
"idx",
"]",
";",
"}"
] | Helper function to lookup a node | [
"Helper",
"function",
"to",
"lookup",
"a",
"node"
] | 69a1a86882f500d52839f544538014460709ba9e | https://github.com/joelahoover/nomv/blob/69a1a86882f500d52839f544538014460709ba9e/index.js#L585-L598 |
55,997 | joelahoover/nomv | index.js | resolveValueOrNodeSkel | function resolveValueOrNodeSkel(index, val, valDefault) {
switch (typeof(val)) {
case "string":
return resolveNodeSkel(index, val);
case "undefined":
if (valDefault === undefined) {
throw "Unable to get value'" + val + "'";
}
return () => valDefault;
default:
return () => val;
}
} | javascript | function resolveValueOrNodeSkel(index, val, valDefault) {
switch (typeof(val)) {
case "string":
return resolveNodeSkel(index, val);
case "undefined":
if (valDefault === undefined) {
throw "Unable to get value'" + val + "'";
}
return () => valDefault;
default:
return () => val;
}
} | [
"function",
"resolveValueOrNodeSkel",
"(",
"index",
",",
"val",
",",
"valDefault",
")",
"{",
"switch",
"(",
"typeof",
"(",
"val",
")",
")",
"{",
"case",
"\"string\"",
":",
"return",
"resolveNodeSkel",
"(",
"index",
",",
"val",
")",
";",
"case",
"\"undefined\"",
":",
"if",
"(",
"valDefault",
"===",
"undefined",
")",
"{",
"throw",
"\"Unable to get value'\"",
"+",
"val",
"+",
"\"'\"",
";",
"}",
"return",
"(",
")",
"=>",
"valDefault",
";",
"default",
":",
"return",
"(",
")",
"=>",
"val",
";",
"}",
"}"
] | Helper function for getting either a value or data from another node, or return the default | [
"Helper",
"function",
"for",
"getting",
"either",
"a",
"value",
"or",
"data",
"from",
"another",
"node",
"or",
"return",
"the",
"default"
] | 69a1a86882f500d52839f544538014460709ba9e | https://github.com/joelahoover/nomv/blob/69a1a86882f500d52839f544538014460709ba9e/index.js#L602-L614 |
55,998 | joelahoover/nomv | index.js | initialize | function initialize() {
var scene = ds = exports.ds = {
"time": 0,
"song": null,
"graph": null,
"shaders": {},
"textures": {},
"texturesToLoad": 0,
"audio": { "loaded": false, "playing": false },
"isLoaded": function() {
return this.graph !== null && this.texturesToLoad === 0 && this.audio.loaded === true;
},
"next": null
};
scene.gl = initializeWebGL();
initAudio(scene.audio);
initUI(scene);
scene.shaders.sprite = createGlslProgram(scene.gl, "vertexShaderSprite", "fragmentShaderSprite");
scene.shaders.particle = createGlslProgram(scene.gl, "vertexShaderParticle", "fragmentShaderParticle");
window.requestAnimationFrame(animationFrame.bind(null, scene));
} | javascript | function initialize() {
var scene = ds = exports.ds = {
"time": 0,
"song": null,
"graph": null,
"shaders": {},
"textures": {},
"texturesToLoad": 0,
"audio": { "loaded": false, "playing": false },
"isLoaded": function() {
return this.graph !== null && this.texturesToLoad === 0 && this.audio.loaded === true;
},
"next": null
};
scene.gl = initializeWebGL();
initAudio(scene.audio);
initUI(scene);
scene.shaders.sprite = createGlslProgram(scene.gl, "vertexShaderSprite", "fragmentShaderSprite");
scene.shaders.particle = createGlslProgram(scene.gl, "vertexShaderParticle", "fragmentShaderParticle");
window.requestAnimationFrame(animationFrame.bind(null, scene));
} | [
"function",
"initialize",
"(",
")",
"{",
"var",
"scene",
"=",
"ds",
"=",
"exports",
".",
"ds",
"=",
"{",
"\"time\"",
":",
"0",
",",
"\"song\"",
":",
"null",
",",
"\"graph\"",
":",
"null",
",",
"\"shaders\"",
":",
"{",
"}",
",",
"\"textures\"",
":",
"{",
"}",
",",
"\"texturesToLoad\"",
":",
"0",
",",
"\"audio\"",
":",
"{",
"\"loaded\"",
":",
"false",
",",
"\"playing\"",
":",
"false",
"}",
",",
"\"isLoaded\"",
":",
"function",
"(",
")",
"{",
"return",
"this",
".",
"graph",
"!==",
"null",
"&&",
"this",
".",
"texturesToLoad",
"===",
"0",
"&&",
"this",
".",
"audio",
".",
"loaded",
"===",
"true",
";",
"}",
",",
"\"next\"",
":",
"null",
"}",
";",
"scene",
".",
"gl",
"=",
"initializeWebGL",
"(",
")",
";",
"initAudio",
"(",
"scene",
".",
"audio",
")",
";",
"initUI",
"(",
"scene",
")",
";",
"scene",
".",
"shaders",
".",
"sprite",
"=",
"createGlslProgram",
"(",
"scene",
".",
"gl",
",",
"\"vertexShaderSprite\"",
",",
"\"fragmentShaderSprite\"",
")",
";",
"scene",
".",
"shaders",
".",
"particle",
"=",
"createGlslProgram",
"(",
"scene",
".",
"gl",
",",
"\"vertexShaderParticle\"",
",",
"\"fragmentShaderParticle\"",
")",
";",
"window",
".",
"requestAnimationFrame",
"(",
"animationFrame",
".",
"bind",
"(",
"null",
",",
"scene",
")",
")",
";",
"}"
] | Scene object for debugging | [
"Scene",
"object",
"for",
"debugging"
] | 69a1a86882f500d52839f544538014460709ba9e | https://github.com/joelahoover/nomv/blob/69a1a86882f500d52839f544538014460709ba9e/index.js#L876-L898 |
55,999 | dimitrievski/sumov | lib/index.js | sumObjectValues | function sumObjectValues(object, depth, level = 1) {
let sum = 0;
for (const i in object) {
const value = object[i];
if (isNumber(value)) {
sum += parseFloat(value);
} else if (isObject(value) && (depth < 1 || depth > level)) {
sum += sumObjectValues(value, depth, ++level);
--level;
}
}
return sum;
} | javascript | function sumObjectValues(object, depth, level = 1) {
let sum = 0;
for (const i in object) {
const value = object[i];
if (isNumber(value)) {
sum += parseFloat(value);
} else if (isObject(value) && (depth < 1 || depth > level)) {
sum += sumObjectValues(value, depth, ++level);
--level;
}
}
return sum;
} | [
"function",
"sumObjectValues",
"(",
"object",
",",
"depth",
",",
"level",
"=",
"1",
")",
"{",
"let",
"sum",
"=",
"0",
";",
"for",
"(",
"const",
"i",
"in",
"object",
")",
"{",
"const",
"value",
"=",
"object",
"[",
"i",
"]",
";",
"if",
"(",
"isNumber",
"(",
"value",
")",
")",
"{",
"sum",
"+=",
"parseFloat",
"(",
"value",
")",
";",
"}",
"else",
"if",
"(",
"isObject",
"(",
"value",
")",
"&&",
"(",
"depth",
"<",
"1",
"||",
"depth",
">",
"level",
")",
")",
"{",
"sum",
"+=",
"sumObjectValues",
"(",
"value",
",",
"depth",
",",
"++",
"level",
")",
";",
"--",
"level",
";",
"}",
"}",
"return",
"sum",
";",
"}"
] | Recursive function that computes the sum
of all numeric values in an object
@param {Object} object
@param {Integer} depth
@param {Integer} level
@returns {Number} | [
"Recursive",
"function",
"that",
"computes",
"the",
"sum",
"of",
"all",
"numeric",
"values",
"in",
"an",
"object"
] | bdbdae19305f9c7e86c2a9124b64d664c0893fab | https://github.com/dimitrievski/sumov/blob/bdbdae19305f9c7e86c2a9124b64d664c0893fab/lib/index.js#L37-L49 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.