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
|
---|---|---|---|---|---|---|---|---|---|---|---|
56,400 | activethread/vulpejs | lib/models/index.js | function (query, page, callback) {
var History = exports.get('History');
History.paginate(query, {
page: page,
limit: vulpejs.app.pagination.history,
}, function (error, items, pageCount, itemCount) {
if (error) {
vulpejs.log.error('HISTORY', error);
} else {
callback(error, {
items: items,
pageCount: pageCount,
itemCount: itemCount,
});
}
}, {
sortBy: {
version: -1,
},
});
} | javascript | function (query, page, callback) {
var History = exports.get('History');
History.paginate(query, {
page: page,
limit: vulpejs.app.pagination.history,
}, function (error, items, pageCount, itemCount) {
if (error) {
vulpejs.log.error('HISTORY', error);
} else {
callback(error, {
items: items,
pageCount: pageCount,
itemCount: itemCount,
});
}
}, {
sortBy: {
version: -1,
},
});
} | [
"function",
"(",
"query",
",",
"page",
",",
"callback",
")",
"{",
"var",
"History",
"=",
"exports",
".",
"get",
"(",
"'History'",
")",
";",
"History",
".",
"paginate",
"(",
"query",
",",
"{",
"page",
":",
"page",
",",
"limit",
":",
"vulpejs",
".",
"app",
".",
"pagination",
".",
"history",
",",
"}",
",",
"function",
"(",
"error",
",",
"items",
",",
"pageCount",
",",
"itemCount",
")",
"{",
"if",
"(",
"error",
")",
"{",
"vulpejs",
".",
"log",
".",
"error",
"(",
"'HISTORY'",
",",
"error",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"error",
",",
"{",
"items",
":",
"items",
",",
"pageCount",
":",
"pageCount",
",",
"itemCount",
":",
"itemCount",
",",
"}",
")",
";",
"}",
"}",
",",
"{",
"sortBy",
":",
"{",
"version",
":",
"-",
"1",
",",
"}",
",",
"}",
")",
";",
"}"
] | Find and page histories of object in database.
@param {Object} query Query
@param {Number} page Page
@param {Function} callback Callback function | [
"Find",
"and",
"page",
"histories",
"of",
"object",
"in",
"database",
"."
] | cba9529ebb13892b2c7d07219c7fa69137151fbd | https://github.com/activethread/vulpejs/blob/cba9529ebb13892b2c7d07219c7fa69137151fbd/lib/models/index.js#L445-L465 |
|
56,401 | byu-oit/sans-server | bin/server/request.js | Request | function Request(server, keys, rejectable, config) {
if (!config) config = {};
if (typeof config !== 'object') config = { path: config };
const promise = new Promise((resolve, reject) => {
let fulfilled = false;
this.on('res-complete', () => {
if (fulfilled) {
req.log('fulfilled', 'Already fulfilled');
} else {
fulfilled = true;
req.log('fulfilled');
resolve(res.state);
}
});
this.on('error', err => {
req.log('error', err.stack.replace(/\n/g, '\n '));
if (fulfilled) {
req.log('fulfilled', 'Already fulfilled');
} else {
fulfilled = true;
res.reset().set('content-type', 'text/plain').status(500).body(httpStatus[500]);
req.log('fulfilled');
if (rejectable) {
reject(err);
} else {
resolve(res.state);
}
}
});
});
// initialize variables
const id = uuid();
const hooks = {};
const req = this;
const res = new Response(this, keys.response);
/**
* Get the unique ID associated with this request.
* @name Request#id
* @type {string}
* @readonly
*/
Object.defineProperty(this, 'id', {
configurable: false,
enumerable: true,
value: id
});
/**
* Get the response object that is tied to this request.
* @name Request#res
* @type {Response}
*/
Object.defineProperty(this, 'res', {
configurable: false,
enumerable: true,
value: res
});
/**
* Get the server instance that initialized this request.
* @name Request#server
* @type {SansServer}
*/
Object.defineProperty(this, 'server', {
enumerable: true,
configurable: false,
value: server
});
/**
* Get the request URL which consists of the path and the query parameters.
* @name Request#url
* @type {string}
* @readonly
*/
Object.defineProperty(this, 'url', {
configurable: false,
enumerable: true,
get: () => this.path + buildQueryString(this.query)
});
/**
* Add a rejection handler to the request promise.
* @name Request#catch
* @param {Function} onRejected
* @returns {Promise}
*/
this.catch = onRejected => promise.catch(onRejected);
/**
* Produce a request log event.
* @param {string} message
* @param {...*} [args]
* @returns {Request}
* @fires Request#log
*/
this.log = this.logger('sans-server', 'request', this);
/**
* Add request specific hooks
* @param {string} type
* @param {number} [weight=0]
* @param {...Function} hook
* @returns {Request}
*/
this.hook = addHook.bind(this, hooks);
/**
* @name Request#hook.run
* @param {Symbol} type
* @param {function} [next]
* @returns {Promise|undefined}
*/
this.hook.reverse = (type, next) => runHooksMode(req, hooks, 'reverse', type, next);
/**
* @name Request#hook.run
* @param {Symbol} type
* @param {function} [next]
* @returns {Promise|undefined}
*/
this.hook.run = (type, next) => runHooksMode(req, hooks, 'run', type, next);
/**
* Add fulfillment or rejection handlers to the request promise.
* @name Request#then
* @param {Function} onFulfilled
* @param {Function} [onRejected]
* @returns {Promise}
*/
this.then = (onFulfilled, onRejected) => promise.then(onFulfilled, onRejected);
/**
* The request body.
* @name Request#body
* @type {string|Object|Buffer|undefined}
*/
/**
* The request headers. This is an object that has lower-case keys and string values.
* @name Request#headers
* @type {Object<string,string>}
*/
/**
* This request method. The lower case equivalents of these value are acceptable but will be automatically lower-cased.
* @name Request#method
* @type {string} One of: 'GET', 'DELETE', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT'
*/
/**
* The request path, beginning with a '/'. Does not include domain or query string.
* @name Request#path
* @type {string}
*/
/**
* An object mapping query parameters by key.
* @name Request#query
* @type {object<string,string>}
*/
// validate and normalize input
Object.assign(this, config, normalize(req, config));
// wait one tick for any event listeners to be added
process.nextTick(() => {
// run request hooks
this.hook.run(keys.request)
.then(() => {
if (!res.sent) {
req.log('unhandled', 'request not handled');
if (res.state.statusCode === 0) {
res.sendStatus(404);
} else {
res.send();
}
}
})
.catch(err => {
this.emit('error', err)
});
});
} | javascript | function Request(server, keys, rejectable, config) {
if (!config) config = {};
if (typeof config !== 'object') config = { path: config };
const promise = new Promise((resolve, reject) => {
let fulfilled = false;
this.on('res-complete', () => {
if (fulfilled) {
req.log('fulfilled', 'Already fulfilled');
} else {
fulfilled = true;
req.log('fulfilled');
resolve(res.state);
}
});
this.on('error', err => {
req.log('error', err.stack.replace(/\n/g, '\n '));
if (fulfilled) {
req.log('fulfilled', 'Already fulfilled');
} else {
fulfilled = true;
res.reset().set('content-type', 'text/plain').status(500).body(httpStatus[500]);
req.log('fulfilled');
if (rejectable) {
reject(err);
} else {
resolve(res.state);
}
}
});
});
// initialize variables
const id = uuid();
const hooks = {};
const req = this;
const res = new Response(this, keys.response);
/**
* Get the unique ID associated with this request.
* @name Request#id
* @type {string}
* @readonly
*/
Object.defineProperty(this, 'id', {
configurable: false,
enumerable: true,
value: id
});
/**
* Get the response object that is tied to this request.
* @name Request#res
* @type {Response}
*/
Object.defineProperty(this, 'res', {
configurable: false,
enumerable: true,
value: res
});
/**
* Get the server instance that initialized this request.
* @name Request#server
* @type {SansServer}
*/
Object.defineProperty(this, 'server', {
enumerable: true,
configurable: false,
value: server
});
/**
* Get the request URL which consists of the path and the query parameters.
* @name Request#url
* @type {string}
* @readonly
*/
Object.defineProperty(this, 'url', {
configurable: false,
enumerable: true,
get: () => this.path + buildQueryString(this.query)
});
/**
* Add a rejection handler to the request promise.
* @name Request#catch
* @param {Function} onRejected
* @returns {Promise}
*/
this.catch = onRejected => promise.catch(onRejected);
/**
* Produce a request log event.
* @param {string} message
* @param {...*} [args]
* @returns {Request}
* @fires Request#log
*/
this.log = this.logger('sans-server', 'request', this);
/**
* Add request specific hooks
* @param {string} type
* @param {number} [weight=0]
* @param {...Function} hook
* @returns {Request}
*/
this.hook = addHook.bind(this, hooks);
/**
* @name Request#hook.run
* @param {Symbol} type
* @param {function} [next]
* @returns {Promise|undefined}
*/
this.hook.reverse = (type, next) => runHooksMode(req, hooks, 'reverse', type, next);
/**
* @name Request#hook.run
* @param {Symbol} type
* @param {function} [next]
* @returns {Promise|undefined}
*/
this.hook.run = (type, next) => runHooksMode(req, hooks, 'run', type, next);
/**
* Add fulfillment or rejection handlers to the request promise.
* @name Request#then
* @param {Function} onFulfilled
* @param {Function} [onRejected]
* @returns {Promise}
*/
this.then = (onFulfilled, onRejected) => promise.then(onFulfilled, onRejected);
/**
* The request body.
* @name Request#body
* @type {string|Object|Buffer|undefined}
*/
/**
* The request headers. This is an object that has lower-case keys and string values.
* @name Request#headers
* @type {Object<string,string>}
*/
/**
* This request method. The lower case equivalents of these value are acceptable but will be automatically lower-cased.
* @name Request#method
* @type {string} One of: 'GET', 'DELETE', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT'
*/
/**
* The request path, beginning with a '/'. Does not include domain or query string.
* @name Request#path
* @type {string}
*/
/**
* An object mapping query parameters by key.
* @name Request#query
* @type {object<string,string>}
*/
// validate and normalize input
Object.assign(this, config, normalize(req, config));
// wait one tick for any event listeners to be added
process.nextTick(() => {
// run request hooks
this.hook.run(keys.request)
.then(() => {
if (!res.sent) {
req.log('unhandled', 'request not handled');
if (res.state.statusCode === 0) {
res.sendStatus(404);
} else {
res.send();
}
}
})
.catch(err => {
this.emit('error', err)
});
});
} | [
"function",
"Request",
"(",
"server",
",",
"keys",
",",
"rejectable",
",",
"config",
")",
"{",
"if",
"(",
"!",
"config",
")",
"config",
"=",
"{",
"}",
";",
"if",
"(",
"typeof",
"config",
"!==",
"'object'",
")",
"config",
"=",
"{",
"path",
":",
"config",
"}",
";",
"const",
"promise",
"=",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"let",
"fulfilled",
"=",
"false",
";",
"this",
".",
"on",
"(",
"'res-complete'",
",",
"(",
")",
"=>",
"{",
"if",
"(",
"fulfilled",
")",
"{",
"req",
".",
"log",
"(",
"'fulfilled'",
",",
"'Already fulfilled'",
")",
";",
"}",
"else",
"{",
"fulfilled",
"=",
"true",
";",
"req",
".",
"log",
"(",
"'fulfilled'",
")",
";",
"resolve",
"(",
"res",
".",
"state",
")",
";",
"}",
"}",
")",
";",
"this",
".",
"on",
"(",
"'error'",
",",
"err",
"=>",
"{",
"req",
".",
"log",
"(",
"'error'",
",",
"err",
".",
"stack",
".",
"replace",
"(",
"/",
"\\n",
"/",
"g",
",",
"'\\n '",
")",
")",
";",
"if",
"(",
"fulfilled",
")",
"{",
"req",
".",
"log",
"(",
"'fulfilled'",
",",
"'Already fulfilled'",
")",
";",
"}",
"else",
"{",
"fulfilled",
"=",
"true",
";",
"res",
".",
"reset",
"(",
")",
".",
"set",
"(",
"'content-type'",
",",
"'text/plain'",
")",
".",
"status",
"(",
"500",
")",
".",
"body",
"(",
"httpStatus",
"[",
"500",
"]",
")",
";",
"req",
".",
"log",
"(",
"'fulfilled'",
")",
";",
"if",
"(",
"rejectable",
")",
"{",
"reject",
"(",
"err",
")",
";",
"}",
"else",
"{",
"resolve",
"(",
"res",
".",
"state",
")",
";",
"}",
"}",
"}",
")",
";",
"}",
")",
";",
"// initialize variables",
"const",
"id",
"=",
"uuid",
"(",
")",
";",
"const",
"hooks",
"=",
"{",
"}",
";",
"const",
"req",
"=",
"this",
";",
"const",
"res",
"=",
"new",
"Response",
"(",
"this",
",",
"keys",
".",
"response",
")",
";",
"/**\n * Get the unique ID associated with this request.\n * @name Request#id\n * @type {string}\n * @readonly\n */",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"'id'",
",",
"{",
"configurable",
":",
"false",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"id",
"}",
")",
";",
"/**\n * Get the response object that is tied to this request.\n * @name Request#res\n * @type {Response}\n */",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"'res'",
",",
"{",
"configurable",
":",
"false",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"res",
"}",
")",
";",
"/**\n * Get the server instance that initialized this request.\n * @name Request#server\n * @type {SansServer}\n */",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"'server'",
",",
"{",
"enumerable",
":",
"true",
",",
"configurable",
":",
"false",
",",
"value",
":",
"server",
"}",
")",
";",
"/**\n * Get the request URL which consists of the path and the query parameters.\n * @name Request#url\n * @type {string}\n * @readonly\n */",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"'url'",
",",
"{",
"configurable",
":",
"false",
",",
"enumerable",
":",
"true",
",",
"get",
":",
"(",
")",
"=>",
"this",
".",
"path",
"+",
"buildQueryString",
"(",
"this",
".",
"query",
")",
"}",
")",
";",
"/**\n * Add a rejection handler to the request promise.\n * @name Request#catch\n * @param {Function} onRejected\n * @returns {Promise}\n */",
"this",
".",
"catch",
"=",
"onRejected",
"=>",
"promise",
".",
"catch",
"(",
"onRejected",
")",
";",
"/**\n * Produce a request log event.\n * @param {string} message\n * @param {...*} [args]\n * @returns {Request}\n * @fires Request#log\n */",
"this",
".",
"log",
"=",
"this",
".",
"logger",
"(",
"'sans-server'",
",",
"'request'",
",",
"this",
")",
";",
"/**\n * Add request specific hooks\n * @param {string} type\n * @param {number} [weight=0]\n * @param {...Function} hook\n * @returns {Request}\n */",
"this",
".",
"hook",
"=",
"addHook",
".",
"bind",
"(",
"this",
",",
"hooks",
")",
";",
"/**\n * @name Request#hook.run\n * @param {Symbol} type\n * @param {function} [next]\n * @returns {Promise|undefined}\n */",
"this",
".",
"hook",
".",
"reverse",
"=",
"(",
"type",
",",
"next",
")",
"=>",
"runHooksMode",
"(",
"req",
",",
"hooks",
",",
"'reverse'",
",",
"type",
",",
"next",
")",
";",
"/**\n * @name Request#hook.run\n * @param {Symbol} type\n * @param {function} [next]\n * @returns {Promise|undefined}\n */",
"this",
".",
"hook",
".",
"run",
"=",
"(",
"type",
",",
"next",
")",
"=>",
"runHooksMode",
"(",
"req",
",",
"hooks",
",",
"'run'",
",",
"type",
",",
"next",
")",
";",
"/**\n * Add fulfillment or rejection handlers to the request promise.\n * @name Request#then\n * @param {Function} onFulfilled\n * @param {Function} [onRejected]\n * @returns {Promise}\n */",
"this",
".",
"then",
"=",
"(",
"onFulfilled",
",",
"onRejected",
")",
"=>",
"promise",
".",
"then",
"(",
"onFulfilled",
",",
"onRejected",
")",
";",
"/**\n * The request body.\n * @name Request#body\n * @type {string|Object|Buffer|undefined}\n */",
"/**\n * The request headers. This is an object that has lower-case keys and string values.\n * @name Request#headers\n * @type {Object<string,string>}\n */",
"/**\n * This request method. The lower case equivalents of these value are acceptable but will be automatically lower-cased.\n * @name Request#method\n * @type {string} One of: 'GET', 'DELETE', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT'\n */",
"/**\n * The request path, beginning with a '/'. Does not include domain or query string.\n * @name Request#path\n * @type {string}\n */",
"/**\n * An object mapping query parameters by key.\n * @name Request#query\n * @type {object<string,string>}\n */",
"// validate and normalize input",
"Object",
".",
"assign",
"(",
"this",
",",
"config",
",",
"normalize",
"(",
"req",
",",
"config",
")",
")",
";",
"// wait one tick for any event listeners to be added",
"process",
".",
"nextTick",
"(",
"(",
")",
"=>",
"{",
"// run request hooks",
"this",
".",
"hook",
".",
"run",
"(",
"keys",
".",
"request",
")",
".",
"then",
"(",
"(",
")",
"=>",
"{",
"if",
"(",
"!",
"res",
".",
"sent",
")",
"{",
"req",
".",
"log",
"(",
"'unhandled'",
",",
"'request not handled'",
")",
";",
"if",
"(",
"res",
".",
"state",
".",
"statusCode",
"===",
"0",
")",
"{",
"res",
".",
"sendStatus",
"(",
"404",
")",
";",
"}",
"else",
"{",
"res",
".",
"send",
"(",
")",
";",
"}",
"}",
"}",
")",
".",
"catch",
"(",
"err",
"=>",
"{",
"this",
".",
"emit",
"(",
"'error'",
",",
"err",
")",
"}",
")",
";",
"}",
")",
";",
"}"
] | Generate a request instance.
@param {SansServer} server
@param {object} keys
@param {boolean} rejectable
@param {string|Object} [config] A string representing the path or a configuration representing all properties
to accompany the request.
@returns {Request}
@constructor
@augments {EventEmitter}
@augments {Promise} | [
"Generate",
"a",
"request",
"instance",
"."
] | 022bcf7b47321e6e8aa20467cd96a6a84a457ec8 | https://github.com/byu-oit/sans-server/blob/022bcf7b47321e6e8aa20467cd96a6a84a457ec8/bin/server/request.js#L40-L229 |
56,402 | ericsaboia/migrate-database | tasks/lib/migrate.js | Migrate | function Migrate (grunt, adapter, config, steps) {
this.grunt = grunt;
this.adapter = adapter;
this.path = path.resolve(config.path);
this.steps = steps;
} | javascript | function Migrate (grunt, adapter, config, steps) {
this.grunt = grunt;
this.adapter = adapter;
this.path = path.resolve(config.path);
this.steps = steps;
} | [
"function",
"Migrate",
"(",
"grunt",
",",
"adapter",
",",
"config",
",",
"steps",
")",
"{",
"this",
".",
"grunt",
"=",
"grunt",
";",
"this",
".",
"adapter",
"=",
"adapter",
";",
"this",
".",
"path",
"=",
"path",
".",
"resolve",
"(",
"config",
".",
"path",
")",
";",
"this",
".",
"steps",
"=",
"steps",
";",
"}"
] | Initialize a new migration `Migrate` with the given `grunt, adapter, path and steps`
@param {Object} grunt
@param {Adapter} adapter
@param {String} path
@param {Number} steps
@api private | [
"Initialize",
"a",
"new",
"migration",
"Migrate",
"with",
"the",
"given",
"grunt",
"adapter",
"path",
"and",
"steps"
] | 7a9afb4d1b4aeb1bb5e6c1ae7a2a7c7e0fa16e5d | https://github.com/ericsaboia/migrate-database/blob/7a9afb4d1b4aeb1bb5e6c1ae7a2a7c7e0fa16e5d/tasks/lib/migrate.js#L35-L40 |
56,403 | kmalakoff/backbone-articulation | vendor/lifecycle-1.0.2.js | function(parent, protoProps, staticProps) {
var child;
// The constructor function for the new subclass is either defined by you
// (the "constructor" property in your extend definition), or defaulted
// by us to simply call the parent's constructor.
if (protoProps && protoProps.hasOwnProperty('constructor')) {
child = protoProps.constructor;
} else {
child = function(){ parent.apply(this, arguments); };
}
// Inherit class (static) properties from parent.
copyProps(child, parent);
// Set the prototype chain to inherit from parent, without calling
// parent's constructor function.
ctor.prototype = parent.prototype;
child.prototype = new ctor();
// Add prototype properties (instance properties) to the subclass,
// if supplied.
if (protoProps) copyProps(child.prototype, protoProps);
// Add static properties to the constructor function, if supplied.
if (staticProps) copyProps(child, staticProps);
// Correctly set child's 'prototype.constructor'.
child.prototype.constructor = child;
// Set a convenience property in case the parent's prototype is needed later.
child.__super__ = parent.prototype;
return child;
} | javascript | function(parent, protoProps, staticProps) {
var child;
// The constructor function for the new subclass is either defined by you
// (the "constructor" property in your extend definition), or defaulted
// by us to simply call the parent's constructor.
if (protoProps && protoProps.hasOwnProperty('constructor')) {
child = protoProps.constructor;
} else {
child = function(){ parent.apply(this, arguments); };
}
// Inherit class (static) properties from parent.
copyProps(child, parent);
// Set the prototype chain to inherit from parent, without calling
// parent's constructor function.
ctor.prototype = parent.prototype;
child.prototype = new ctor();
// Add prototype properties (instance properties) to the subclass,
// if supplied.
if (protoProps) copyProps(child.prototype, protoProps);
// Add static properties to the constructor function, if supplied.
if (staticProps) copyProps(child, staticProps);
// Correctly set child's 'prototype.constructor'.
child.prototype.constructor = child;
// Set a convenience property in case the parent's prototype is needed later.
child.__super__ = parent.prototype;
return child;
} | [
"function",
"(",
"parent",
",",
"protoProps",
",",
"staticProps",
")",
"{",
"var",
"child",
";",
"// The constructor function for the new subclass is either defined by you",
"// (the \"constructor\" property in your extend definition), or defaulted",
"// by us to simply call the parent's constructor.",
"if",
"(",
"protoProps",
"&&",
"protoProps",
".",
"hasOwnProperty",
"(",
"'constructor'",
")",
")",
"{",
"child",
"=",
"protoProps",
".",
"constructor",
";",
"}",
"else",
"{",
"child",
"=",
"function",
"(",
")",
"{",
"parent",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
";",
"}",
"// Inherit class (static) properties from parent.",
"copyProps",
"(",
"child",
",",
"parent",
")",
";",
"// Set the prototype chain to inherit from parent, without calling",
"// parent's constructor function.",
"ctor",
".",
"prototype",
"=",
"parent",
".",
"prototype",
";",
"child",
".",
"prototype",
"=",
"new",
"ctor",
"(",
")",
";",
"// Add prototype properties (instance properties) to the subclass,",
"// if supplied.",
"if",
"(",
"protoProps",
")",
"copyProps",
"(",
"child",
".",
"prototype",
",",
"protoProps",
")",
";",
"// Add static properties to the constructor function, if supplied.",
"if",
"(",
"staticProps",
")",
"copyProps",
"(",
"child",
",",
"staticProps",
")",
";",
"// Correctly set child's 'prototype.constructor'.",
"child",
".",
"prototype",
".",
"constructor",
"=",
"child",
";",
"// Set a convenience property in case the parent's prototype is needed later.",
"child",
".",
"__super__",
"=",
"parent",
".",
"prototype",
";",
"return",
"child",
";",
"}"
] | Helper function to correctly set up the prototype chain, for subclasses. Similar to 'goog.inherits', but uses a hash of prototype properties and class properties to be extended. | [
"Helper",
"function",
"to",
"correctly",
"set",
"up",
"the",
"prototype",
"chain",
"for",
"subclasses",
".",
"Similar",
"to",
"goog",
".",
"inherits",
"but",
"uses",
"a",
"hash",
"of",
"prototype",
"properties",
"and",
"class",
"properties",
"to",
"be",
"extended",
"."
] | ce093551bab078369b5f9f4244873d108a344eb5 | https://github.com/kmalakoff/backbone-articulation/blob/ce093551bab078369b5f9f4244873d108a344eb5/vendor/lifecycle-1.0.2.js#L56-L90 |
|
56,404 | jpitts/rapt-modelrizerly | lib/datastores/mongodb.js | function (finder) {
if (mongo_query_options && mongo_query_options.sort) {
finder.sort(mongo_query_options.sort).toArray(cb);
} else {
finder.toArray(cb);
}
} | javascript | function (finder) {
if (mongo_query_options && mongo_query_options.sort) {
finder.sort(mongo_query_options.sort).toArray(cb);
} else {
finder.toArray(cb);
}
} | [
"function",
"(",
"finder",
")",
"{",
"if",
"(",
"mongo_query_options",
"&&",
"mongo_query_options",
".",
"sort",
")",
"{",
"finder",
".",
"sort",
"(",
"mongo_query_options",
".",
"sort",
")",
".",
"toArray",
"(",
"cb",
")",
";",
"}",
"else",
"{",
"finder",
".",
"toArray",
"(",
"cb",
")",
";",
"}",
"}"
] | final sorting and rendering to array | [
"final",
"sorting",
"and",
"rendering",
"to",
"array"
] | 4b6b5bd0e7838c05029e7c20d500c9f4f7b0cc92 | https://github.com/jpitts/rapt-modelrizerly/blob/4b6b5bd0e7838c05029e7c20d500c9f4f7b0cc92/lib/datastores/mongodb.js#L227-L236 |
|
56,405 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/link/plugin.js | function( editor ) {
var selection = editor.getSelection();
var selectedElement = selection.getSelectedElement();
if ( selectedElement && selectedElement.is( 'a' ) )
return selectedElement;
var range = selection.getRanges()[ 0 ];
if ( range ) {
range.shrink( CKEDITOR.SHRINK_TEXT );
return editor.elementPath( range.getCommonAncestor() ).contains( 'a', 1 );
}
return null;
} | javascript | function( editor ) {
var selection = editor.getSelection();
var selectedElement = selection.getSelectedElement();
if ( selectedElement && selectedElement.is( 'a' ) )
return selectedElement;
var range = selection.getRanges()[ 0 ];
if ( range ) {
range.shrink( CKEDITOR.SHRINK_TEXT );
return editor.elementPath( range.getCommonAncestor() ).contains( 'a', 1 );
}
return null;
} | [
"function",
"(",
"editor",
")",
"{",
"var",
"selection",
"=",
"editor",
".",
"getSelection",
"(",
")",
";",
"var",
"selectedElement",
"=",
"selection",
".",
"getSelectedElement",
"(",
")",
";",
"if",
"(",
"selectedElement",
"&&",
"selectedElement",
".",
"is",
"(",
"'a'",
")",
")",
"return",
"selectedElement",
";",
"var",
"range",
"=",
"selection",
".",
"getRanges",
"(",
")",
"[",
"0",
"]",
";",
"if",
"(",
"range",
")",
"{",
"range",
".",
"shrink",
"(",
"CKEDITOR",
".",
"SHRINK_TEXT",
")",
";",
"return",
"editor",
".",
"elementPath",
"(",
"range",
".",
"getCommonAncestor",
"(",
")",
")",
".",
"contains",
"(",
"'a'",
",",
"1",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Get the surrounding link element of the current selection.
CKEDITOR.plugins.link.getSelectedLink( editor );
// The following selections will all return the link element.
<a href="#">li^nk</a>
<a href="#">[link]</a>
text[<a href="#">link]</a>
<a href="#">li[nk</a>]
[<b><a href="#">li]nk</a></b>]
[<a href="#"><b>li]nk</b></a>
@since 3.2.1
@param {CKEDITOR.editor} editor | [
"Get",
"the",
"surrounding",
"link",
"element",
"of",
"the",
"current",
"selection",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/link/plugin.js#L312-L325 |
|
56,406 | christophercrouzet/pillr | lib/load_templates.js | loadTemplate | function loadTemplate(template, name, callback) {
async.waterfall([
cb => source(template.path, template.filter, template.readMode, cb),
(files, cb) => asDataMap(files, template.mapping, cb),
], (error, result) => {
async.nextTick(callback, error, result);
});
} | javascript | function loadTemplate(template, name, callback) {
async.waterfall([
cb => source(template.path, template.filter, template.readMode, cb),
(files, cb) => asDataMap(files, template.mapping, cb),
], (error, result) => {
async.nextTick(callback, error, result);
});
} | [
"function",
"loadTemplate",
"(",
"template",
",",
"name",
",",
"callback",
")",
"{",
"async",
".",
"waterfall",
"(",
"[",
"cb",
"=>",
"source",
"(",
"template",
".",
"path",
",",
"template",
".",
"filter",
",",
"template",
".",
"readMode",
",",
"cb",
")",
",",
"(",
"files",
",",
"cb",
")",
"=>",
"asDataMap",
"(",
"files",
",",
"template",
".",
"mapping",
",",
"cb",
")",
",",
"]",
",",
"(",
"error",
",",
"result",
")",
"=>",
"{",
"async",
".",
"nextTick",
"(",
"callback",
",",
"error",
",",
"result",
")",
";",
"}",
")",
";",
"}"
] | Load a single template. | [
"Load",
"a",
"single",
"template",
"."
] | 411ccd344a03478776c4e8d2e2f9bdc45dc8ee45 | https://github.com/christophercrouzet/pillr/blob/411ccd344a03478776c4e8d2e2f9bdc45dc8ee45/lib/load_templates.js#L23-L30 |
56,407 | michaelnisi/pushup | index.js | Headers | function Headers (size, type, ttl, enc) {
if (!(this instanceof Headers)) return new Headers(size, type, ttl, enc)
if (size) this['Content-Length'] = size
if (type) this['Content-Type'] = type
if (!isNaN(ttl)) this['Cache-Control'] = 'max-age=' + ttl
if (enc) this['Content-Encoding'] = enc
} | javascript | function Headers (size, type, ttl, enc) {
if (!(this instanceof Headers)) return new Headers(size, type, ttl, enc)
if (size) this['Content-Length'] = size
if (type) this['Content-Type'] = type
if (!isNaN(ttl)) this['Cache-Control'] = 'max-age=' + ttl
if (enc) this['Content-Encoding'] = enc
} | [
"function",
"Headers",
"(",
"size",
",",
"type",
",",
"ttl",
",",
"enc",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Headers",
")",
")",
"return",
"new",
"Headers",
"(",
"size",
",",
"type",
",",
"ttl",
",",
"enc",
")",
"if",
"(",
"size",
")",
"this",
"[",
"'Content-Length'",
"]",
"=",
"size",
"if",
"(",
"type",
")",
"this",
"[",
"'Content-Type'",
"]",
"=",
"type",
"if",
"(",
"!",
"isNaN",
"(",
"ttl",
")",
")",
"this",
"[",
"'Cache-Control'",
"]",
"=",
"'max-age='",
"+",
"ttl",
"if",
"(",
"enc",
")",
"this",
"[",
"'Content-Encoding'",
"]",
"=",
"enc",
"}"
] | - size the size of the entity-body in decimal number of octets - type the media type of the entity-body - ttl the maximum age in seconds - enc the modifier to the media-type | [
"-",
"size",
"the",
"size",
"of",
"the",
"entity",
"-",
"body",
"in",
"decimal",
"number",
"of",
"octets",
"-",
"type",
"the",
"media",
"type",
"of",
"the",
"entity",
"-",
"body",
"-",
"ttl",
"the",
"maximum",
"age",
"in",
"seconds",
"-",
"enc",
"the",
"modifier",
"to",
"the",
"media",
"-",
"type"
] | 104c4db4a1938d89cf9e77cb97090c42ea3d35ed | https://github.com/michaelnisi/pushup/blob/104c4db4a1938d89cf9e77cb97090c42ea3d35ed/index.js#L70-L76 |
56,408 | EyalAr/fume | bin/fume.js | function (next) {
async.each(input, function (path, done) {
fs.stat(path, function (err, stats) {
if (err) return done(err);
if (stats.isDirectory())
return done("Cannot have a directory as input");
done();
});
}, next);
} | javascript | function (next) {
async.each(input, function (path, done) {
fs.stat(path, function (err, stats) {
if (err) return done(err);
if (stats.isDirectory())
return done("Cannot have a directory as input");
done();
});
}, next);
} | [
"function",
"(",
"next",
")",
"{",
"async",
".",
"each",
"(",
"input",
",",
"function",
"(",
"path",
",",
"done",
")",
"{",
"fs",
".",
"stat",
"(",
"path",
",",
"function",
"(",
"err",
",",
"stats",
")",
"{",
"if",
"(",
"err",
")",
"return",
"done",
"(",
"err",
")",
";",
"if",
"(",
"stats",
".",
"isDirectory",
"(",
")",
")",
"return",
"done",
"(",
"\"Cannot have a directory as input\"",
")",
";",
"done",
"(",
")",
";",
"}",
")",
";",
"}",
",",
"next",
")",
";",
"}"
] | make sure no directories in the input list | [
"make",
"sure",
"no",
"directories",
"in",
"the",
"input",
"list"
] | 66f555d39b9cee18bbdf7a0a565919247163a227 | https://github.com/EyalAr/fume/blob/66f555d39b9cee18bbdf7a0a565919247163a227/bin/fume.js#L55-L66 |
|
56,409 | codenothing/munit | lib/render.js | function( name ) {
if ( ! munit.isString( name ) || ! name.length ) {
throw new Error( "Name not found for removing formatter" );
}
if ( render._formatHash[ name ] ) {
delete render._formatHash[ name ];
render._formats = render._formats.filter(function( f ) {
return f.name !== name;
});
}
} | javascript | function( name ) {
if ( ! munit.isString( name ) || ! name.length ) {
throw new Error( "Name not found for removing formatter" );
}
if ( render._formatHash[ name ] ) {
delete render._formatHash[ name ];
render._formats = render._formats.filter(function( f ) {
return f.name !== name;
});
}
} | [
"function",
"(",
"name",
")",
"{",
"if",
"(",
"!",
"munit",
".",
"isString",
"(",
"name",
")",
"||",
"!",
"name",
".",
"length",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Name not found for removing formatter\"",
")",
";",
"}",
"if",
"(",
"render",
".",
"_formatHash",
"[",
"name",
"]",
")",
"{",
"delete",
"render",
".",
"_formatHash",
"[",
"name",
"]",
";",
"render",
".",
"_formats",
"=",
"render",
".",
"_formats",
".",
"filter",
"(",
"function",
"(",
"f",
")",
"{",
"return",
"f",
".",
"name",
"!==",
"name",
";",
"}",
")",
";",
"}",
"}"
] | Removing a formatter | [
"Removing",
"a",
"formatter"
] | aedf3f31aafc05441970eec49eeeb81174c14033 | https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/render.js#L119-L130 |
|
56,410 | codenothing/munit | lib/render.js | function( path, callback ) {
var parts = ( path || '' ).split( /\//g ),
filepath = '/';
// Trim Left
if ( ! parts[ 0 ].length ) {
parts.shift();
}
// Trim right
if ( parts.length && ! parts[ parts.length - 1 ].length ) {
parts.pop();
}
// Handle root '/' error
if ( ! parts.length ) {
return callback( new Error( "No directory path found to make" ) );
}
// Make sure each branch is created
async.mapSeries( parts,
function( dir, callback ) {
fs.stat( filepath += dir + '/', function( e, stat ) {
if ( stat && stat.isDirectory() ) {
callback();
}
else {
fs.mkdir( filepath, callback );
}
});
},
callback
);
} | javascript | function( path, callback ) {
var parts = ( path || '' ).split( /\//g ),
filepath = '/';
// Trim Left
if ( ! parts[ 0 ].length ) {
parts.shift();
}
// Trim right
if ( parts.length && ! parts[ parts.length - 1 ].length ) {
parts.pop();
}
// Handle root '/' error
if ( ! parts.length ) {
return callback( new Error( "No directory path found to make" ) );
}
// Make sure each branch is created
async.mapSeries( parts,
function( dir, callback ) {
fs.stat( filepath += dir + '/', function( e, stat ) {
if ( stat && stat.isDirectory() ) {
callback();
}
else {
fs.mkdir( filepath, callback );
}
});
},
callback
);
} | [
"function",
"(",
"path",
",",
"callback",
")",
"{",
"var",
"parts",
"=",
"(",
"path",
"||",
"''",
")",
".",
"split",
"(",
"/",
"\\/",
"/",
"g",
")",
",",
"filepath",
"=",
"'/'",
";",
"// Trim Left",
"if",
"(",
"!",
"parts",
"[",
"0",
"]",
".",
"length",
")",
"{",
"parts",
".",
"shift",
"(",
")",
";",
"}",
"// Trim right",
"if",
"(",
"parts",
".",
"length",
"&&",
"!",
"parts",
"[",
"parts",
".",
"length",
"-",
"1",
"]",
".",
"length",
")",
"{",
"parts",
".",
"pop",
"(",
")",
";",
"}",
"// Handle root '/' error",
"if",
"(",
"!",
"parts",
".",
"length",
")",
"{",
"return",
"callback",
"(",
"new",
"Error",
"(",
"\"No directory path found to make\"",
")",
")",
";",
"}",
"// Make sure each branch is created",
"async",
".",
"mapSeries",
"(",
"parts",
",",
"function",
"(",
"dir",
",",
"callback",
")",
"{",
"fs",
".",
"stat",
"(",
"filepath",
"+=",
"dir",
"+",
"'/'",
",",
"function",
"(",
"e",
",",
"stat",
")",
"{",
"if",
"(",
"stat",
"&&",
"stat",
".",
"isDirectory",
"(",
")",
")",
"{",
"callback",
"(",
")",
";",
"}",
"else",
"{",
"fs",
".",
"mkdir",
"(",
"filepath",
",",
"callback",
")",
";",
"}",
"}",
")",
";",
"}",
",",
"callback",
")",
";",
"}"
] | Creates directory path if not already | [
"Creates",
"directory",
"path",
"if",
"not",
"already"
] | aedf3f31aafc05441970eec49eeeb81174c14033 | https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/render.js#L145-L178 |
|
56,411 | codenothing/munit | lib/render.js | function( path, callback ) {
var match = munit.isRegExp( render.options.file_match ) ? render.options.file_match : rtestfile;
path += '/';
fs.readdir( path, function( e, files ) {
if ( e ) {
return callback( e );
}
async.each( files || [],
function( file, callback ) {
var fullpath = path + file;
fs.stat( fullpath, function( e, stat ) {
if ( e ) {
callback( e );
}
else if ( stat.isDirectory() ) {
render._renderPath( fullpath, callback );
}
else {
if ( stat.isFile() && match.exec( file ) ) {
munit.require( fullpath );
}
callback();
}
});
},
callback
);
});
} | javascript | function( path, callback ) {
var match = munit.isRegExp( render.options.file_match ) ? render.options.file_match : rtestfile;
path += '/';
fs.readdir( path, function( e, files ) {
if ( e ) {
return callback( e );
}
async.each( files || [],
function( file, callback ) {
var fullpath = path + file;
fs.stat( fullpath, function( e, stat ) {
if ( e ) {
callback( e );
}
else if ( stat.isDirectory() ) {
render._renderPath( fullpath, callback );
}
else {
if ( stat.isFile() && match.exec( file ) ) {
munit.require( fullpath );
}
callback();
}
});
},
callback
);
});
} | [
"function",
"(",
"path",
",",
"callback",
")",
"{",
"var",
"match",
"=",
"munit",
".",
"isRegExp",
"(",
"render",
".",
"options",
".",
"file_match",
")",
"?",
"render",
".",
"options",
".",
"file_match",
":",
"rtestfile",
";",
"path",
"+=",
"'/'",
";",
"fs",
".",
"readdir",
"(",
"path",
",",
"function",
"(",
"e",
",",
"files",
")",
"{",
"if",
"(",
"e",
")",
"{",
"return",
"callback",
"(",
"e",
")",
";",
"}",
"async",
".",
"each",
"(",
"files",
"||",
"[",
"]",
",",
"function",
"(",
"file",
",",
"callback",
")",
"{",
"var",
"fullpath",
"=",
"path",
"+",
"file",
";",
"fs",
".",
"stat",
"(",
"fullpath",
",",
"function",
"(",
"e",
",",
"stat",
")",
"{",
"if",
"(",
"e",
")",
"{",
"callback",
"(",
"e",
")",
";",
"}",
"else",
"if",
"(",
"stat",
".",
"isDirectory",
"(",
")",
")",
"{",
"render",
".",
"_renderPath",
"(",
"fullpath",
",",
"callback",
")",
";",
"}",
"else",
"{",
"if",
"(",
"stat",
".",
"isFile",
"(",
")",
"&&",
"match",
".",
"exec",
"(",
"file",
")",
")",
"{",
"munit",
".",
"require",
"(",
"fullpath",
")",
";",
"}",
"callback",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
",",
"callback",
")",
";",
"}",
")",
";",
"}"
] | Loads up each possible test file | [
"Loads",
"up",
"each",
"possible",
"test",
"file"
] | aedf3f31aafc05441970eec49eeeb81174c14033 | https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/render.js#L181-L213 |
|
56,412 | codenothing/munit | lib/render.js | function( nspath ) {
var found = true,
nsparts = nspath.split( rpathsplit ),
focus = render.options.focus;
// Allow single path string
if ( munit.isString( focus ) ) {
focus = [ focus ];
}
// If set, only add modules that belong on the focus path(s)
if ( munit.isArray( focus ) && focus.length ) {
found = false;
focus.forEach(function( fpath ) {
var fparts = fpath.split( rpathsplit ),
i = -1, l = Math.min( fparts.length, nsparts.length );
// Check that each namespace of the focus path
// exists inside the modules path
for ( ; ++i < l; ) {
if ( fparts[ i ] !== nsparts[ i ] ) {
return;
}
}
// Paths line up
found = true;
});
}
return found;
} | javascript | function( nspath ) {
var found = true,
nsparts = nspath.split( rpathsplit ),
focus = render.options.focus;
// Allow single path string
if ( munit.isString( focus ) ) {
focus = [ focus ];
}
// If set, only add modules that belong on the focus path(s)
if ( munit.isArray( focus ) && focus.length ) {
found = false;
focus.forEach(function( fpath ) {
var fparts = fpath.split( rpathsplit ),
i = -1, l = Math.min( fparts.length, nsparts.length );
// Check that each namespace of the focus path
// exists inside the modules path
for ( ; ++i < l; ) {
if ( fparts[ i ] !== nsparts[ i ] ) {
return;
}
}
// Paths line up
found = true;
});
}
return found;
} | [
"function",
"(",
"nspath",
")",
"{",
"var",
"found",
"=",
"true",
",",
"nsparts",
"=",
"nspath",
".",
"split",
"(",
"rpathsplit",
")",
",",
"focus",
"=",
"render",
".",
"options",
".",
"focus",
";",
"// Allow single path string",
"if",
"(",
"munit",
".",
"isString",
"(",
"focus",
")",
")",
"{",
"focus",
"=",
"[",
"focus",
"]",
";",
"}",
"// If set, only add modules that belong on the focus path(s)",
"if",
"(",
"munit",
".",
"isArray",
"(",
"focus",
")",
"&&",
"focus",
".",
"length",
")",
"{",
"found",
"=",
"false",
";",
"focus",
".",
"forEach",
"(",
"function",
"(",
"fpath",
")",
"{",
"var",
"fparts",
"=",
"fpath",
".",
"split",
"(",
"rpathsplit",
")",
",",
"i",
"=",
"-",
"1",
",",
"l",
"=",
"Math",
".",
"min",
"(",
"fparts",
".",
"length",
",",
"nsparts",
".",
"length",
")",
";",
"// Check that each namespace of the focus path",
"// exists inside the modules path",
"for",
"(",
";",
"++",
"i",
"<",
"l",
";",
")",
"{",
"if",
"(",
"fparts",
"[",
"i",
"]",
"!==",
"nsparts",
"[",
"i",
"]",
")",
"{",
"return",
";",
"}",
"}",
"// Paths line up",
"found",
"=",
"true",
";",
"}",
")",
";",
"}",
"return",
"found",
";",
"}"
] | Testing path to see if it exists in the focus option | [
"Testing",
"path",
"to",
"see",
"if",
"it",
"exists",
"in",
"the",
"focus",
"option"
] | aedf3f31aafc05441970eec49eeeb81174c14033 | https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/render.js#L216-L248 |
|
56,413 | codenothing/munit | lib/render.js | function( required, startFunc ) {
if ( required !== render.state ) {
render._stateError( startFunc || render.requireState );
}
} | javascript | function( required, startFunc ) {
if ( required !== render.state ) {
render._stateError( startFunc || render.requireState );
}
} | [
"function",
"(",
"required",
",",
"startFunc",
")",
"{",
"if",
"(",
"required",
"!==",
"render",
".",
"state",
")",
"{",
"render",
".",
"_stateError",
"(",
"startFunc",
"||",
"render",
".",
"requireState",
")",
";",
"}",
"}"
] | Throws an error if munit isn't in the required state | [
"Throws",
"an",
"error",
"if",
"munit",
"isn",
"t",
"in",
"the",
"required",
"state"
] | aedf3f31aafc05441970eec49eeeb81174c14033 | https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/render.js#L265-L269 |
|
56,414 | codenothing/munit | lib/render.js | function( ns ) {
munit.each( ns, function( assert, name ) {
if ( render.focusPath( assert.nsPath ) ) {
munit.tests.push( assert );
}
else {
assert.trigger();
}
// Traverse down the module tree
render._renderNS( assert.ns );
});
return munit.tests;
} | javascript | function( ns ) {
munit.each( ns, function( assert, name ) {
if ( render.focusPath( assert.nsPath ) ) {
munit.tests.push( assert );
}
else {
assert.trigger();
}
// Traverse down the module tree
render._renderNS( assert.ns );
});
return munit.tests;
} | [
"function",
"(",
"ns",
")",
"{",
"munit",
".",
"each",
"(",
"ns",
",",
"function",
"(",
"assert",
",",
"name",
")",
"{",
"if",
"(",
"render",
".",
"focusPath",
"(",
"assert",
".",
"nsPath",
")",
")",
"{",
"munit",
".",
"tests",
".",
"push",
"(",
"assert",
")",
";",
"}",
"else",
"{",
"assert",
".",
"trigger",
"(",
")",
";",
"}",
"// Traverse down the module tree",
"render",
".",
"_renderNS",
"(",
"assert",
".",
"ns",
")",
";",
"}",
")",
";",
"return",
"munit",
".",
"tests",
";",
"}"
] | Renders each module | [
"Renders",
"each",
"module"
] | aedf3f31aafc05441970eec49eeeb81174c14033 | https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/render.js#L286-L300 |
|
56,415 | codenothing/munit | lib/render.js | function( assert ) {
var stack = [], depends, i, l, module;
// Should only be checking dependencies when in compile mode
render.requireMinState( munit.RENDER_STATE_COMPILE, render.checkDepency );
// Build up the list of dependency paths
do {
depends = assert.option( 'depends' );
// Allow single path
if ( munit.isString( depends ) ) {
stack.push( depends );
}
// Add to stack of module dependencies
else if ( munit.isArray( depends ) ) {
stack = stack.concat( depends );
}
} while ( assert = assert.parAssert );
// Check each dependency for completion
for ( i = -1, l = stack.length; ++i < l; ) {
if ( munit( stack[ i ] || '' ).state < munit.ASSERT_STATE_CLOSED ) {
return false;
}
}
return true;
} | javascript | function( assert ) {
var stack = [], depends, i, l, module;
// Should only be checking dependencies when in compile mode
render.requireMinState( munit.RENDER_STATE_COMPILE, render.checkDepency );
// Build up the list of dependency paths
do {
depends = assert.option( 'depends' );
// Allow single path
if ( munit.isString( depends ) ) {
stack.push( depends );
}
// Add to stack of module dependencies
else if ( munit.isArray( depends ) ) {
stack = stack.concat( depends );
}
} while ( assert = assert.parAssert );
// Check each dependency for completion
for ( i = -1, l = stack.length; ++i < l; ) {
if ( munit( stack[ i ] || '' ).state < munit.ASSERT_STATE_CLOSED ) {
return false;
}
}
return true;
} | [
"function",
"(",
"assert",
")",
"{",
"var",
"stack",
"=",
"[",
"]",
",",
"depends",
",",
"i",
",",
"l",
",",
"module",
";",
"// Should only be checking dependencies when in compile mode",
"render",
".",
"requireMinState",
"(",
"munit",
".",
"RENDER_STATE_COMPILE",
",",
"render",
".",
"checkDepency",
")",
";",
"// Build up the list of dependency paths",
"do",
"{",
"depends",
"=",
"assert",
".",
"option",
"(",
"'depends'",
")",
";",
"// Allow single path",
"if",
"(",
"munit",
".",
"isString",
"(",
"depends",
")",
")",
"{",
"stack",
".",
"push",
"(",
"depends",
")",
";",
"}",
"// Add to stack of module dependencies",
"else",
"if",
"(",
"munit",
".",
"isArray",
"(",
"depends",
")",
")",
"{",
"stack",
"=",
"stack",
".",
"concat",
"(",
"depends",
")",
";",
"}",
"}",
"while",
"(",
"assert",
"=",
"assert",
".",
"parAssert",
")",
";",
"// Check each dependency for completion",
"for",
"(",
"i",
"=",
"-",
"1",
",",
"l",
"=",
"stack",
".",
"length",
";",
"++",
"i",
"<",
"l",
";",
")",
"{",
"if",
"(",
"munit",
"(",
"stack",
"[",
"i",
"]",
"||",
"''",
")",
".",
"state",
"<",
"munit",
".",
"ASSERT_STATE_CLOSED",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Checks test modules depencies to see if it can be run | [
"Checks",
"test",
"modules",
"depencies",
"to",
"see",
"if",
"it",
"can",
"be",
"run"
] | aedf3f31aafc05441970eec49eeeb81174c14033 | https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/render.js#L303-L331 |
|
56,416 | codenothing/munit | lib/render.js | function(){
var options = render.options,
path = options.render = render._normalizePath( options.render );
// Ensure render path actually exists
fs.stat( path, function( e, stat ) {
if ( e || ! stat || ! stat.isDirectory() ) {
return munit.exit( 1, e, "'" + path + "' is not a directory" );
}
// Check for root munit config file
fs.exists( path + '/munit.js', function( exists ) {
if ( exists ) {
munit.require( path + '/munit.js' );
}
// Initialize all files in test path for submodule additions
render._renderPath( path, function( e ) {
if ( e ) {
return munit.exit( 1, e, "Unable to render test path" );
}
render._compile();
});
});
});
} | javascript | function(){
var options = render.options,
path = options.render = render._normalizePath( options.render );
// Ensure render path actually exists
fs.stat( path, function( e, stat ) {
if ( e || ! stat || ! stat.isDirectory() ) {
return munit.exit( 1, e, "'" + path + "' is not a directory" );
}
// Check for root munit config file
fs.exists( path + '/munit.js', function( exists ) {
if ( exists ) {
munit.require( path + '/munit.js' );
}
// Initialize all files in test path for submodule additions
render._renderPath( path, function( e ) {
if ( e ) {
return munit.exit( 1, e, "Unable to render test path" );
}
render._compile();
});
});
});
} | [
"function",
"(",
")",
"{",
"var",
"options",
"=",
"render",
".",
"options",
",",
"path",
"=",
"options",
".",
"render",
"=",
"render",
".",
"_normalizePath",
"(",
"options",
".",
"render",
")",
";",
"// Ensure render path actually exists",
"fs",
".",
"stat",
"(",
"path",
",",
"function",
"(",
"e",
",",
"stat",
")",
"{",
"if",
"(",
"e",
"||",
"!",
"stat",
"||",
"!",
"stat",
".",
"isDirectory",
"(",
")",
")",
"{",
"return",
"munit",
".",
"exit",
"(",
"1",
",",
"e",
",",
"\"'\"",
"+",
"path",
"+",
"\"' is not a directory\"",
")",
";",
"}",
"// Check for root munit config file",
"fs",
".",
"exists",
"(",
"path",
"+",
"'/munit.js'",
",",
"function",
"(",
"exists",
")",
"{",
"if",
"(",
"exists",
")",
"{",
"munit",
".",
"require",
"(",
"path",
"+",
"'/munit.js'",
")",
";",
"}",
"// Initialize all files in test path for submodule additions",
"render",
".",
"_renderPath",
"(",
"path",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
")",
"{",
"return",
"munit",
".",
"exit",
"(",
"1",
",",
"e",
",",
"\"Unable to render test path\"",
")",
";",
"}",
"render",
".",
"_compile",
"(",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Setup for rendering a path | [
"Setup",
"for",
"rendering",
"a",
"path"
] | aedf3f31aafc05441970eec49eeeb81174c14033 | https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/render.js#L334-L360 |
|
56,417 | codenothing/munit | lib/render.js | function(){
// Swap render state to compile mode for priority generation
render.requireState( munit.RENDER_STATE_READ, render._compile );
render.state = munit.RENDER_STATE_COMPILE;
render._renderNS( munit.ns );
// Just in case triggers set off any undesired state
render.requireState( munit.RENDER_STATE_COMPILE, render._compile );
render.state = munit.RENDER_STATE_TRIGGER;
// Sort modules on priority
munit.tests.sort(function( a, b ) {
if ( a.options.priority === b.options.priority ) {
return a._added > b._added ? 1 : -1;
}
else {
return a.options.priority > b.options.priority ? -1 : 1;
}
})
// Trigger modules based on priority
.forEach(function( assert ) {
// Stack modules waiting on a queue
if ( assert.options.queue ) {
munit.queue.addModule( assert );
}
else if ( render.checkDepency( assert ) ) {
assert.trigger();
}
});
// All modules triggered, check to see if we can close out
render.state = munit.RENDER_STATE_ACTIVE;
render.check();
} | javascript | function(){
// Swap render state to compile mode for priority generation
render.requireState( munit.RENDER_STATE_READ, render._compile );
render.state = munit.RENDER_STATE_COMPILE;
render._renderNS( munit.ns );
// Just in case triggers set off any undesired state
render.requireState( munit.RENDER_STATE_COMPILE, render._compile );
render.state = munit.RENDER_STATE_TRIGGER;
// Sort modules on priority
munit.tests.sort(function( a, b ) {
if ( a.options.priority === b.options.priority ) {
return a._added > b._added ? 1 : -1;
}
else {
return a.options.priority > b.options.priority ? -1 : 1;
}
})
// Trigger modules based on priority
.forEach(function( assert ) {
// Stack modules waiting on a queue
if ( assert.options.queue ) {
munit.queue.addModule( assert );
}
else if ( render.checkDepency( assert ) ) {
assert.trigger();
}
});
// All modules triggered, check to see if we can close out
render.state = munit.RENDER_STATE_ACTIVE;
render.check();
} | [
"function",
"(",
")",
"{",
"// Swap render state to compile mode for priority generation",
"render",
".",
"requireState",
"(",
"munit",
".",
"RENDER_STATE_READ",
",",
"render",
".",
"_compile",
")",
";",
"render",
".",
"state",
"=",
"munit",
".",
"RENDER_STATE_COMPILE",
";",
"render",
".",
"_renderNS",
"(",
"munit",
".",
"ns",
")",
";",
"// Just in case triggers set off any undesired state",
"render",
".",
"requireState",
"(",
"munit",
".",
"RENDER_STATE_COMPILE",
",",
"render",
".",
"_compile",
")",
";",
"render",
".",
"state",
"=",
"munit",
".",
"RENDER_STATE_TRIGGER",
";",
"// Sort modules on priority",
"munit",
".",
"tests",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"a",
".",
"options",
".",
"priority",
"===",
"b",
".",
"options",
".",
"priority",
")",
"{",
"return",
"a",
".",
"_added",
">",
"b",
".",
"_added",
"?",
"1",
":",
"-",
"1",
";",
"}",
"else",
"{",
"return",
"a",
".",
"options",
".",
"priority",
">",
"b",
".",
"options",
".",
"priority",
"?",
"-",
"1",
":",
"1",
";",
"}",
"}",
")",
"// Trigger modules based on priority",
".",
"forEach",
"(",
"function",
"(",
"assert",
")",
"{",
"// Stack modules waiting on a queue",
"if",
"(",
"assert",
".",
"options",
".",
"queue",
")",
"{",
"munit",
".",
"queue",
".",
"addModule",
"(",
"assert",
")",
";",
"}",
"else",
"if",
"(",
"render",
".",
"checkDepency",
"(",
"assert",
")",
")",
"{",
"assert",
".",
"trigger",
"(",
")",
";",
"}",
"}",
")",
";",
"// All modules triggered, check to see if we can close out",
"render",
".",
"state",
"=",
"munit",
".",
"RENDER_STATE_ACTIVE",
";",
"render",
".",
"check",
"(",
")",
";",
"}"
] | Triggered after all file paths have been loaded | [
"Triggered",
"after",
"all",
"file",
"paths",
"have",
"been",
"loaded"
] | aedf3f31aafc05441970eec49eeeb81174c14033 | https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/render.js#L363-L396 |
|
56,418 | codenothing/munit | lib/render.js | function(){
var color = munit.color.get[ munit.failed > 0 ? 'red' : 'green' ],
callback = render.callback;
// Can only complete a finished munit state
// (dont pass startFunc, we want _complete as part of the trace here)
render.requireState( munit.RENDER_STATE_FINISHED );
render.state = munit.RENDER_STATE_COMPLETE;
// Print out final results
munit.log([
"\n",
color( "Tests Passed: " + munit.passed ),
color( "Tests Failed: " + munit.failed ),
color( "Tests Skipped: " + munit.skipped ),
color( "Time: " + munit._relativeTime( munit.end - munit.start ) ),
"\n"
].join( "\n" ));
// Only exit if there is an error (callback will be triggered there)
if ( munit.failed > 0 ) {
munit.exit( 1, "Test failed with " + munit.failed + " errors" );
}
// Trigger callback if provided
else if ( callback ) {
render.callback = undefined;
callback( null, munit );
}
} | javascript | function(){
var color = munit.color.get[ munit.failed > 0 ? 'red' : 'green' ],
callback = render.callback;
// Can only complete a finished munit state
// (dont pass startFunc, we want _complete as part of the trace here)
render.requireState( munit.RENDER_STATE_FINISHED );
render.state = munit.RENDER_STATE_COMPLETE;
// Print out final results
munit.log([
"\n",
color( "Tests Passed: " + munit.passed ),
color( "Tests Failed: " + munit.failed ),
color( "Tests Skipped: " + munit.skipped ),
color( "Time: " + munit._relativeTime( munit.end - munit.start ) ),
"\n"
].join( "\n" ));
// Only exit if there is an error (callback will be triggered there)
if ( munit.failed > 0 ) {
munit.exit( 1, "Test failed with " + munit.failed + " errors" );
}
// Trigger callback if provided
else if ( callback ) {
render.callback = undefined;
callback( null, munit );
}
} | [
"function",
"(",
")",
"{",
"var",
"color",
"=",
"munit",
".",
"color",
".",
"get",
"[",
"munit",
".",
"failed",
">",
"0",
"?",
"'red'",
":",
"'green'",
"]",
",",
"callback",
"=",
"render",
".",
"callback",
";",
"// Can only complete a finished munit state",
"// (dont pass startFunc, we want _complete as part of the trace here)",
"render",
".",
"requireState",
"(",
"munit",
".",
"RENDER_STATE_FINISHED",
")",
";",
"render",
".",
"state",
"=",
"munit",
".",
"RENDER_STATE_COMPLETE",
";",
"// Print out final results",
"munit",
".",
"log",
"(",
"[",
"\"\\n\"",
",",
"color",
"(",
"\"Tests Passed: \"",
"+",
"munit",
".",
"passed",
")",
",",
"color",
"(",
"\"Tests Failed: \"",
"+",
"munit",
".",
"failed",
")",
",",
"color",
"(",
"\"Tests Skipped: \"",
"+",
"munit",
".",
"skipped",
")",
",",
"color",
"(",
"\"Time: \"",
"+",
"munit",
".",
"_relativeTime",
"(",
"munit",
".",
"end",
"-",
"munit",
".",
"start",
")",
")",
",",
"\"\\n\"",
"]",
".",
"join",
"(",
"\"\\n\"",
")",
")",
";",
"// Only exit if there is an error (callback will be triggered there)",
"if",
"(",
"munit",
".",
"failed",
">",
"0",
")",
"{",
"munit",
".",
"exit",
"(",
"1",
",",
"\"Test failed with \"",
"+",
"munit",
".",
"failed",
"+",
"\" errors\"",
")",
";",
"}",
"// Trigger callback if provided",
"else",
"if",
"(",
"callback",
")",
"{",
"render",
".",
"callback",
"=",
"undefined",
";",
"callback",
"(",
"null",
",",
"munit",
")",
";",
"}",
"}"
] | Finished off test result writing, print out suite results | [
"Finished",
"off",
"test",
"result",
"writing",
"print",
"out",
"suite",
"results"
] | aedf3f31aafc05441970eec49eeeb81174c14033 | https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/render.js#L399-L427 |
|
56,419 | codenothing/munit | lib/render.js | function( dir ) {
// Make the root results directory first
render._mkdir( dir, function( e ) {
if ( e ) {
return munit.exit( 1, e, "Failed to make root results directory" );
}
// Make a working directory for each format
async.each( render._formats,
function( format, callback ) {
var path = dir + format.name + '/';
render._mkdir( path, function( e ) {
if ( e ) {
callback( e );
}
else {
format.callback( path, callback );
}
});
},
function( e ) {
if ( e ) {
munit.exit( 1, e );
}
else {
render._complete();
}
}
);
});
} | javascript | function( dir ) {
// Make the root results directory first
render._mkdir( dir, function( e ) {
if ( e ) {
return munit.exit( 1, e, "Failed to make root results directory" );
}
// Make a working directory for each format
async.each( render._formats,
function( format, callback ) {
var path = dir + format.name + '/';
render._mkdir( path, function( e ) {
if ( e ) {
callback( e );
}
else {
format.callback( path, callback );
}
});
},
function( e ) {
if ( e ) {
munit.exit( 1, e );
}
else {
render._complete();
}
}
);
});
} | [
"function",
"(",
"dir",
")",
"{",
"// Make the root results directory first",
"render",
".",
"_mkdir",
"(",
"dir",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
")",
"{",
"return",
"munit",
".",
"exit",
"(",
"1",
",",
"e",
",",
"\"Failed to make root results directory\"",
")",
";",
"}",
"// Make a working directory for each format",
"async",
".",
"each",
"(",
"render",
".",
"_formats",
",",
"function",
"(",
"format",
",",
"callback",
")",
"{",
"var",
"path",
"=",
"dir",
"+",
"format",
".",
"name",
"+",
"'/'",
";",
"render",
".",
"_mkdir",
"(",
"path",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
")",
"{",
"callback",
"(",
"e",
")",
";",
"}",
"else",
"{",
"format",
".",
"callback",
"(",
"path",
",",
"callback",
")",
";",
"}",
"}",
")",
";",
"}",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
")",
"{",
"munit",
".",
"exit",
"(",
"1",
",",
"e",
")",
";",
"}",
"else",
"{",
"render",
".",
"_complete",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}"
] | Generates result directories | [
"Generates",
"result",
"directories"
] | aedf3f31aafc05441970eec49eeeb81174c14033 | https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/render.js#L430-L461 |
|
56,420 | codenothing/munit | lib/render.js | function(){
var finished = true,
now = Date.now(),
options = render.options,
results = options.results ? render._normalizePath( options.results ) : null;
// Wait until all modules have been triggered before checking states
if ( render.state < munit.RENDER_STATE_ACTIVE ) {
return;
}
// Can only check an active munit
render.requireState( munit.RENDER_STATE_ACTIVE, render.check );
// Check each module
munit.each( munit.ns, function( mod, name ) {
if ( mod.state < munit.ASSERT_STATE_FINISHED ) {
return ( finished = false );
}
});
// Check dependency chains if test suite isn't yet finished
if ( ! finished ) {
munit.queue.check();
// Check each untriggered module to see if it's dependencies have been closed
munit.tests.forEach(function( assert ) {
if ( assert.state === munit.ASSERT_STATE_DEFAULT && ! assert.option( 'queue' ) && render.checkDepency( assert ) ) {
assert.trigger();
}
});
}
// Only flush full results once all modules have completed
else {
render.state = munit.RENDER_STATE_FINISHED;
munit.end = now;
// Print out test results
if ( results && results.length ) {
render._renderResults( results + '/' );
}
else {
render._complete();
}
}
} | javascript | function(){
var finished = true,
now = Date.now(),
options = render.options,
results = options.results ? render._normalizePath( options.results ) : null;
// Wait until all modules have been triggered before checking states
if ( render.state < munit.RENDER_STATE_ACTIVE ) {
return;
}
// Can only check an active munit
render.requireState( munit.RENDER_STATE_ACTIVE, render.check );
// Check each module
munit.each( munit.ns, function( mod, name ) {
if ( mod.state < munit.ASSERT_STATE_FINISHED ) {
return ( finished = false );
}
});
// Check dependency chains if test suite isn't yet finished
if ( ! finished ) {
munit.queue.check();
// Check each untriggered module to see if it's dependencies have been closed
munit.tests.forEach(function( assert ) {
if ( assert.state === munit.ASSERT_STATE_DEFAULT && ! assert.option( 'queue' ) && render.checkDepency( assert ) ) {
assert.trigger();
}
});
}
// Only flush full results once all modules have completed
else {
render.state = munit.RENDER_STATE_FINISHED;
munit.end = now;
// Print out test results
if ( results && results.length ) {
render._renderResults( results + '/' );
}
else {
render._complete();
}
}
} | [
"function",
"(",
")",
"{",
"var",
"finished",
"=",
"true",
",",
"now",
"=",
"Date",
".",
"now",
"(",
")",
",",
"options",
"=",
"render",
".",
"options",
",",
"results",
"=",
"options",
".",
"results",
"?",
"render",
".",
"_normalizePath",
"(",
"options",
".",
"results",
")",
":",
"null",
";",
"// Wait until all modules have been triggered before checking states",
"if",
"(",
"render",
".",
"state",
"<",
"munit",
".",
"RENDER_STATE_ACTIVE",
")",
"{",
"return",
";",
"}",
"// Can only check an active munit",
"render",
".",
"requireState",
"(",
"munit",
".",
"RENDER_STATE_ACTIVE",
",",
"render",
".",
"check",
")",
";",
"// Check each module",
"munit",
".",
"each",
"(",
"munit",
".",
"ns",
",",
"function",
"(",
"mod",
",",
"name",
")",
"{",
"if",
"(",
"mod",
".",
"state",
"<",
"munit",
".",
"ASSERT_STATE_FINISHED",
")",
"{",
"return",
"(",
"finished",
"=",
"false",
")",
";",
"}",
"}",
")",
";",
"// Check dependency chains if test suite isn't yet finished",
"if",
"(",
"!",
"finished",
")",
"{",
"munit",
".",
"queue",
".",
"check",
"(",
")",
";",
"// Check each untriggered module to see if it's dependencies have been closed",
"munit",
".",
"tests",
".",
"forEach",
"(",
"function",
"(",
"assert",
")",
"{",
"if",
"(",
"assert",
".",
"state",
"===",
"munit",
".",
"ASSERT_STATE_DEFAULT",
"&&",
"!",
"assert",
".",
"option",
"(",
"'queue'",
")",
"&&",
"render",
".",
"checkDepency",
"(",
"assert",
")",
")",
"{",
"assert",
".",
"trigger",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
"// Only flush full results once all modules have completed",
"else",
"{",
"render",
".",
"state",
"=",
"munit",
".",
"RENDER_STATE_FINISHED",
";",
"munit",
".",
"end",
"=",
"now",
";",
"// Print out test results",
"if",
"(",
"results",
"&&",
"results",
".",
"length",
")",
"{",
"render",
".",
"_renderResults",
"(",
"results",
"+",
"'/'",
")",
";",
"}",
"else",
"{",
"render",
".",
"_complete",
"(",
")",
";",
"}",
"}",
"}"
] | Checks all modules to see if they are finished | [
"Checks",
"all",
"modules",
"to",
"see",
"if",
"they",
"are",
"finished"
] | aedf3f31aafc05441970eec49eeeb81174c14033 | https://github.com/codenothing/munit/blob/aedf3f31aafc05441970eec49eeeb81174c14033/lib/render.js#L464-L509 |
|
56,421 | mgesmundo/authorify-client | build/authorify.js | function(api, id, key, data) {
// get storage object
var obj = _getStorageObject(api, id);
if(obj === null) {
// create a new storage object
obj = {};
}
// update key
obj[key] = data;
// set storage object
_setStorageObject(api, id, obj);
} | javascript | function(api, id, key, data) {
// get storage object
var obj = _getStorageObject(api, id);
if(obj === null) {
// create a new storage object
obj = {};
}
// update key
obj[key] = data;
// set storage object
_setStorageObject(api, id, obj);
} | [
"function",
"(",
"api",
",",
"id",
",",
"key",
",",
"data",
")",
"{",
"// get storage object",
"var",
"obj",
"=",
"_getStorageObject",
"(",
"api",
",",
"id",
")",
";",
"if",
"(",
"obj",
"===",
"null",
")",
"{",
"// create a new storage object",
"obj",
"=",
"{",
"}",
";",
"}",
"// update key",
"obj",
"[",
"key",
"]",
"=",
"data",
";",
"// set storage object",
"_setStorageObject",
"(",
"api",
",",
"id",
",",
"obj",
")",
";",
"}"
] | Stores an item in local storage.
@param api the storage interface.
@param id the storage ID to use.
@param key the key for the item.
@param data the data for the item (any javascript object/primitive). | [
"Stores",
"an",
"item",
"in",
"local",
"storage",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L1420-L1432 |
|
56,422 | mgesmundo/authorify-client | build/authorify.js | function(api, id, key) {
// get storage object
var rval = _getStorageObject(api, id);
if(rval !== null) {
// return data at key
rval = (key in rval) ? rval[key] : null;
}
return rval;
} | javascript | function(api, id, key) {
// get storage object
var rval = _getStorageObject(api, id);
if(rval !== null) {
// return data at key
rval = (key in rval) ? rval[key] : null;
}
return rval;
} | [
"function",
"(",
"api",
",",
"id",
",",
"key",
")",
"{",
"// get storage object",
"var",
"rval",
"=",
"_getStorageObject",
"(",
"api",
",",
"id",
")",
";",
"if",
"(",
"rval",
"!==",
"null",
")",
"{",
"// return data at key",
"rval",
"=",
"(",
"key",
"in",
"rval",
")",
"?",
"rval",
"[",
"key",
"]",
":",
"null",
";",
"}",
"return",
"rval",
";",
"}"
] | Gets an item from local storage.
@param api the storage interface.
@param id the storage ID to use.
@param key the key for the item.
@return the item. | [
"Gets",
"an",
"item",
"from",
"local",
"storage",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L1443-L1452 |
|
56,423 | mgesmundo/authorify-client | build/authorify.js | function(api, id, key) {
// get storage object
var obj = _getStorageObject(api, id);
if(obj !== null && key in obj) {
// remove key
delete obj[key];
// see if entry has no keys remaining
var empty = true;
for(var prop in obj) {
empty = false;
break;
}
if(empty) {
// remove entry entirely if no keys are left
obj = null;
}
// set storage object
_setStorageObject(api, id, obj);
}
} | javascript | function(api, id, key) {
// get storage object
var obj = _getStorageObject(api, id);
if(obj !== null && key in obj) {
// remove key
delete obj[key];
// see if entry has no keys remaining
var empty = true;
for(var prop in obj) {
empty = false;
break;
}
if(empty) {
// remove entry entirely if no keys are left
obj = null;
}
// set storage object
_setStorageObject(api, id, obj);
}
} | [
"function",
"(",
"api",
",",
"id",
",",
"key",
")",
"{",
"// get storage object",
"var",
"obj",
"=",
"_getStorageObject",
"(",
"api",
",",
"id",
")",
";",
"if",
"(",
"obj",
"!==",
"null",
"&&",
"key",
"in",
"obj",
")",
"{",
"// remove key",
"delete",
"obj",
"[",
"key",
"]",
";",
"// see if entry has no keys remaining",
"var",
"empty",
"=",
"true",
";",
"for",
"(",
"var",
"prop",
"in",
"obj",
")",
"{",
"empty",
"=",
"false",
";",
"break",
";",
"}",
"if",
"(",
"empty",
")",
"{",
"// remove entry entirely if no keys are left",
"obj",
"=",
"null",
";",
"}",
"// set storage object",
"_setStorageObject",
"(",
"api",
",",
"id",
",",
"obj",
")",
";",
"}",
"}"
] | Removes an item from local storage.
@param api the storage interface.
@param id the storage ID to use.
@param key the key for the item. | [
"Removes",
"an",
"item",
"from",
"local",
"storage",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L1461-L1482 |
|
56,424 | mgesmundo/authorify-client | build/authorify.js | function(func, args, location) {
var rval = null;
// default storage types
if(typeof(location) === 'undefined') {
location = ['web', 'flash'];
}
// apply storage types in order of preference
var type;
var done = false;
var exception = null;
for(var idx in location) {
type = location[idx];
try {
if(type === 'flash' || type === 'both') {
if(args[0] === null) {
throw new Error('Flash local storage not available.');
} else {
rval = func.apply(this, args);
done = (type === 'flash');
}
}
if(type === 'web' || type === 'both') {
args[0] = localStorage;
rval = func.apply(this, args);
done = true;
}
} catch(ex) {
exception = ex;
}
if(done) {
break;
}
}
if(!done) {
throw exception;
}
return rval;
} | javascript | function(func, args, location) {
var rval = null;
// default storage types
if(typeof(location) === 'undefined') {
location = ['web', 'flash'];
}
// apply storage types in order of preference
var type;
var done = false;
var exception = null;
for(var idx in location) {
type = location[idx];
try {
if(type === 'flash' || type === 'both') {
if(args[0] === null) {
throw new Error('Flash local storage not available.');
} else {
rval = func.apply(this, args);
done = (type === 'flash');
}
}
if(type === 'web' || type === 'both') {
args[0] = localStorage;
rval = func.apply(this, args);
done = true;
}
} catch(ex) {
exception = ex;
}
if(done) {
break;
}
}
if(!done) {
throw exception;
}
return rval;
} | [
"function",
"(",
"func",
",",
"args",
",",
"location",
")",
"{",
"var",
"rval",
"=",
"null",
";",
"// default storage types",
"if",
"(",
"typeof",
"(",
"location",
")",
"===",
"'undefined'",
")",
"{",
"location",
"=",
"[",
"'web'",
",",
"'flash'",
"]",
";",
"}",
"// apply storage types in order of preference",
"var",
"type",
";",
"var",
"done",
"=",
"false",
";",
"var",
"exception",
"=",
"null",
";",
"for",
"(",
"var",
"idx",
"in",
"location",
")",
"{",
"type",
"=",
"location",
"[",
"idx",
"]",
";",
"try",
"{",
"if",
"(",
"type",
"===",
"'flash'",
"||",
"type",
"===",
"'both'",
")",
"{",
"if",
"(",
"args",
"[",
"0",
"]",
"===",
"null",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Flash local storage not available.'",
")",
";",
"}",
"else",
"{",
"rval",
"=",
"func",
".",
"apply",
"(",
"this",
",",
"args",
")",
";",
"done",
"=",
"(",
"type",
"===",
"'flash'",
")",
";",
"}",
"}",
"if",
"(",
"type",
"===",
"'web'",
"||",
"type",
"===",
"'both'",
")",
"{",
"args",
"[",
"0",
"]",
"=",
"localStorage",
";",
"rval",
"=",
"func",
".",
"apply",
"(",
"this",
",",
"args",
")",
";",
"done",
"=",
"true",
";",
"}",
"}",
"catch",
"(",
"ex",
")",
"{",
"exception",
"=",
"ex",
";",
"}",
"if",
"(",
"done",
")",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"done",
")",
"{",
"throw",
"exception",
";",
"}",
"return",
"rval",
";",
"}"
] | Calls a storage function.
@param func the function to call.
@param args the arguments for the function.
@param location the location argument.
@return the return value from the function. | [
"Calls",
"a",
"storage",
"function",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L1503-L1544 |
|
56,425 | mgesmundo/authorify-client | build/authorify.js | function(b) {
var b2 = b.getByte();
if(b2 === 0x80) {
return undefined;
}
// see if the length is "short form" or "long form" (bit 8 set)
var length;
var longForm = b2 & 0x80;
if(!longForm) {
// length is just the first byte
length = b2;
} else {
// the number of bytes the length is specified in bits 7 through 1
// and each length byte is in big-endian base-256
length = b.getInt((b2 & 0x7F) << 3);
}
return length;
} | javascript | function(b) {
var b2 = b.getByte();
if(b2 === 0x80) {
return undefined;
}
// see if the length is "short form" or "long form" (bit 8 set)
var length;
var longForm = b2 & 0x80;
if(!longForm) {
// length is just the first byte
length = b2;
} else {
// the number of bytes the length is specified in bits 7 through 1
// and each length byte is in big-endian base-256
length = b.getInt((b2 & 0x7F) << 3);
}
return length;
} | [
"function",
"(",
"b",
")",
"{",
"var",
"b2",
"=",
"b",
".",
"getByte",
"(",
")",
";",
"if",
"(",
"b2",
"===",
"0x80",
")",
"{",
"return",
"undefined",
";",
"}",
"// see if the length is \"short form\" or \"long form\" (bit 8 set)",
"var",
"length",
";",
"var",
"longForm",
"=",
"b2",
"&",
"0x80",
";",
"if",
"(",
"!",
"longForm",
")",
"{",
"// length is just the first byte",
"length",
"=",
"b2",
";",
"}",
"else",
"{",
"// the number of bytes the length is specified in bits 7 through 1",
"// and each length byte is in big-endian base-256",
"length",
"=",
"b",
".",
"getInt",
"(",
"(",
"b2",
"&",
"0x7F",
")",
"<<",
"3",
")",
";",
"}",
"return",
"length",
";",
"}"
] | Gets the length of an ASN.1 value.
In case the length is not specified, undefined is returned.
@param b the ASN.1 byte buffer.
@return the length of the ASN.1 value. | [
"Gets",
"the",
"length",
"of",
"an",
"ASN",
".",
"1",
"value",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L5142-L5160 |
|
56,426 | mgesmundo/authorify-client | build/authorify.js | _reseedSync | function _reseedSync() {
if(ctx.pools[0].messageLength >= 32) {
return _seed();
}
// not enough seed data...
var needed = (32 - ctx.pools[0].messageLength) << 5;
ctx.collect(ctx.seedFileSync(needed));
_seed();
} | javascript | function _reseedSync() {
if(ctx.pools[0].messageLength >= 32) {
return _seed();
}
// not enough seed data...
var needed = (32 - ctx.pools[0].messageLength) << 5;
ctx.collect(ctx.seedFileSync(needed));
_seed();
} | [
"function",
"_reseedSync",
"(",
")",
"{",
"if",
"(",
"ctx",
".",
"pools",
"[",
"0",
"]",
".",
"messageLength",
">=",
"32",
")",
"{",
"return",
"_seed",
"(",
")",
";",
"}",
"// not enough seed data...",
"var",
"needed",
"=",
"(",
"32",
"-",
"ctx",
".",
"pools",
"[",
"0",
"]",
".",
"messageLength",
")",
"<<",
"5",
";",
"ctx",
".",
"collect",
"(",
"ctx",
".",
"seedFileSync",
"(",
"needed",
")",
")",
";",
"_seed",
"(",
")",
";",
"}"
] | Private function that synchronously reseeds a generator. | [
"Private",
"function",
"that",
"synchronously",
"reseeds",
"a",
"generator",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L9113-L9121 |
56,427 | mgesmundo/authorify-client | build/authorify.js | _seed | function _seed() {
// create a plugin-based message digest
var md = ctx.plugin.md.create();
// digest pool 0's entropy and restart it
md.update(ctx.pools[0].digest().getBytes());
ctx.pools[0].start();
// digest the entropy of other pools whose index k meet the
// condition '2^k mod n == 0' where n is the number of reseeds
var k = 1;
for(var i = 1; i < 32; ++i) {
// prevent signed numbers from being used
k = (k === 31) ? 0x80000000 : (k << 2);
if(k % ctx.reseeds === 0) {
md.update(ctx.pools[i].digest().getBytes());
ctx.pools[i].start();
}
}
// get digest for key bytes and iterate again for seed bytes
var keyBytes = md.digest().getBytes();
md.start();
md.update(keyBytes);
var seedBytes = md.digest().getBytes();
// update
ctx.key = ctx.plugin.formatKey(keyBytes);
ctx.seed = ctx.plugin.formatSeed(seedBytes);
ctx.reseeds = (ctx.reseeds === 0xffffffff) ? 0 : ctx.reseeds + 1;
ctx.generated = 0;
} | javascript | function _seed() {
// create a plugin-based message digest
var md = ctx.plugin.md.create();
// digest pool 0's entropy and restart it
md.update(ctx.pools[0].digest().getBytes());
ctx.pools[0].start();
// digest the entropy of other pools whose index k meet the
// condition '2^k mod n == 0' where n is the number of reseeds
var k = 1;
for(var i = 1; i < 32; ++i) {
// prevent signed numbers from being used
k = (k === 31) ? 0x80000000 : (k << 2);
if(k % ctx.reseeds === 0) {
md.update(ctx.pools[i].digest().getBytes());
ctx.pools[i].start();
}
}
// get digest for key bytes and iterate again for seed bytes
var keyBytes = md.digest().getBytes();
md.start();
md.update(keyBytes);
var seedBytes = md.digest().getBytes();
// update
ctx.key = ctx.plugin.formatKey(keyBytes);
ctx.seed = ctx.plugin.formatSeed(seedBytes);
ctx.reseeds = (ctx.reseeds === 0xffffffff) ? 0 : ctx.reseeds + 1;
ctx.generated = 0;
} | [
"function",
"_seed",
"(",
")",
"{",
"// create a plugin-based message digest",
"var",
"md",
"=",
"ctx",
".",
"plugin",
".",
"md",
".",
"create",
"(",
")",
";",
"// digest pool 0's entropy and restart it",
"md",
".",
"update",
"(",
"ctx",
".",
"pools",
"[",
"0",
"]",
".",
"digest",
"(",
")",
".",
"getBytes",
"(",
")",
")",
";",
"ctx",
".",
"pools",
"[",
"0",
"]",
".",
"start",
"(",
")",
";",
"// digest the entropy of other pools whose index k meet the",
"// condition '2^k mod n == 0' where n is the number of reseeds",
"var",
"k",
"=",
"1",
";",
"for",
"(",
"var",
"i",
"=",
"1",
";",
"i",
"<",
"32",
";",
"++",
"i",
")",
"{",
"// prevent signed numbers from being used",
"k",
"=",
"(",
"k",
"===",
"31",
")",
"?",
"0x80000000",
":",
"(",
"k",
"<<",
"2",
")",
";",
"if",
"(",
"k",
"%",
"ctx",
".",
"reseeds",
"===",
"0",
")",
"{",
"md",
".",
"update",
"(",
"ctx",
".",
"pools",
"[",
"i",
"]",
".",
"digest",
"(",
")",
".",
"getBytes",
"(",
")",
")",
";",
"ctx",
".",
"pools",
"[",
"i",
"]",
".",
"start",
"(",
")",
";",
"}",
"}",
"// get digest for key bytes and iterate again for seed bytes",
"var",
"keyBytes",
"=",
"md",
".",
"digest",
"(",
")",
".",
"getBytes",
"(",
")",
";",
"md",
".",
"start",
"(",
")",
";",
"md",
".",
"update",
"(",
"keyBytes",
")",
";",
"var",
"seedBytes",
"=",
"md",
".",
"digest",
"(",
")",
".",
"getBytes",
"(",
")",
";",
"// update",
"ctx",
".",
"key",
"=",
"ctx",
".",
"plugin",
".",
"formatKey",
"(",
"keyBytes",
")",
";",
"ctx",
".",
"seed",
"=",
"ctx",
".",
"plugin",
".",
"formatSeed",
"(",
"seedBytes",
")",
";",
"ctx",
".",
"reseeds",
"=",
"(",
"ctx",
".",
"reseeds",
"===",
"0xffffffff",
")",
"?",
"0",
":",
"ctx",
".",
"reseeds",
"+",
"1",
";",
"ctx",
".",
"generated",
"=",
"0",
";",
"}"
] | Private function that seeds a generator once enough bytes are available. | [
"Private",
"function",
"that",
"seeds",
"a",
"generator",
"once",
"enough",
"bytes",
"are",
"available",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L9126-L9157 |
56,428 | mgesmundo/authorify-client | build/authorify.js | defaultSeedFile | function defaultSeedFile(needed) {
// use window.crypto.getRandomValues strong source of entropy if available
var getRandomValues = null;
if(typeof window !== 'undefined') {
var _crypto = window.crypto || window.msCrypto;
if(_crypto && _crypto.getRandomValues) {
getRandomValues = function(arr) {
return _crypto.getRandomValues(arr);
};
}
}
var b = forge.util.createBuffer();
if(getRandomValues) {
while(b.length() < needed) {
// max byte length is 65536 before QuotaExceededError is thrown
// http://www.w3.org/TR/WebCryptoAPI/#RandomSource-method-getRandomValues
var count = Math.max(1, Math.min(needed - b.length(), 65536) / 4);
var entropy = new Uint32Array(Math.floor(count));
try {
getRandomValues(entropy);
for(var i = 0; i < entropy.length; ++i) {
b.putInt32(entropy[i]);
}
} catch(e) {
/* only ignore QuotaExceededError */
if(!(typeof QuotaExceededError !== 'undefined' &&
e instanceof QuotaExceededError)) {
throw e;
}
}
}
}
// be sad and add some weak random data
if(b.length() < needed) {
/* Draws from Park-Miller "minimal standard" 31 bit PRNG,
implemented with David G. Carta's optimization: with 32 bit math
and without division (Public Domain). */
var hi, lo, next;
var seed = Math.floor(Math.random() * 0x010000);
while(b.length() < needed) {
lo = 16807 * (seed & 0xFFFF);
hi = 16807 * (seed >> 16);
lo += (hi & 0x7FFF) << 16;
lo += hi >> 15;
lo = (lo & 0x7FFFFFFF) + (lo >> 31);
seed = lo & 0xFFFFFFFF;
// consume lower 3 bytes of seed
for(var i = 0; i < 3; ++i) {
// throw in more pseudo random
next = seed >>> (i << 3);
next ^= Math.floor(Math.random() * 0x0100);
b.putByte(String.fromCharCode(next & 0xFF));
}
}
}
return b.getBytes(needed);
} | javascript | function defaultSeedFile(needed) {
// use window.crypto.getRandomValues strong source of entropy if available
var getRandomValues = null;
if(typeof window !== 'undefined') {
var _crypto = window.crypto || window.msCrypto;
if(_crypto && _crypto.getRandomValues) {
getRandomValues = function(arr) {
return _crypto.getRandomValues(arr);
};
}
}
var b = forge.util.createBuffer();
if(getRandomValues) {
while(b.length() < needed) {
// max byte length is 65536 before QuotaExceededError is thrown
// http://www.w3.org/TR/WebCryptoAPI/#RandomSource-method-getRandomValues
var count = Math.max(1, Math.min(needed - b.length(), 65536) / 4);
var entropy = new Uint32Array(Math.floor(count));
try {
getRandomValues(entropy);
for(var i = 0; i < entropy.length; ++i) {
b.putInt32(entropy[i]);
}
} catch(e) {
/* only ignore QuotaExceededError */
if(!(typeof QuotaExceededError !== 'undefined' &&
e instanceof QuotaExceededError)) {
throw e;
}
}
}
}
// be sad and add some weak random data
if(b.length() < needed) {
/* Draws from Park-Miller "minimal standard" 31 bit PRNG,
implemented with David G. Carta's optimization: with 32 bit math
and without division (Public Domain). */
var hi, lo, next;
var seed = Math.floor(Math.random() * 0x010000);
while(b.length() < needed) {
lo = 16807 * (seed & 0xFFFF);
hi = 16807 * (seed >> 16);
lo += (hi & 0x7FFF) << 16;
lo += hi >> 15;
lo = (lo & 0x7FFFFFFF) + (lo >> 31);
seed = lo & 0xFFFFFFFF;
// consume lower 3 bytes of seed
for(var i = 0; i < 3; ++i) {
// throw in more pseudo random
next = seed >>> (i << 3);
next ^= Math.floor(Math.random() * 0x0100);
b.putByte(String.fromCharCode(next & 0xFF));
}
}
}
return b.getBytes(needed);
} | [
"function",
"defaultSeedFile",
"(",
"needed",
")",
"{",
"// use window.crypto.getRandomValues strong source of entropy if available",
"var",
"getRandomValues",
"=",
"null",
";",
"if",
"(",
"typeof",
"window",
"!==",
"'undefined'",
")",
"{",
"var",
"_crypto",
"=",
"window",
".",
"crypto",
"||",
"window",
".",
"msCrypto",
";",
"if",
"(",
"_crypto",
"&&",
"_crypto",
".",
"getRandomValues",
")",
"{",
"getRandomValues",
"=",
"function",
"(",
"arr",
")",
"{",
"return",
"_crypto",
".",
"getRandomValues",
"(",
"arr",
")",
";",
"}",
";",
"}",
"}",
"var",
"b",
"=",
"forge",
".",
"util",
".",
"createBuffer",
"(",
")",
";",
"if",
"(",
"getRandomValues",
")",
"{",
"while",
"(",
"b",
".",
"length",
"(",
")",
"<",
"needed",
")",
"{",
"// max byte length is 65536 before QuotaExceededError is thrown",
"// http://www.w3.org/TR/WebCryptoAPI/#RandomSource-method-getRandomValues",
"var",
"count",
"=",
"Math",
".",
"max",
"(",
"1",
",",
"Math",
".",
"min",
"(",
"needed",
"-",
"b",
".",
"length",
"(",
")",
",",
"65536",
")",
"/",
"4",
")",
";",
"var",
"entropy",
"=",
"new",
"Uint32Array",
"(",
"Math",
".",
"floor",
"(",
"count",
")",
")",
";",
"try",
"{",
"getRandomValues",
"(",
"entropy",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"entropy",
".",
"length",
";",
"++",
"i",
")",
"{",
"b",
".",
"putInt32",
"(",
"entropy",
"[",
"i",
"]",
")",
";",
"}",
"}",
"catch",
"(",
"e",
")",
"{",
"/* only ignore QuotaExceededError */",
"if",
"(",
"!",
"(",
"typeof",
"QuotaExceededError",
"!==",
"'undefined'",
"&&",
"e",
"instanceof",
"QuotaExceededError",
")",
")",
"{",
"throw",
"e",
";",
"}",
"}",
"}",
"}",
"// be sad and add some weak random data",
"if",
"(",
"b",
".",
"length",
"(",
")",
"<",
"needed",
")",
"{",
"/* Draws from Park-Miller \"minimal standard\" 31 bit PRNG,\n implemented with David G. Carta's optimization: with 32 bit math\n and without division (Public Domain). */",
"var",
"hi",
",",
"lo",
",",
"next",
";",
"var",
"seed",
"=",
"Math",
".",
"floor",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"0x010000",
")",
";",
"while",
"(",
"b",
".",
"length",
"(",
")",
"<",
"needed",
")",
"{",
"lo",
"=",
"16807",
"*",
"(",
"seed",
"&",
"0xFFFF",
")",
";",
"hi",
"=",
"16807",
"*",
"(",
"seed",
">>",
"16",
")",
";",
"lo",
"+=",
"(",
"hi",
"&",
"0x7FFF",
")",
"<<",
"16",
";",
"lo",
"+=",
"hi",
">>",
"15",
";",
"lo",
"=",
"(",
"lo",
"&",
"0x7FFFFFFF",
")",
"+",
"(",
"lo",
">>",
"31",
")",
";",
"seed",
"=",
"lo",
"&",
"0xFFFFFFFF",
";",
"// consume lower 3 bytes of seed",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"++",
"i",
")",
"{",
"// throw in more pseudo random",
"next",
"=",
"seed",
">>>",
"(",
"i",
"<<",
"3",
")",
";",
"next",
"^=",
"Math",
".",
"floor",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"0x0100",
")",
";",
"b",
".",
"putByte",
"(",
"String",
".",
"fromCharCode",
"(",
"next",
"&",
"0xFF",
")",
")",
";",
"}",
"}",
"}",
"return",
"b",
".",
"getBytes",
"(",
"needed",
")",
";",
"}"
] | The built-in default seedFile. This seedFile is used when entropy
is needed immediately.
@param needed the number of bytes that are needed.
@return the random bytes. | [
"The",
"built",
"-",
"in",
"default",
"seedFile",
".",
"This",
"seedFile",
"is",
"used",
"when",
"entropy",
"is",
"needed",
"immediately",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L9167-L9227 |
56,429 | mgesmundo/authorify-client | build/authorify.js | spawnPrng | function spawnPrng() {
var ctx = forge.prng.create(prng_aes);
/**
* Gets random bytes. If a native secure crypto API is unavailable, this
* method tries to make the bytes more unpredictable by drawing from data that
* can be collected from the user of the browser, eg: mouse movement.
*
* If a callback is given, this method will be called asynchronously.
*
* @param count the number of random bytes to get.
* @param [callback(err, bytes)] called once the operation completes.
*
* @return the random bytes in a string.
*/
ctx.getBytes = function(count, callback) {
return ctx.generate(count, callback);
};
/**
* Gets random bytes asynchronously. If a native secure crypto API is
* unavailable, this method tries to make the bytes more unpredictable by
* drawing from data that can be collected from the user of the browser,
* eg: mouse movement.
*
* @param count the number of random bytes to get.
*
* @return the random bytes in a string.
*/
ctx.getBytesSync = function(count) {
return ctx.generate(count);
};
return ctx;
} | javascript | function spawnPrng() {
var ctx = forge.prng.create(prng_aes);
/**
* Gets random bytes. If a native secure crypto API is unavailable, this
* method tries to make the bytes more unpredictable by drawing from data that
* can be collected from the user of the browser, eg: mouse movement.
*
* If a callback is given, this method will be called asynchronously.
*
* @param count the number of random bytes to get.
* @param [callback(err, bytes)] called once the operation completes.
*
* @return the random bytes in a string.
*/
ctx.getBytes = function(count, callback) {
return ctx.generate(count, callback);
};
/**
* Gets random bytes asynchronously. If a native secure crypto API is
* unavailable, this method tries to make the bytes more unpredictable by
* drawing from data that can be collected from the user of the browser,
* eg: mouse movement.
*
* @param count the number of random bytes to get.
*
* @return the random bytes in a string.
*/
ctx.getBytesSync = function(count) {
return ctx.generate(count);
};
return ctx;
} | [
"function",
"spawnPrng",
"(",
")",
"{",
"var",
"ctx",
"=",
"forge",
".",
"prng",
".",
"create",
"(",
"prng_aes",
")",
";",
"/**\n * Gets random bytes. If a native secure crypto API is unavailable, this\n * method tries to make the bytes more unpredictable by drawing from data that\n * can be collected from the user of the browser, eg: mouse movement.\n *\n * If a callback is given, this method will be called asynchronously.\n *\n * @param count the number of random bytes to get.\n * @param [callback(err, bytes)] called once the operation completes.\n *\n * @return the random bytes in a string.\n */",
"ctx",
".",
"getBytes",
"=",
"function",
"(",
"count",
",",
"callback",
")",
"{",
"return",
"ctx",
".",
"generate",
"(",
"count",
",",
"callback",
")",
";",
"}",
";",
"/**\n * Gets random bytes asynchronously. If a native secure crypto API is\n * unavailable, this method tries to make the bytes more unpredictable by\n * drawing from data that can be collected from the user of the browser,\n * eg: mouse movement.\n *\n * @param count the number of random bytes to get.\n *\n * @return the random bytes in a string.\n */",
"ctx",
".",
"getBytesSync",
"=",
"function",
"(",
"count",
")",
"{",
"return",
"ctx",
".",
"generate",
"(",
"count",
")",
";",
"}",
";",
"return",
"ctx",
";",
"}"
] | Creates a new PRNG. | [
"Creates",
"a",
"new",
"PRNG",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L9447-L9481 |
56,430 | mgesmundo/authorify-client | build/authorify.js | function(plan) {
var R = [];
/* Get data from input buffer and fill the four words into R */
for(i = 0; i < 4; i ++) {
var val = _input.getInt16Le();
if(_iv !== null) {
if(encrypt) {
/* We're encrypting, apply the IV first. */
val ^= _iv.getInt16Le();
} else {
/* We're decryption, keep cipher text for next block. */
_iv.putInt16Le(val);
}
}
R.push(val & 0xffff);
}
/* Reset global "j" variable as per spec. */
j = encrypt ? 0 : 63;
/* Run execution plan. */
for(var ptr = 0; ptr < plan.length; ptr ++) {
for(var ctr = 0; ctr < plan[ptr][0]; ctr ++) {
plan[ptr][1](R);
}
}
/* Write back result to output buffer. */
for(i = 0; i < 4; i ++) {
if(_iv !== null) {
if(encrypt) {
/* We're encrypting in CBC-mode, feed back encrypted bytes into
IV buffer to carry it forward to next block. */
_iv.putInt16Le(R[i]);
} else {
R[i] ^= _iv.getInt16Le();
}
}
_output.putInt16Le(R[i]);
}
} | javascript | function(plan) {
var R = [];
/* Get data from input buffer and fill the four words into R */
for(i = 0; i < 4; i ++) {
var val = _input.getInt16Le();
if(_iv !== null) {
if(encrypt) {
/* We're encrypting, apply the IV first. */
val ^= _iv.getInt16Le();
} else {
/* We're decryption, keep cipher text for next block. */
_iv.putInt16Le(val);
}
}
R.push(val & 0xffff);
}
/* Reset global "j" variable as per spec. */
j = encrypt ? 0 : 63;
/* Run execution plan. */
for(var ptr = 0; ptr < plan.length; ptr ++) {
for(var ctr = 0; ctr < plan[ptr][0]; ctr ++) {
plan[ptr][1](R);
}
}
/* Write back result to output buffer. */
for(i = 0; i < 4; i ++) {
if(_iv !== null) {
if(encrypt) {
/* We're encrypting in CBC-mode, feed back encrypted bytes into
IV buffer to carry it forward to next block. */
_iv.putInt16Le(R[i]);
} else {
R[i] ^= _iv.getInt16Le();
}
}
_output.putInt16Le(R[i]);
}
} | [
"function",
"(",
"plan",
")",
"{",
"var",
"R",
"=",
"[",
"]",
";",
"/* Get data from input buffer and fill the four words into R */",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"4",
";",
"i",
"++",
")",
"{",
"var",
"val",
"=",
"_input",
".",
"getInt16Le",
"(",
")",
";",
"if",
"(",
"_iv",
"!==",
"null",
")",
"{",
"if",
"(",
"encrypt",
")",
"{",
"/* We're encrypting, apply the IV first. */",
"val",
"^=",
"_iv",
".",
"getInt16Le",
"(",
")",
";",
"}",
"else",
"{",
"/* We're decryption, keep cipher text for next block. */",
"_iv",
".",
"putInt16Le",
"(",
"val",
")",
";",
"}",
"}",
"R",
".",
"push",
"(",
"val",
"&",
"0xffff",
")",
";",
"}",
"/* Reset global \"j\" variable as per spec. */",
"j",
"=",
"encrypt",
"?",
"0",
":",
"63",
";",
"/* Run execution plan. */",
"for",
"(",
"var",
"ptr",
"=",
"0",
";",
"ptr",
"<",
"plan",
".",
"length",
";",
"ptr",
"++",
")",
"{",
"for",
"(",
"var",
"ctr",
"=",
"0",
";",
"ctr",
"<",
"plan",
"[",
"ptr",
"]",
"[",
"0",
"]",
";",
"ctr",
"++",
")",
"{",
"plan",
"[",
"ptr",
"]",
"[",
"1",
"]",
"(",
"R",
")",
";",
"}",
"}",
"/* Write back result to output buffer. */",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"4",
";",
"i",
"++",
")",
"{",
"if",
"(",
"_iv",
"!==",
"null",
")",
"{",
"if",
"(",
"encrypt",
")",
"{",
"/* We're encrypting in CBC-mode, feed back encrypted bytes into\n IV buffer to carry it forward to next block. */",
"_iv",
".",
"putInt16Le",
"(",
"R",
"[",
"i",
"]",
")",
";",
"}",
"else",
"{",
"R",
"[",
"i",
"]",
"^=",
"_iv",
".",
"getInt16Le",
"(",
")",
";",
"}",
"}",
"_output",
".",
"putInt16Le",
"(",
"R",
"[",
"i",
"]",
")",
";",
"}",
"}"
] | Run the specified cipher execution plan.
This function takes four words from the input buffer, applies the IV on
it (if requested) and runs the provided execution plan.
The plan must be put together in form of a array of arrays. Where the
outer one is simply a list of steps to perform and the inner one needs
to have two elements: the first one telling how many rounds to perform,
the second one telling what to do (i.e. the function to call).
@param {Array} plan The plan to execute. | [
"Run",
"the",
"specified",
"cipher",
"execution",
"plan",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L9803-L9847 |
|
56,431 | mgesmundo/authorify-client | build/authorify.js | function(input) {
if(!_finish) {
// not finishing, so fill the input buffer with more input
_input.putBuffer(input);
}
while(_input.length() >= 8) {
runPlan([
[ 5, mixRound ],
[ 1, mashRound ],
[ 6, mixRound ],
[ 1, mashRound ],
[ 5, mixRound ]
]);
}
} | javascript | function(input) {
if(!_finish) {
// not finishing, so fill the input buffer with more input
_input.putBuffer(input);
}
while(_input.length() >= 8) {
runPlan([
[ 5, mixRound ],
[ 1, mashRound ],
[ 6, mixRound ],
[ 1, mashRound ],
[ 5, mixRound ]
]);
}
} | [
"function",
"(",
"input",
")",
"{",
"if",
"(",
"!",
"_finish",
")",
"{",
"// not finishing, so fill the input buffer with more input",
"_input",
".",
"putBuffer",
"(",
"input",
")",
";",
"}",
"while",
"(",
"_input",
".",
"length",
"(",
")",
">=",
"8",
")",
"{",
"runPlan",
"(",
"[",
"[",
"5",
",",
"mixRound",
"]",
",",
"[",
"1",
",",
"mashRound",
"]",
",",
"[",
"6",
",",
"mixRound",
"]",
",",
"[",
"1",
",",
"mashRound",
"]",
",",
"[",
"5",
",",
"mixRound",
"]",
"]",
")",
";",
"}",
"}"
] | Updates the next block.
@param input the buffer to read from. | [
"Updates",
"the",
"next",
"block",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L9884-L9899 |
|
56,432 | mgesmundo/authorify-client | build/authorify.js | function(pad) {
var rval = true;
if(encrypt) {
if(pad) {
rval = pad(8, _input, !encrypt);
} else {
// add PKCS#7 padding to block (each pad byte is the
// value of the number of pad bytes)
var padding = (_input.length() === 8) ? 8 : (8 - _input.length());
_input.fillWithByte(padding, padding);
}
}
if(rval) {
// do final update
_finish = true;
cipher.update();
}
if(!encrypt) {
// check for error: input data not a multiple of block size
rval = (_input.length() === 0);
if(rval) {
if(pad) {
rval = pad(8, _output, !encrypt);
} else {
// ensure padding byte count is valid
var len = _output.length();
var count = _output.at(len - 1);
if(count > len) {
rval = false;
} else {
// trim off padding bytes
_output.truncate(count);
}
}
}
}
return rval;
} | javascript | function(pad) {
var rval = true;
if(encrypt) {
if(pad) {
rval = pad(8, _input, !encrypt);
} else {
// add PKCS#7 padding to block (each pad byte is the
// value of the number of pad bytes)
var padding = (_input.length() === 8) ? 8 : (8 - _input.length());
_input.fillWithByte(padding, padding);
}
}
if(rval) {
// do final update
_finish = true;
cipher.update();
}
if(!encrypt) {
// check for error: input data not a multiple of block size
rval = (_input.length() === 0);
if(rval) {
if(pad) {
rval = pad(8, _output, !encrypt);
} else {
// ensure padding byte count is valid
var len = _output.length();
var count = _output.at(len - 1);
if(count > len) {
rval = false;
} else {
// trim off padding bytes
_output.truncate(count);
}
}
}
}
return rval;
} | [
"function",
"(",
"pad",
")",
"{",
"var",
"rval",
"=",
"true",
";",
"if",
"(",
"encrypt",
")",
"{",
"if",
"(",
"pad",
")",
"{",
"rval",
"=",
"pad",
"(",
"8",
",",
"_input",
",",
"!",
"encrypt",
")",
";",
"}",
"else",
"{",
"// add PKCS#7 padding to block (each pad byte is the",
"// value of the number of pad bytes)",
"var",
"padding",
"=",
"(",
"_input",
".",
"length",
"(",
")",
"===",
"8",
")",
"?",
"8",
":",
"(",
"8",
"-",
"_input",
".",
"length",
"(",
")",
")",
";",
"_input",
".",
"fillWithByte",
"(",
"padding",
",",
"padding",
")",
";",
"}",
"}",
"if",
"(",
"rval",
")",
"{",
"// do final update",
"_finish",
"=",
"true",
";",
"cipher",
".",
"update",
"(",
")",
";",
"}",
"if",
"(",
"!",
"encrypt",
")",
"{",
"// check for error: input data not a multiple of block size",
"rval",
"=",
"(",
"_input",
".",
"length",
"(",
")",
"===",
"0",
")",
";",
"if",
"(",
"rval",
")",
"{",
"if",
"(",
"pad",
")",
"{",
"rval",
"=",
"pad",
"(",
"8",
",",
"_output",
",",
"!",
"encrypt",
")",
";",
"}",
"else",
"{",
"// ensure padding byte count is valid",
"var",
"len",
"=",
"_output",
".",
"length",
"(",
")",
";",
"var",
"count",
"=",
"_output",
".",
"at",
"(",
"len",
"-",
"1",
")",
";",
"if",
"(",
"count",
">",
"len",
")",
"{",
"rval",
"=",
"false",
";",
"}",
"else",
"{",
"// trim off padding bytes",
"_output",
".",
"truncate",
"(",
"count",
")",
";",
"}",
"}",
"}",
"}",
"return",
"rval",
";",
"}"
] | Finishes encrypting or decrypting.
@param pad a padding function to use, null for PKCS#7 padding,
signature(blockSize, buffer, decrypt).
@return true if successful, false on error. | [
"Finishes",
"encrypting",
"or",
"decrypting",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L9909-L9951 |
|
56,433 | mgesmundo/authorify-client | build/authorify.js | bnGetPrng | function bnGetPrng() {
// create prng with api that matches BigInteger secure random
return {
// x is an array to fill with bytes
nextBytes: function(x) {
for(var i = 0; i < x.length; ++i) {
x[i] = Math.floor(Math.random() * 0xFF);
}
}
};
} | javascript | function bnGetPrng() {
// create prng with api that matches BigInteger secure random
return {
// x is an array to fill with bytes
nextBytes: function(x) {
for(var i = 0; i < x.length; ++i) {
x[i] = Math.floor(Math.random() * 0xFF);
}
}
};
} | [
"function",
"bnGetPrng",
"(",
")",
"{",
"// create prng with api that matches BigInteger secure random",
"return",
"{",
"// x is an array to fill with bytes",
"nextBytes",
":",
"function",
"(",
"x",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"x",
".",
"length",
";",
"++",
"i",
")",
"{",
"x",
"[",
"i",
"]",
"=",
"Math",
".",
"floor",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"0xFF",
")",
";",
"}",
"}",
"}",
";",
"}"
] | get pseudo random number generator | [
"get",
"pseudo",
"random",
"number",
"generator"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L11280-L11290 |
56,434 | mgesmundo/authorify-client | build/authorify.js | getPrime | function getPrime(bits, callback) {
// TODO: consider optimizing by starting workers outside getPrime() ...
// note that in order to clean up they will have to be made internally
// asynchronous which may actually be slower
// start workers immediately
var workers = [];
for(var i = 0; i < numWorkers; ++i) {
// FIXME: fix path or use blob URLs
workers[i] = new Worker(workerScript);
}
var running = numWorkers;
// initialize random number
var num = generateRandom();
// listen for requests from workers and assign ranges to find prime
for(var i = 0; i < numWorkers; ++i) {
workers[i].addEventListener('message', workerMessage);
}
/* Note: The distribution of random numbers is unknown. Therefore, each
web worker is continuously allocated a range of numbers to check for a
random number until one is found.
Every 30 numbers will be checked just 8 times, because prime numbers
have the form:
30k+i, for i < 30 and gcd(30, i)=1 (there are 8 values of i for this)
Therefore, if we want a web worker to run N checks before asking for
a new range of numbers, each range must contain N*30/8 numbers.
For 100 checks (workLoad), this is a range of 375. */
function generateRandom() {
var bits1 = bits - 1;
var num = new BigInteger(bits, state.rng);
// force MSB set
if(!num.testBit(bits1)) {
num.bitwiseTo(BigInteger.ONE.shiftLeft(bits1), op_or, num);
}
// align number on 30k+1 boundary
num.dAddOffset(31 - num.mod(THIRTY).byteValue(), 0);
return num;
}
var found = false;
function workerMessage(e) {
// ignore message, prime already found
if(found) {
return;
}
--running;
var data = e.data;
if(data.found) {
// terminate all workers
for(var i = 0; i < workers.length; ++i) {
workers[i].terminate();
}
found = true;
return callback(null, new BigInteger(data.prime, 16));
}
// overflow, regenerate prime
if(num.bitLength() > bits) {
num = generateRandom();
}
// assign new range to check
var hex = num.toString(16);
// start prime search
e.target.postMessage({
e: state.eInt,
hex: hex,
workLoad: workLoad
});
num.dAddOffset(range, 0);
}
} | javascript | function getPrime(bits, callback) {
// TODO: consider optimizing by starting workers outside getPrime() ...
// note that in order to clean up they will have to be made internally
// asynchronous which may actually be slower
// start workers immediately
var workers = [];
for(var i = 0; i < numWorkers; ++i) {
// FIXME: fix path or use blob URLs
workers[i] = new Worker(workerScript);
}
var running = numWorkers;
// initialize random number
var num = generateRandom();
// listen for requests from workers and assign ranges to find prime
for(var i = 0; i < numWorkers; ++i) {
workers[i].addEventListener('message', workerMessage);
}
/* Note: The distribution of random numbers is unknown. Therefore, each
web worker is continuously allocated a range of numbers to check for a
random number until one is found.
Every 30 numbers will be checked just 8 times, because prime numbers
have the form:
30k+i, for i < 30 and gcd(30, i)=1 (there are 8 values of i for this)
Therefore, if we want a web worker to run N checks before asking for
a new range of numbers, each range must contain N*30/8 numbers.
For 100 checks (workLoad), this is a range of 375. */
function generateRandom() {
var bits1 = bits - 1;
var num = new BigInteger(bits, state.rng);
// force MSB set
if(!num.testBit(bits1)) {
num.bitwiseTo(BigInteger.ONE.shiftLeft(bits1), op_or, num);
}
// align number on 30k+1 boundary
num.dAddOffset(31 - num.mod(THIRTY).byteValue(), 0);
return num;
}
var found = false;
function workerMessage(e) {
// ignore message, prime already found
if(found) {
return;
}
--running;
var data = e.data;
if(data.found) {
// terminate all workers
for(var i = 0; i < workers.length; ++i) {
workers[i].terminate();
}
found = true;
return callback(null, new BigInteger(data.prime, 16));
}
// overflow, regenerate prime
if(num.bitLength() > bits) {
num = generateRandom();
}
// assign new range to check
var hex = num.toString(16);
// start prime search
e.target.postMessage({
e: state.eInt,
hex: hex,
workLoad: workLoad
});
num.dAddOffset(range, 0);
}
} | [
"function",
"getPrime",
"(",
"bits",
",",
"callback",
")",
"{",
"// TODO: consider optimizing by starting workers outside getPrime() ...",
"// note that in order to clean up they will have to be made internally",
"// asynchronous which may actually be slower",
"// start workers immediately",
"var",
"workers",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"numWorkers",
";",
"++",
"i",
")",
"{",
"// FIXME: fix path or use blob URLs",
"workers",
"[",
"i",
"]",
"=",
"new",
"Worker",
"(",
"workerScript",
")",
";",
"}",
"var",
"running",
"=",
"numWorkers",
";",
"// initialize random number",
"var",
"num",
"=",
"generateRandom",
"(",
")",
";",
"// listen for requests from workers and assign ranges to find prime",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"numWorkers",
";",
"++",
"i",
")",
"{",
"workers",
"[",
"i",
"]",
".",
"addEventListener",
"(",
"'message'",
",",
"workerMessage",
")",
";",
"}",
"/* Note: The distribution of random numbers is unknown. Therefore, each\n web worker is continuously allocated a range of numbers to check for a\n random number until one is found.\n\n Every 30 numbers will be checked just 8 times, because prime numbers\n have the form:\n\n 30k+i, for i < 30 and gcd(30, i)=1 (there are 8 values of i for this)\n\n Therefore, if we want a web worker to run N checks before asking for\n a new range of numbers, each range must contain N*30/8 numbers.\n\n For 100 checks (workLoad), this is a range of 375. */",
"function",
"generateRandom",
"(",
")",
"{",
"var",
"bits1",
"=",
"bits",
"-",
"1",
";",
"var",
"num",
"=",
"new",
"BigInteger",
"(",
"bits",
",",
"state",
".",
"rng",
")",
";",
"// force MSB set",
"if",
"(",
"!",
"num",
".",
"testBit",
"(",
"bits1",
")",
")",
"{",
"num",
".",
"bitwiseTo",
"(",
"BigInteger",
".",
"ONE",
".",
"shiftLeft",
"(",
"bits1",
")",
",",
"op_or",
",",
"num",
")",
";",
"}",
"// align number on 30k+1 boundary",
"num",
".",
"dAddOffset",
"(",
"31",
"-",
"num",
".",
"mod",
"(",
"THIRTY",
")",
".",
"byteValue",
"(",
")",
",",
"0",
")",
";",
"return",
"num",
";",
"}",
"var",
"found",
"=",
"false",
";",
"function",
"workerMessage",
"(",
"e",
")",
"{",
"// ignore message, prime already found",
"if",
"(",
"found",
")",
"{",
"return",
";",
"}",
"--",
"running",
";",
"var",
"data",
"=",
"e",
".",
"data",
";",
"if",
"(",
"data",
".",
"found",
")",
"{",
"// terminate all workers",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"workers",
".",
"length",
";",
"++",
"i",
")",
"{",
"workers",
"[",
"i",
"]",
".",
"terminate",
"(",
")",
";",
"}",
"found",
"=",
"true",
";",
"return",
"callback",
"(",
"null",
",",
"new",
"BigInteger",
"(",
"data",
".",
"prime",
",",
"16",
")",
")",
";",
"}",
"// overflow, regenerate prime",
"if",
"(",
"num",
".",
"bitLength",
"(",
")",
">",
"bits",
")",
"{",
"num",
"=",
"generateRandom",
"(",
")",
";",
"}",
"// assign new range to check",
"var",
"hex",
"=",
"num",
".",
"toString",
"(",
"16",
")",
";",
"// start prime search",
"e",
".",
"target",
".",
"postMessage",
"(",
"{",
"e",
":",
"state",
".",
"eInt",
",",
"hex",
":",
"hex",
",",
"workLoad",
":",
"workLoad",
"}",
")",
";",
"num",
".",
"dAddOffset",
"(",
"range",
",",
"0",
")",
";",
"}",
"}"
] | implement prime number generation using web workers | [
"implement",
"prime",
"number",
"generation",
"using",
"web",
"workers"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L13286-L13368 |
56,435 | mgesmundo/authorify-client | build/authorify.js | _bnToBytes | function _bnToBytes(b) {
// prepend 0x00 if first byte >= 0x80
var hex = b.toString(16);
if(hex[0] >= '8') {
hex = '00' + hex;
}
return forge.util.hexToBytes(hex);
} | javascript | function _bnToBytes(b) {
// prepend 0x00 if first byte >= 0x80
var hex = b.toString(16);
if(hex[0] >= '8') {
hex = '00' + hex;
}
return forge.util.hexToBytes(hex);
} | [
"function",
"_bnToBytes",
"(",
"b",
")",
"{",
"// prepend 0x00 if first byte >= 0x80",
"var",
"hex",
"=",
"b",
".",
"toString",
"(",
"16",
")",
";",
"if",
"(",
"hex",
"[",
"0",
"]",
">=",
"'8'",
")",
"{",
"hex",
"=",
"'00'",
"+",
"hex",
";",
"}",
"return",
"forge",
".",
"util",
".",
"hexToBytes",
"(",
"hex",
")",
";",
"}"
] | Converts a positive BigInteger into 2's-complement big-endian bytes.
@param b the big integer to convert.
@return the bytes. | [
"Converts",
"a",
"positive",
"BigInteger",
"into",
"2",
"s",
"-",
"complement",
"big",
"-",
"endian",
"bytes",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L13424-L13431 |
56,436 | mgesmundo/authorify-client | build/authorify.js | evpBytesToKey | function evpBytesToKey(password, salt, dkLen) {
var digests = [md5(password + salt)];
for(var length = 16, i = 1; length < dkLen; ++i, length += 16) {
digests.push(md5(digests[i - 1] + password + salt));
}
return digests.join('').substr(0, dkLen);
} | javascript | function evpBytesToKey(password, salt, dkLen) {
var digests = [md5(password + salt)];
for(var length = 16, i = 1; length < dkLen; ++i, length += 16) {
digests.push(md5(digests[i - 1] + password + salt));
}
return digests.join('').substr(0, dkLen);
} | [
"function",
"evpBytesToKey",
"(",
"password",
",",
"salt",
",",
"dkLen",
")",
"{",
"var",
"digests",
"=",
"[",
"md5",
"(",
"password",
"+",
"salt",
")",
"]",
";",
"for",
"(",
"var",
"length",
"=",
"16",
",",
"i",
"=",
"1",
";",
"length",
"<",
"dkLen",
";",
"++",
"i",
",",
"length",
"+=",
"16",
")",
"{",
"digests",
".",
"push",
"(",
"md5",
"(",
"digests",
"[",
"i",
"-",
"1",
"]",
"+",
"password",
"+",
"salt",
")",
")",
";",
"}",
"return",
"digests",
".",
"join",
"(",
"''",
")",
".",
"substr",
"(",
"0",
",",
"dkLen",
")",
";",
"}"
] | OpenSSL's legacy key derivation function.
See: http://www.openssl.org/docs/crypto/EVP_BytesToKey.html
@param password the password to derive the key from.
@param salt the salt to use.
@param dkLen the number of bytes needed for the derived key. | [
"OpenSSL",
"s",
"legacy",
"key",
"derivation",
"function",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L14408-L14414 |
56,437 | mgesmundo/authorify-client | build/authorify.js | _extensionsToAsn1 | function _extensionsToAsn1(exts) {
// create top-level extension container
var rval = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 3, true, []);
// create extension sequence (stores a sequence for each extension)
var seq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
rval.value.push(seq);
var ext, extseq;
for(var i = 0; i < exts.length; ++i) {
ext = exts[i];
// create a sequence for each extension
extseq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
seq.value.push(extseq);
// extnID (OID)
extseq.value.push(asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(ext.id).getBytes()));
// critical defaults to false
if(ext.critical) {
// critical BOOLEAN DEFAULT FALSE
extseq.value.push(asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.BOOLEAN, false,
String.fromCharCode(0xFF)));
}
var value = ext.value;
if(typeof ext.value !== 'string') {
// value is asn.1
value = asn1.toDer(value).getBytes();
}
// extnValue (OCTET STRING)
extseq.value.push(asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, value));
}
return rval;
} | javascript | function _extensionsToAsn1(exts) {
// create top-level extension container
var rval = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 3, true, []);
// create extension sequence (stores a sequence for each extension)
var seq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
rval.value.push(seq);
var ext, extseq;
for(var i = 0; i < exts.length; ++i) {
ext = exts[i];
// create a sequence for each extension
extseq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
seq.value.push(extseq);
// extnID (OID)
extseq.value.push(asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(ext.id).getBytes()));
// critical defaults to false
if(ext.critical) {
// critical BOOLEAN DEFAULT FALSE
extseq.value.push(asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.BOOLEAN, false,
String.fromCharCode(0xFF)));
}
var value = ext.value;
if(typeof ext.value !== 'string') {
// value is asn.1
value = asn1.toDer(value).getBytes();
}
// extnValue (OCTET STRING)
extseq.value.push(asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, value));
}
return rval;
} | [
"function",
"_extensionsToAsn1",
"(",
"exts",
")",
"{",
"// create top-level extension container",
"var",
"rval",
"=",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"CONTEXT_SPECIFIC",
",",
"3",
",",
"true",
",",
"[",
"]",
")",
";",
"// create extension sequence (stores a sequence for each extension)",
"var",
"seq",
"=",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"]",
")",
";",
"rval",
".",
"value",
".",
"push",
"(",
"seq",
")",
";",
"var",
"ext",
",",
"extseq",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"exts",
".",
"length",
";",
"++",
"i",
")",
"{",
"ext",
"=",
"exts",
"[",
"i",
"]",
";",
"// create a sequence for each extension",
"extseq",
"=",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"]",
")",
";",
"seq",
".",
"value",
".",
"push",
"(",
"extseq",
")",
";",
"// extnID (OID)",
"extseq",
".",
"value",
".",
"push",
"(",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OID",
",",
"false",
",",
"asn1",
".",
"oidToDer",
"(",
"ext",
".",
"id",
")",
".",
"getBytes",
"(",
")",
")",
")",
";",
"// critical defaults to false",
"if",
"(",
"ext",
".",
"critical",
")",
"{",
"// critical BOOLEAN DEFAULT FALSE",
"extseq",
".",
"value",
".",
"push",
"(",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"BOOLEAN",
",",
"false",
",",
"String",
".",
"fromCharCode",
"(",
"0xFF",
")",
")",
")",
";",
"}",
"var",
"value",
"=",
"ext",
".",
"value",
";",
"if",
"(",
"typeof",
"ext",
".",
"value",
"!==",
"'string'",
")",
"{",
"// value is asn.1",
"value",
"=",
"asn1",
".",
"toDer",
"(",
"value",
")",
".",
"getBytes",
"(",
")",
";",
"}",
"// extnValue (OCTET STRING)",
"extseq",
".",
"value",
".",
"push",
"(",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OCTETSTRING",
",",
"false",
",",
"value",
")",
")",
";",
"}",
"return",
"rval",
";",
"}"
] | Converts X.509v3 certificate extensions to ASN.1.
@param exts the extensions to convert.
@return the extensions in ASN.1 format. | [
"Converts",
"X",
".",
"509v3",
"certificate",
"extensions",
"to",
"ASN",
".",
"1",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L17430-L17471 |
56,438 | mgesmundo/authorify-client | build/authorify.js | _CRIAttributesToAsn1 | function _CRIAttributesToAsn1(csr) {
// create an empty context-specific container
var rval = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, []);
// no attributes, return empty container
if(csr.attributes.length === 0) {
return rval;
}
// each attribute has a sequence with a type and a set of values
var attrs = csr.attributes;
for(var i = 0; i < attrs.length; ++i) {
var attr = attrs[i];
var value = attr.value;
// reuse tag class for attribute value if available
var valueTagClass = asn1.Type.UTF8;
if('valueTagClass' in attr) {
valueTagClass = attr.valueTagClass;
}
if(valueTagClass === asn1.Type.UTF8) {
value = forge.util.encodeUtf8(value);
}
// FIXME: handle more encodings
// create a RelativeDistinguishedName set
// each value in the set is an AttributeTypeAndValue first
// containing the type (an OID) and second the value
var seq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// AttributeType
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(attr.type).getBytes()),
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [
// AttributeValue
asn1.create(asn1.Class.UNIVERSAL, valueTagClass, false, value)
])
]);
rval.value.push(seq);
}
return rval;
} | javascript | function _CRIAttributesToAsn1(csr) {
// create an empty context-specific container
var rval = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, []);
// no attributes, return empty container
if(csr.attributes.length === 0) {
return rval;
}
// each attribute has a sequence with a type and a set of values
var attrs = csr.attributes;
for(var i = 0; i < attrs.length; ++i) {
var attr = attrs[i];
var value = attr.value;
// reuse tag class for attribute value if available
var valueTagClass = asn1.Type.UTF8;
if('valueTagClass' in attr) {
valueTagClass = attr.valueTagClass;
}
if(valueTagClass === asn1.Type.UTF8) {
value = forge.util.encodeUtf8(value);
}
// FIXME: handle more encodings
// create a RelativeDistinguishedName set
// each value in the set is an AttributeTypeAndValue first
// containing the type (an OID) and second the value
var seq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// AttributeType
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(attr.type).getBytes()),
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [
// AttributeValue
asn1.create(asn1.Class.UNIVERSAL, valueTagClass, false, value)
])
]);
rval.value.push(seq);
}
return rval;
} | [
"function",
"_CRIAttributesToAsn1",
"(",
"csr",
")",
"{",
"// create an empty context-specific container",
"var",
"rval",
"=",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"CONTEXT_SPECIFIC",
",",
"0",
",",
"true",
",",
"[",
"]",
")",
";",
"// no attributes, return empty container",
"if",
"(",
"csr",
".",
"attributes",
".",
"length",
"===",
"0",
")",
"{",
"return",
"rval",
";",
"}",
"// each attribute has a sequence with a type and a set of values",
"var",
"attrs",
"=",
"csr",
".",
"attributes",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"attrs",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"attr",
"=",
"attrs",
"[",
"i",
"]",
";",
"var",
"value",
"=",
"attr",
".",
"value",
";",
"// reuse tag class for attribute value if available",
"var",
"valueTagClass",
"=",
"asn1",
".",
"Type",
".",
"UTF8",
";",
"if",
"(",
"'valueTagClass'",
"in",
"attr",
")",
"{",
"valueTagClass",
"=",
"attr",
".",
"valueTagClass",
";",
"}",
"if",
"(",
"valueTagClass",
"===",
"asn1",
".",
"Type",
".",
"UTF8",
")",
"{",
"value",
"=",
"forge",
".",
"util",
".",
"encodeUtf8",
"(",
"value",
")",
";",
"}",
"// FIXME: handle more encodings",
"// create a RelativeDistinguishedName set",
"// each value in the set is an AttributeTypeAndValue first",
"// containing the type (an OID) and second the value",
"var",
"seq",
"=",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"// AttributeType",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OID",
",",
"false",
",",
"asn1",
".",
"oidToDer",
"(",
"attr",
".",
"type",
")",
".",
"getBytes",
"(",
")",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SET",
",",
"true",
",",
"[",
"// AttributeValue",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"valueTagClass",
",",
"false",
",",
"value",
")",
"]",
")",
"]",
")",
";",
"rval",
".",
"value",
".",
"push",
"(",
"seq",
")",
";",
"}",
"return",
"rval",
";",
"}"
] | Converts a certification request's attributes to an ASN.1 set of
CRIAttributes.
@param csr certification request.
@return the ASN.1 set of CRIAttributes. | [
"Converts",
"a",
"certification",
"request",
"s",
"attributes",
"to",
"an",
"ASN",
".",
"1",
"set",
"of",
"CRIAttributes",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L17608-L17649 |
56,439 | mgesmundo/authorify-client | build/authorify.js | function(filter) {
var rval = {};
var localKeyId;
if('localKeyId' in filter) {
localKeyId = filter.localKeyId;
} else if('localKeyIdHex' in filter) {
localKeyId = forge.util.hexToBytes(filter.localKeyIdHex);
}
// filter on bagType only
if(localKeyId === undefined && !('friendlyName' in filter) &&
'bagType' in filter) {
rval[filter.bagType] = _getBagsByAttribute(
pfx.safeContents, null, null, filter.bagType);
}
if(localKeyId !== undefined) {
rval.localKeyId = _getBagsByAttribute(
pfx.safeContents, 'localKeyId',
localKeyId, filter.bagType);
}
if('friendlyName' in filter) {
rval.friendlyName = _getBagsByAttribute(
pfx.safeContents, 'friendlyName',
filter.friendlyName, filter.bagType);
}
return rval;
} | javascript | function(filter) {
var rval = {};
var localKeyId;
if('localKeyId' in filter) {
localKeyId = filter.localKeyId;
} else if('localKeyIdHex' in filter) {
localKeyId = forge.util.hexToBytes(filter.localKeyIdHex);
}
// filter on bagType only
if(localKeyId === undefined && !('friendlyName' in filter) &&
'bagType' in filter) {
rval[filter.bagType] = _getBagsByAttribute(
pfx.safeContents, null, null, filter.bagType);
}
if(localKeyId !== undefined) {
rval.localKeyId = _getBagsByAttribute(
pfx.safeContents, 'localKeyId',
localKeyId, filter.bagType);
}
if('friendlyName' in filter) {
rval.friendlyName = _getBagsByAttribute(
pfx.safeContents, 'friendlyName',
filter.friendlyName, filter.bagType);
}
return rval;
} | [
"function",
"(",
"filter",
")",
"{",
"var",
"rval",
"=",
"{",
"}",
";",
"var",
"localKeyId",
";",
"if",
"(",
"'localKeyId'",
"in",
"filter",
")",
"{",
"localKeyId",
"=",
"filter",
".",
"localKeyId",
";",
"}",
"else",
"if",
"(",
"'localKeyIdHex'",
"in",
"filter",
")",
"{",
"localKeyId",
"=",
"forge",
".",
"util",
".",
"hexToBytes",
"(",
"filter",
".",
"localKeyIdHex",
")",
";",
"}",
"// filter on bagType only",
"if",
"(",
"localKeyId",
"===",
"undefined",
"&&",
"!",
"(",
"'friendlyName'",
"in",
"filter",
")",
"&&",
"'bagType'",
"in",
"filter",
")",
"{",
"rval",
"[",
"filter",
".",
"bagType",
"]",
"=",
"_getBagsByAttribute",
"(",
"pfx",
".",
"safeContents",
",",
"null",
",",
"null",
",",
"filter",
".",
"bagType",
")",
";",
"}",
"if",
"(",
"localKeyId",
"!==",
"undefined",
")",
"{",
"rval",
".",
"localKeyId",
"=",
"_getBagsByAttribute",
"(",
"pfx",
".",
"safeContents",
",",
"'localKeyId'",
",",
"localKeyId",
",",
"filter",
".",
"bagType",
")",
";",
"}",
"if",
"(",
"'friendlyName'",
"in",
"filter",
")",
"{",
"rval",
".",
"friendlyName",
"=",
"_getBagsByAttribute",
"(",
"pfx",
".",
"safeContents",
",",
"'friendlyName'",
",",
"filter",
".",
"friendlyName",
",",
"filter",
".",
"bagType",
")",
";",
"}",
"return",
"rval",
";",
"}"
] | Gets bags with matching attributes.
@param filter the attributes to filter by:
[localKeyId] the localKeyId to search for.
[localKeyIdHex] the localKeyId in hex to search for.
[friendlyName] the friendly name to search for.
[bagType] bag type to narrow each attribute search by.
@return a map of attribute type to an array of matching bags or, if no
attribute was given but a bag type, the map key will be the
bag type. | [
"Gets",
"bags",
"with",
"matching",
"attributes",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L18696-L18725 |
|
56,440 | mgesmundo/authorify-client | build/authorify.js | function(secret, label, seed, length) {
var rval = forge.util.createBuffer();
/* For TLS 1.0, the secret is split in half, into two secrets of equal
length. If the secret has an odd length then the last byte of the first
half will be the same as the first byte of the second. The length of the
two secrets is half of the secret rounded up. */
var idx = (secret.length >> 1);
var slen = idx + (secret.length & 1);
var s1 = secret.substr(0, slen);
var s2 = secret.substr(idx, slen);
var ai = forge.util.createBuffer();
var hmac = forge.hmac.create();
seed = label + seed;
// determine the number of iterations that must be performed to generate
// enough output bytes, md5 creates 16 byte hashes, sha1 creates 20
var md5itr = Math.ceil(length / 16);
var sha1itr = Math.ceil(length / 20);
// do md5 iterations
hmac.start('MD5', s1);
var md5bytes = forge.util.createBuffer();
ai.putBytes(seed);
for(var i = 0; i < md5itr; ++i) {
// HMAC_hash(secret, A(i-1))
hmac.start(null, null);
hmac.update(ai.getBytes());
ai.putBuffer(hmac.digest());
// HMAC_hash(secret, A(i) + seed)
hmac.start(null, null);
hmac.update(ai.bytes() + seed);
md5bytes.putBuffer(hmac.digest());
}
// do sha1 iterations
hmac.start('SHA1', s2);
var sha1bytes = forge.util.createBuffer();
ai.clear();
ai.putBytes(seed);
for(var i = 0; i < sha1itr; ++i) {
// HMAC_hash(secret, A(i-1))
hmac.start(null, null);
hmac.update(ai.getBytes());
ai.putBuffer(hmac.digest());
// HMAC_hash(secret, A(i) + seed)
hmac.start(null, null);
hmac.update(ai.bytes() + seed);
sha1bytes.putBuffer(hmac.digest());
}
// XOR the md5 bytes with the sha1 bytes
rval.putBytes(forge.util.xorBytes(
md5bytes.getBytes(), sha1bytes.getBytes(), length));
return rval;
} | javascript | function(secret, label, seed, length) {
var rval = forge.util.createBuffer();
/* For TLS 1.0, the secret is split in half, into two secrets of equal
length. If the secret has an odd length then the last byte of the first
half will be the same as the first byte of the second. The length of the
two secrets is half of the secret rounded up. */
var idx = (secret.length >> 1);
var slen = idx + (secret.length & 1);
var s1 = secret.substr(0, slen);
var s2 = secret.substr(idx, slen);
var ai = forge.util.createBuffer();
var hmac = forge.hmac.create();
seed = label + seed;
// determine the number of iterations that must be performed to generate
// enough output bytes, md5 creates 16 byte hashes, sha1 creates 20
var md5itr = Math.ceil(length / 16);
var sha1itr = Math.ceil(length / 20);
// do md5 iterations
hmac.start('MD5', s1);
var md5bytes = forge.util.createBuffer();
ai.putBytes(seed);
for(var i = 0; i < md5itr; ++i) {
// HMAC_hash(secret, A(i-1))
hmac.start(null, null);
hmac.update(ai.getBytes());
ai.putBuffer(hmac.digest());
// HMAC_hash(secret, A(i) + seed)
hmac.start(null, null);
hmac.update(ai.bytes() + seed);
md5bytes.putBuffer(hmac.digest());
}
// do sha1 iterations
hmac.start('SHA1', s2);
var sha1bytes = forge.util.createBuffer();
ai.clear();
ai.putBytes(seed);
for(var i = 0; i < sha1itr; ++i) {
// HMAC_hash(secret, A(i-1))
hmac.start(null, null);
hmac.update(ai.getBytes());
ai.putBuffer(hmac.digest());
// HMAC_hash(secret, A(i) + seed)
hmac.start(null, null);
hmac.update(ai.bytes() + seed);
sha1bytes.putBuffer(hmac.digest());
}
// XOR the md5 bytes with the sha1 bytes
rval.putBytes(forge.util.xorBytes(
md5bytes.getBytes(), sha1bytes.getBytes(), length));
return rval;
} | [
"function",
"(",
"secret",
",",
"label",
",",
"seed",
",",
"length",
")",
"{",
"var",
"rval",
"=",
"forge",
".",
"util",
".",
"createBuffer",
"(",
")",
";",
"/* For TLS 1.0, the secret is split in half, into two secrets of equal\n length. If the secret has an odd length then the last byte of the first\n half will be the same as the first byte of the second. The length of the\n two secrets is half of the secret rounded up. */",
"var",
"idx",
"=",
"(",
"secret",
".",
"length",
">>",
"1",
")",
";",
"var",
"slen",
"=",
"idx",
"+",
"(",
"secret",
".",
"length",
"&",
"1",
")",
";",
"var",
"s1",
"=",
"secret",
".",
"substr",
"(",
"0",
",",
"slen",
")",
";",
"var",
"s2",
"=",
"secret",
".",
"substr",
"(",
"idx",
",",
"slen",
")",
";",
"var",
"ai",
"=",
"forge",
".",
"util",
".",
"createBuffer",
"(",
")",
";",
"var",
"hmac",
"=",
"forge",
".",
"hmac",
".",
"create",
"(",
")",
";",
"seed",
"=",
"label",
"+",
"seed",
";",
"// determine the number of iterations that must be performed to generate",
"// enough output bytes, md5 creates 16 byte hashes, sha1 creates 20",
"var",
"md5itr",
"=",
"Math",
".",
"ceil",
"(",
"length",
"/",
"16",
")",
";",
"var",
"sha1itr",
"=",
"Math",
".",
"ceil",
"(",
"length",
"/",
"20",
")",
";",
"// do md5 iterations",
"hmac",
".",
"start",
"(",
"'MD5'",
",",
"s1",
")",
";",
"var",
"md5bytes",
"=",
"forge",
".",
"util",
".",
"createBuffer",
"(",
")",
";",
"ai",
".",
"putBytes",
"(",
"seed",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"md5itr",
";",
"++",
"i",
")",
"{",
"// HMAC_hash(secret, A(i-1))",
"hmac",
".",
"start",
"(",
"null",
",",
"null",
")",
";",
"hmac",
".",
"update",
"(",
"ai",
".",
"getBytes",
"(",
")",
")",
";",
"ai",
".",
"putBuffer",
"(",
"hmac",
".",
"digest",
"(",
")",
")",
";",
"// HMAC_hash(secret, A(i) + seed)",
"hmac",
".",
"start",
"(",
"null",
",",
"null",
")",
";",
"hmac",
".",
"update",
"(",
"ai",
".",
"bytes",
"(",
")",
"+",
"seed",
")",
";",
"md5bytes",
".",
"putBuffer",
"(",
"hmac",
".",
"digest",
"(",
")",
")",
";",
"}",
"// do sha1 iterations",
"hmac",
".",
"start",
"(",
"'SHA1'",
",",
"s2",
")",
";",
"var",
"sha1bytes",
"=",
"forge",
".",
"util",
".",
"createBuffer",
"(",
")",
";",
"ai",
".",
"clear",
"(",
")",
";",
"ai",
".",
"putBytes",
"(",
"seed",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"sha1itr",
";",
"++",
"i",
")",
"{",
"// HMAC_hash(secret, A(i-1))",
"hmac",
".",
"start",
"(",
"null",
",",
"null",
")",
";",
"hmac",
".",
"update",
"(",
"ai",
".",
"getBytes",
"(",
")",
")",
";",
"ai",
".",
"putBuffer",
"(",
"hmac",
".",
"digest",
"(",
")",
")",
";",
"// HMAC_hash(secret, A(i) + seed)",
"hmac",
".",
"start",
"(",
"null",
",",
"null",
")",
";",
"hmac",
".",
"update",
"(",
"ai",
".",
"bytes",
"(",
")",
"+",
"seed",
")",
";",
"sha1bytes",
".",
"putBuffer",
"(",
"hmac",
".",
"digest",
"(",
")",
")",
";",
"}",
"// XOR the md5 bytes with the sha1 bytes",
"rval",
".",
"putBytes",
"(",
"forge",
".",
"util",
".",
"xorBytes",
"(",
"md5bytes",
".",
"getBytes",
"(",
")",
",",
"sha1bytes",
".",
"getBytes",
"(",
")",
",",
"length",
")",
")",
";",
"return",
"rval",
";",
"}"
] | Generates pseudo random bytes by mixing the result of two hash functions,
MD5 and SHA-1.
prf_TLS1(secret, label, seed) =
P_MD5(S1, label + seed) XOR P_SHA-1(S2, label + seed);
Each P_hash function functions as follows:
P_hash(secret, seed) = HMAC_hash(secret, A(1) + seed) +
HMAC_hash(secret, A(2) + seed) +
HMAC_hash(secret, A(3) + seed) + ...
A() is defined as:
A(0) = seed
A(i) = HMAC_hash(secret, A(i-1))
The '+' operator denotes concatenation.
As many iterations A(N) as are needed are performed to generate enough
pseudo random byte output. If an iteration creates more data than is
necessary, then it is truncated.
Therefore:
A(1) = HMAC_hash(secret, A(0))
= HMAC_hash(secret, seed)
A(2) = HMAC_hash(secret, A(1))
= HMAC_hash(secret, HMAC_hash(secret, seed))
Therefore:
P_hash(secret, seed) =
HMAC_hash(secret, HMAC_hash(secret, A(0)) + seed) +
HMAC_hash(secret, HMAC_hash(secret, A(1)) + seed) +
...
Therefore:
P_hash(secret, seed) =
HMAC_hash(secret, HMAC_hash(secret, seed) + seed) +
HMAC_hash(secret, HMAC_hash(secret, HMAC_hash(secret, seed)) + seed) +
...
@param secret the secret to use.
@param label the label to use.
@param seed the seed value to use.
@param length the number of bytes to generate.
@return the pseudo random bytes in a byte buffer. | [
"Generates",
"pseudo",
"random",
"bytes",
"by",
"mixing",
"the",
"result",
"of",
"two",
"hash",
"functions",
"MD5",
"and",
"SHA",
"-",
"1",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L19920-L19978 |
|
56,441 | mgesmundo/authorify-client | build/authorify.js | function(key, seqNum, record) {
/* MAC is computed like so:
HMAC_hash(
key, seqNum +
TLSCompressed.type +
TLSCompressed.version +
TLSCompressed.length +
TLSCompressed.fragment)
*/
var hmac = forge.hmac.create();
hmac.start('SHA1', key);
var b = forge.util.createBuffer();
b.putInt32(seqNum[0]);
b.putInt32(seqNum[1]);
b.putByte(record.type);
b.putByte(record.version.major);
b.putByte(record.version.minor);
b.putInt16(record.length);
b.putBytes(record.fragment.bytes());
hmac.update(b.getBytes());
return hmac.digest().getBytes();
} | javascript | function(key, seqNum, record) {
/* MAC is computed like so:
HMAC_hash(
key, seqNum +
TLSCompressed.type +
TLSCompressed.version +
TLSCompressed.length +
TLSCompressed.fragment)
*/
var hmac = forge.hmac.create();
hmac.start('SHA1', key);
var b = forge.util.createBuffer();
b.putInt32(seqNum[0]);
b.putInt32(seqNum[1]);
b.putByte(record.type);
b.putByte(record.version.major);
b.putByte(record.version.minor);
b.putInt16(record.length);
b.putBytes(record.fragment.bytes());
hmac.update(b.getBytes());
return hmac.digest().getBytes();
} | [
"function",
"(",
"key",
",",
"seqNum",
",",
"record",
")",
"{",
"/* MAC is computed like so:\n HMAC_hash(\n key, seqNum +\n TLSCompressed.type +\n TLSCompressed.version +\n TLSCompressed.length +\n TLSCompressed.fragment)\n */",
"var",
"hmac",
"=",
"forge",
".",
"hmac",
".",
"create",
"(",
")",
";",
"hmac",
".",
"start",
"(",
"'SHA1'",
",",
"key",
")",
";",
"var",
"b",
"=",
"forge",
".",
"util",
".",
"createBuffer",
"(",
")",
";",
"b",
".",
"putInt32",
"(",
"seqNum",
"[",
"0",
"]",
")",
";",
"b",
".",
"putInt32",
"(",
"seqNum",
"[",
"1",
"]",
")",
";",
"b",
".",
"putByte",
"(",
"record",
".",
"type",
")",
";",
"b",
".",
"putByte",
"(",
"record",
".",
"version",
".",
"major",
")",
";",
"b",
".",
"putByte",
"(",
"record",
".",
"version",
".",
"minor",
")",
";",
"b",
".",
"putInt16",
"(",
"record",
".",
"length",
")",
";",
"b",
".",
"putBytes",
"(",
"record",
".",
"fragment",
".",
"bytes",
"(",
")",
")",
";",
"hmac",
".",
"update",
"(",
"b",
".",
"getBytes",
"(",
")",
")",
";",
"return",
"hmac",
".",
"digest",
"(",
")",
".",
"getBytes",
"(",
")",
";",
"}"
] | Gets a MAC for a record using the SHA-1 hash algorithm.
@param key the mac key.
@param state the sequence number (array of two 32-bit integers).
@param record the record.
@return the sha-1 hash (20 bytes) for the given record. | [
"Gets",
"a",
"MAC",
"for",
"a",
"record",
"using",
"the",
"SHA",
"-",
"1",
"hash",
"algorithm",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L20003-L20024 |
|
56,442 | mgesmundo/authorify-client | build/authorify.js | encrypt_aes_cbc_sha1 | function encrypt_aes_cbc_sha1(record, s) {
var rval = false;
// append MAC to fragment, update sequence number
var mac = s.macFunction(s.macKey, s.sequenceNumber, record);
record.fragment.putBytes(mac);
s.updateSequenceNumber();
// TLS 1.1+ use an explicit IV every time to protect against CBC attacks
var iv;
if(record.version.minor === tls.Versions.TLS_1_0.minor) {
// use the pre-generated IV when initializing for TLS 1.0, otherwise use
// the residue from the previous encryption
iv = s.cipherState.init ? null : s.cipherState.iv;
} else {
iv = forge.random.getBytesSync(16);
}
s.cipherState.init = true;
// start cipher
var cipher = s.cipherState.cipher;
cipher.start({iv: iv});
// TLS 1.1+ write IV into output
if(record.version.minor >= tls.Versions.TLS_1_1.minor) {
cipher.output.putBytes(iv);
}
// do encryption (default padding is appropriate)
cipher.update(record.fragment);
if(cipher.finish(encrypt_aes_cbc_sha1_padding)) {
// set record fragment to encrypted output
record.fragment = cipher.output;
record.length = record.fragment.length();
rval = true;
}
return rval;
} | javascript | function encrypt_aes_cbc_sha1(record, s) {
var rval = false;
// append MAC to fragment, update sequence number
var mac = s.macFunction(s.macKey, s.sequenceNumber, record);
record.fragment.putBytes(mac);
s.updateSequenceNumber();
// TLS 1.1+ use an explicit IV every time to protect against CBC attacks
var iv;
if(record.version.minor === tls.Versions.TLS_1_0.minor) {
// use the pre-generated IV when initializing for TLS 1.0, otherwise use
// the residue from the previous encryption
iv = s.cipherState.init ? null : s.cipherState.iv;
} else {
iv = forge.random.getBytesSync(16);
}
s.cipherState.init = true;
// start cipher
var cipher = s.cipherState.cipher;
cipher.start({iv: iv});
// TLS 1.1+ write IV into output
if(record.version.minor >= tls.Versions.TLS_1_1.minor) {
cipher.output.putBytes(iv);
}
// do encryption (default padding is appropriate)
cipher.update(record.fragment);
if(cipher.finish(encrypt_aes_cbc_sha1_padding)) {
// set record fragment to encrypted output
record.fragment = cipher.output;
record.length = record.fragment.length();
rval = true;
}
return rval;
} | [
"function",
"encrypt_aes_cbc_sha1",
"(",
"record",
",",
"s",
")",
"{",
"var",
"rval",
"=",
"false",
";",
"// append MAC to fragment, update sequence number",
"var",
"mac",
"=",
"s",
".",
"macFunction",
"(",
"s",
".",
"macKey",
",",
"s",
".",
"sequenceNumber",
",",
"record",
")",
";",
"record",
".",
"fragment",
".",
"putBytes",
"(",
"mac",
")",
";",
"s",
".",
"updateSequenceNumber",
"(",
")",
";",
"// TLS 1.1+ use an explicit IV every time to protect against CBC attacks",
"var",
"iv",
";",
"if",
"(",
"record",
".",
"version",
".",
"minor",
"===",
"tls",
".",
"Versions",
".",
"TLS_1_0",
".",
"minor",
")",
"{",
"// use the pre-generated IV when initializing for TLS 1.0, otherwise use",
"// the residue from the previous encryption",
"iv",
"=",
"s",
".",
"cipherState",
".",
"init",
"?",
"null",
":",
"s",
".",
"cipherState",
".",
"iv",
";",
"}",
"else",
"{",
"iv",
"=",
"forge",
".",
"random",
".",
"getBytesSync",
"(",
"16",
")",
";",
"}",
"s",
".",
"cipherState",
".",
"init",
"=",
"true",
";",
"// start cipher",
"var",
"cipher",
"=",
"s",
".",
"cipherState",
".",
"cipher",
";",
"cipher",
".",
"start",
"(",
"{",
"iv",
":",
"iv",
"}",
")",
";",
"// TLS 1.1+ write IV into output",
"if",
"(",
"record",
".",
"version",
".",
"minor",
">=",
"tls",
".",
"Versions",
".",
"TLS_1_1",
".",
"minor",
")",
"{",
"cipher",
".",
"output",
".",
"putBytes",
"(",
"iv",
")",
";",
"}",
"// do encryption (default padding is appropriate)",
"cipher",
".",
"update",
"(",
"record",
".",
"fragment",
")",
";",
"if",
"(",
"cipher",
".",
"finish",
"(",
"encrypt_aes_cbc_sha1_padding",
")",
")",
"{",
"// set record fragment to encrypted output",
"record",
".",
"fragment",
"=",
"cipher",
".",
"output",
";",
"record",
".",
"length",
"=",
"record",
".",
"fragment",
".",
"length",
"(",
")",
";",
"rval",
"=",
"true",
";",
"}",
"return",
"rval",
";",
"}"
] | Encrypts the TLSCompressed record into a TLSCipherText record using AES
in CBC mode.
@param record the TLSCompressed record to encrypt.
@param s the ConnectionState to use.
@return true on success, false on failure. | [
"Encrypts",
"the",
"TLSCompressed",
"record",
"into",
"a",
"TLSCipherText",
"record",
"using",
"AES",
"in",
"CBC",
"mode",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L24037-L24076 |
56,443 | mgesmundo/authorify-client | build/authorify.js | decrypt_aes_cbc_sha1_padding | function decrypt_aes_cbc_sha1_padding(blockSize, output, decrypt) {
var rval = true;
if(decrypt) {
/* The last byte in the output specifies the number of padding bytes not
including itself. Each of the padding bytes has the same value as that
last byte (known as the padding_length). Here we check all padding
bytes to ensure they have the value of padding_length even if one of
them is bad in order to ward-off timing attacks. */
var len = output.length();
var paddingLength = output.last();
for(var i = len - 1 - paddingLength; i < len - 1; ++i) {
rval = rval && (output.at(i) == paddingLength);
}
if(rval) {
// trim off padding bytes and last padding length byte
output.truncate(paddingLength + 1);
}
}
return rval;
} | javascript | function decrypt_aes_cbc_sha1_padding(blockSize, output, decrypt) {
var rval = true;
if(decrypt) {
/* The last byte in the output specifies the number of padding bytes not
including itself. Each of the padding bytes has the same value as that
last byte (known as the padding_length). Here we check all padding
bytes to ensure they have the value of padding_length even if one of
them is bad in order to ward-off timing attacks. */
var len = output.length();
var paddingLength = output.last();
for(var i = len - 1 - paddingLength; i < len - 1; ++i) {
rval = rval && (output.at(i) == paddingLength);
}
if(rval) {
// trim off padding bytes and last padding length byte
output.truncate(paddingLength + 1);
}
}
return rval;
} | [
"function",
"decrypt_aes_cbc_sha1_padding",
"(",
"blockSize",
",",
"output",
",",
"decrypt",
")",
"{",
"var",
"rval",
"=",
"true",
";",
"if",
"(",
"decrypt",
")",
"{",
"/* The last byte in the output specifies the number of padding bytes not\n including itself. Each of the padding bytes has the same value as that\n last byte (known as the padding_length). Here we check all padding\n bytes to ensure they have the value of padding_length even if one of\n them is bad in order to ward-off timing attacks. */",
"var",
"len",
"=",
"output",
".",
"length",
"(",
")",
";",
"var",
"paddingLength",
"=",
"output",
".",
"last",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"len",
"-",
"1",
"-",
"paddingLength",
";",
"i",
"<",
"len",
"-",
"1",
";",
"++",
"i",
")",
"{",
"rval",
"=",
"rval",
"&&",
"(",
"output",
".",
"at",
"(",
"i",
")",
"==",
"paddingLength",
")",
";",
"}",
"if",
"(",
"rval",
")",
"{",
"// trim off padding bytes and last padding length byte",
"output",
".",
"truncate",
"(",
"paddingLength",
"+",
"1",
")",
";",
"}",
"}",
"return",
"rval",
";",
"}"
] | Handles padding for aes_cbc_sha1 in decrypt mode.
@param blockSize the block size.
@param output the output buffer.
@param decrypt true in decrypt mode, false in encrypt mode.
@return true on success, false on failure. | [
"Handles",
"padding",
"for",
"aes_cbc_sha1",
"in",
"decrypt",
"mode",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L24125-L24144 |
56,444 | mgesmundo/authorify-client | build/authorify.js | function(objArr) {
var ret = [];
for(var i = 0; i < objArr.length; i ++) {
ret.push(_recipientInfoFromAsn1(objArr[i]));
}
return ret;
} | javascript | function(objArr) {
var ret = [];
for(var i = 0; i < objArr.length; i ++) {
ret.push(_recipientInfoFromAsn1(objArr[i]));
}
return ret;
} | [
"function",
"(",
"objArr",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"objArr",
".",
"length",
";",
"i",
"++",
")",
"{",
"ret",
".",
"push",
"(",
"_recipientInfoFromAsn1",
"(",
"objArr",
"[",
"i",
"]",
")",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | Map a set of RecipientInfo ASN.1 objects to recipientInfo objects.
@param objArr Array of ASN.1 representations RecipientInfo (i.e. SET OF).
@return array of recipientInfo objects. | [
"Map",
"a",
"set",
"of",
"RecipientInfo",
"ASN",
".",
"1",
"objects",
"to",
"recipientInfo",
"objects",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L24961-L24967 |
|
56,445 | mgesmundo/authorify-client | build/authorify.js | function(recipientsArr) {
var ret = [];
for(var i = 0; i < recipientsArr.length; i ++) {
ret.push(_recipientInfoToAsn1(recipientsArr[i]));
}
return ret;
} | javascript | function(recipientsArr) {
var ret = [];
for(var i = 0; i < recipientsArr.length; i ++) {
ret.push(_recipientInfoToAsn1(recipientsArr[i]));
}
return ret;
} | [
"function",
"(",
"recipientsArr",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"recipientsArr",
".",
"length",
";",
"i",
"++",
")",
"{",
"ret",
".",
"push",
"(",
"_recipientInfoToAsn1",
"(",
"recipientsArr",
"[",
"i",
"]",
")",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | Map an array of recipientInfo objects to ASN.1 objects.
@param recipientsArr Array of recipientInfo objects.
@return Array of ASN.1 representations RecipientInfo. | [
"Map",
"an",
"array",
"of",
"recipientInfo",
"objects",
"to",
"ASN",
".",
"1",
"objects",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L24976-L24982 |
|
56,446 | mgesmundo/authorify-client | build/authorify.js | function(task, recurse) {
// get time since last context swap (ms), if enough time has passed set
// swap to true to indicate that doNext was performed asynchronously
// also, if recurse is too high do asynchronously
var swap =
(recurse > sMaxRecursions) ||
(+new Date() - task.swapTime) > sTimeSlice;
var doNext = function(recurse) {
recurse++;
if(task.state === RUNNING) {
if(swap) {
// update swap time
task.swapTime = +new Date();
}
if(task.subtasks.length > 0) {
// run next subtask
var subtask = task.subtasks.shift();
subtask.error = task.error;
subtask.swapTime = task.swapTime;
subtask.userData = task.userData;
subtask.run(subtask);
if(!subtask.error)
{
runNext(subtask, recurse);
}
} else {
finish(task);
if(!task.error) {
// chain back up and run parent
if(task.parent !== null) {
// propagate task info
task.parent.error = task.error;
task.parent.swapTime = task.swapTime;
task.parent.userData = task.userData;
// no subtasks left, call run next subtask on parent
runNext(task.parent, recurse);
}
}
}
}
};
if(swap) {
// we're swapping, so run asynchronously
setTimeout(doNext, 0);
} else {
// not swapping, so run synchronously
doNext(recurse);
}
} | javascript | function(task, recurse) {
// get time since last context swap (ms), if enough time has passed set
// swap to true to indicate that doNext was performed asynchronously
// also, if recurse is too high do asynchronously
var swap =
(recurse > sMaxRecursions) ||
(+new Date() - task.swapTime) > sTimeSlice;
var doNext = function(recurse) {
recurse++;
if(task.state === RUNNING) {
if(swap) {
// update swap time
task.swapTime = +new Date();
}
if(task.subtasks.length > 0) {
// run next subtask
var subtask = task.subtasks.shift();
subtask.error = task.error;
subtask.swapTime = task.swapTime;
subtask.userData = task.userData;
subtask.run(subtask);
if(!subtask.error)
{
runNext(subtask, recurse);
}
} else {
finish(task);
if(!task.error) {
// chain back up and run parent
if(task.parent !== null) {
// propagate task info
task.parent.error = task.error;
task.parent.swapTime = task.swapTime;
task.parent.userData = task.userData;
// no subtasks left, call run next subtask on parent
runNext(task.parent, recurse);
}
}
}
}
};
if(swap) {
// we're swapping, so run asynchronously
setTimeout(doNext, 0);
} else {
// not swapping, so run synchronously
doNext(recurse);
}
} | [
"function",
"(",
"task",
",",
"recurse",
")",
"{",
"// get time since last context swap (ms), if enough time has passed set",
"// swap to true to indicate that doNext was performed asynchronously",
"// also, if recurse is too high do asynchronously",
"var",
"swap",
"=",
"(",
"recurse",
">",
"sMaxRecursions",
")",
"||",
"(",
"+",
"new",
"Date",
"(",
")",
"-",
"task",
".",
"swapTime",
")",
">",
"sTimeSlice",
";",
"var",
"doNext",
"=",
"function",
"(",
"recurse",
")",
"{",
"recurse",
"++",
";",
"if",
"(",
"task",
".",
"state",
"===",
"RUNNING",
")",
"{",
"if",
"(",
"swap",
")",
"{",
"// update swap time",
"task",
".",
"swapTime",
"=",
"+",
"new",
"Date",
"(",
")",
";",
"}",
"if",
"(",
"task",
".",
"subtasks",
".",
"length",
">",
"0",
")",
"{",
"// run next subtask",
"var",
"subtask",
"=",
"task",
".",
"subtasks",
".",
"shift",
"(",
")",
";",
"subtask",
".",
"error",
"=",
"task",
".",
"error",
";",
"subtask",
".",
"swapTime",
"=",
"task",
".",
"swapTime",
";",
"subtask",
".",
"userData",
"=",
"task",
".",
"userData",
";",
"subtask",
".",
"run",
"(",
"subtask",
")",
";",
"if",
"(",
"!",
"subtask",
".",
"error",
")",
"{",
"runNext",
"(",
"subtask",
",",
"recurse",
")",
";",
"}",
"}",
"else",
"{",
"finish",
"(",
"task",
")",
";",
"if",
"(",
"!",
"task",
".",
"error",
")",
"{",
"// chain back up and run parent",
"if",
"(",
"task",
".",
"parent",
"!==",
"null",
")",
"{",
"// propagate task info",
"task",
".",
"parent",
".",
"error",
"=",
"task",
".",
"error",
";",
"task",
".",
"parent",
".",
"swapTime",
"=",
"task",
".",
"swapTime",
";",
"task",
".",
"parent",
".",
"userData",
"=",
"task",
".",
"userData",
";",
"// no subtasks left, call run next subtask on parent",
"runNext",
"(",
"task",
".",
"parent",
",",
"recurse",
")",
";",
"}",
"}",
"}",
"}",
"}",
";",
"if",
"(",
"swap",
")",
"{",
"// we're swapping, so run asynchronously",
"setTimeout",
"(",
"doNext",
",",
"0",
")",
";",
"}",
"else",
"{",
"// not swapping, so run synchronously",
"doNext",
"(",
"recurse",
")",
";",
"}",
"}"
] | Run the next subtask or finish this task.
@param task the task to process.
@param recurse the recursion count. | [
"Run",
"the",
"next",
"subtask",
"or",
"finish",
"this",
"task",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L26112-L26165 |
|
56,447 | mgesmundo/authorify-client | build/authorify.js | function(task, suppressCallbacks) {
// subtask is now done
task.state = DONE;
delete sTasks[task.id];
if(sVL >= 1) {
forge.log.verbose(cat, '[%s][%s] finish',
task.id, task.name, task);
}
// only do queue processing for root tasks
if(task.parent === null) {
// report error if queue is missing
if(!(task.type in sTaskQueues)) {
forge.log.error(cat,
'[%s][%s] task queue missing [%s]',
task.id, task.name, task.type);
} else if(sTaskQueues[task.type].length === 0) {
// report error if queue is empty
forge.log.error(cat,
'[%s][%s] task queue empty [%s]',
task.id, task.name, task.type);
} else if(sTaskQueues[task.type][0] !== task) {
// report error if this task isn't the first in the queue
forge.log.error(cat,
'[%s][%s] task not first in queue [%s]',
task.id, task.name, task.type);
} else {
// remove ourselves from the queue
sTaskQueues[task.type].shift();
// clean up queue if it is empty
if(sTaskQueues[task.type].length === 0) {
if(sVL >= 1) {
forge.log.verbose(cat, '[%s][%s] delete queue [%s]',
task.id, task.name, task.type);
}
/* Note: Only a task can delete a queue of its own type. This
is used as a way to synchronize tasks. If a queue for a certain
task type exists, then a task of that type is running.
*/
delete sTaskQueues[task.type];
} else {
// dequeue the next task and start it
if(sVL >= 1) {
forge.log.verbose(cat,
'[%s][%s] queue start next [%s] remain:%s',
task.id, task.name, task.type,
sTaskQueues[task.type].length);
}
sTaskQueues[task.type][0].start();
}
}
if(!suppressCallbacks) {
// call final callback if one exists
if(task.error && task.failureCallback) {
task.failureCallback(task);
} else if(!task.error && task.successCallback) {
task.successCallback(task);
}
}
}
} | javascript | function(task, suppressCallbacks) {
// subtask is now done
task.state = DONE;
delete sTasks[task.id];
if(sVL >= 1) {
forge.log.verbose(cat, '[%s][%s] finish',
task.id, task.name, task);
}
// only do queue processing for root tasks
if(task.parent === null) {
// report error if queue is missing
if(!(task.type in sTaskQueues)) {
forge.log.error(cat,
'[%s][%s] task queue missing [%s]',
task.id, task.name, task.type);
} else if(sTaskQueues[task.type].length === 0) {
// report error if queue is empty
forge.log.error(cat,
'[%s][%s] task queue empty [%s]',
task.id, task.name, task.type);
} else if(sTaskQueues[task.type][0] !== task) {
// report error if this task isn't the first in the queue
forge.log.error(cat,
'[%s][%s] task not first in queue [%s]',
task.id, task.name, task.type);
} else {
// remove ourselves from the queue
sTaskQueues[task.type].shift();
// clean up queue if it is empty
if(sTaskQueues[task.type].length === 0) {
if(sVL >= 1) {
forge.log.verbose(cat, '[%s][%s] delete queue [%s]',
task.id, task.name, task.type);
}
/* Note: Only a task can delete a queue of its own type. This
is used as a way to synchronize tasks. If a queue for a certain
task type exists, then a task of that type is running.
*/
delete sTaskQueues[task.type];
} else {
// dequeue the next task and start it
if(sVL >= 1) {
forge.log.verbose(cat,
'[%s][%s] queue start next [%s] remain:%s',
task.id, task.name, task.type,
sTaskQueues[task.type].length);
}
sTaskQueues[task.type][0].start();
}
}
if(!suppressCallbacks) {
// call final callback if one exists
if(task.error && task.failureCallback) {
task.failureCallback(task);
} else if(!task.error && task.successCallback) {
task.successCallback(task);
}
}
}
} | [
"function",
"(",
"task",
",",
"suppressCallbacks",
")",
"{",
"// subtask is now done",
"task",
".",
"state",
"=",
"DONE",
";",
"delete",
"sTasks",
"[",
"task",
".",
"id",
"]",
";",
"if",
"(",
"sVL",
">=",
"1",
")",
"{",
"forge",
".",
"log",
".",
"verbose",
"(",
"cat",
",",
"'[%s][%s] finish'",
",",
"task",
".",
"id",
",",
"task",
".",
"name",
",",
"task",
")",
";",
"}",
"// only do queue processing for root tasks",
"if",
"(",
"task",
".",
"parent",
"===",
"null",
")",
"{",
"// report error if queue is missing",
"if",
"(",
"!",
"(",
"task",
".",
"type",
"in",
"sTaskQueues",
")",
")",
"{",
"forge",
".",
"log",
".",
"error",
"(",
"cat",
",",
"'[%s][%s] task queue missing [%s]'",
",",
"task",
".",
"id",
",",
"task",
".",
"name",
",",
"task",
".",
"type",
")",
";",
"}",
"else",
"if",
"(",
"sTaskQueues",
"[",
"task",
".",
"type",
"]",
".",
"length",
"===",
"0",
")",
"{",
"// report error if queue is empty",
"forge",
".",
"log",
".",
"error",
"(",
"cat",
",",
"'[%s][%s] task queue empty [%s]'",
",",
"task",
".",
"id",
",",
"task",
".",
"name",
",",
"task",
".",
"type",
")",
";",
"}",
"else",
"if",
"(",
"sTaskQueues",
"[",
"task",
".",
"type",
"]",
"[",
"0",
"]",
"!==",
"task",
")",
"{",
"// report error if this task isn't the first in the queue",
"forge",
".",
"log",
".",
"error",
"(",
"cat",
",",
"'[%s][%s] task not first in queue [%s]'",
",",
"task",
".",
"id",
",",
"task",
".",
"name",
",",
"task",
".",
"type",
")",
";",
"}",
"else",
"{",
"// remove ourselves from the queue",
"sTaskQueues",
"[",
"task",
".",
"type",
"]",
".",
"shift",
"(",
")",
";",
"// clean up queue if it is empty",
"if",
"(",
"sTaskQueues",
"[",
"task",
".",
"type",
"]",
".",
"length",
"===",
"0",
")",
"{",
"if",
"(",
"sVL",
">=",
"1",
")",
"{",
"forge",
".",
"log",
".",
"verbose",
"(",
"cat",
",",
"'[%s][%s] delete queue [%s]'",
",",
"task",
".",
"id",
",",
"task",
".",
"name",
",",
"task",
".",
"type",
")",
";",
"}",
"/* Note: Only a task can delete a queue of its own type. This\n is used as a way to synchronize tasks. If a queue for a certain\n task type exists, then a task of that type is running.\n */",
"delete",
"sTaskQueues",
"[",
"task",
".",
"type",
"]",
";",
"}",
"else",
"{",
"// dequeue the next task and start it",
"if",
"(",
"sVL",
">=",
"1",
")",
"{",
"forge",
".",
"log",
".",
"verbose",
"(",
"cat",
",",
"'[%s][%s] queue start next [%s] remain:%s'",
",",
"task",
".",
"id",
",",
"task",
".",
"name",
",",
"task",
".",
"type",
",",
"sTaskQueues",
"[",
"task",
".",
"type",
"]",
".",
"length",
")",
";",
"}",
"sTaskQueues",
"[",
"task",
".",
"type",
"]",
"[",
"0",
"]",
".",
"start",
"(",
")",
";",
"}",
"}",
"if",
"(",
"!",
"suppressCallbacks",
")",
"{",
"// call final callback if one exists",
"if",
"(",
"task",
".",
"error",
"&&",
"task",
".",
"failureCallback",
")",
"{",
"task",
".",
"failureCallback",
"(",
"task",
")",
";",
"}",
"else",
"if",
"(",
"!",
"task",
".",
"error",
"&&",
"task",
".",
"successCallback",
")",
"{",
"task",
".",
"successCallback",
"(",
"task",
")",
";",
"}",
"}",
"}",
"}"
] | Finishes a task and looks for the next task in the queue to start.
@param task the task to finish.
@param suppressCallbacks true to suppress callbacks. | [
"Finishes",
"a",
"task",
"and",
"looks",
"for",
"the",
"next",
"task",
"in",
"the",
"queue",
"to",
"start",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L26173-L26235 |
|
56,448 | mgesmundo/authorify-client | build/authorify.js | function() {
var cert;
try {
cert = this.keychain.getCertPem();
} catch (e) {
throw new CError({
body: {
code: 'ImATeapot',
message: 'missing certificate',
cause: e
}
}).log('body');
}
if (!cert) {
throw new CError('missing certificate').log();
}
if (!this.getDate()) {
throw new CError('missing date').log();
}
if (!this.getSid()) {
throw new CError('missing session identifier').log();
}
if (!this.getId()) {
throw new CError('missing id').log();
}
if (!this.getApp()) {
throw new CError('missing app').log();
}
var tmp = this.getDate() + '::' + cert +'::' + this.getSid() + '::' + this.getId() + '::' + this.getApp() + '::';
if (this._reply) {
// NOTE: username is not mandatory in non browser environment
// NOTE: SECRET_SERVER is present only when the client is used inside the authorify module
var username = this.getUsername();
if (!username) {
username = 'anonymous';
}
var password = this.getPassword();
if (!password) {
password = forge.util.encode64(forge.random.getBytesSync(16));
}
tmp += username + '::' + password + '::' + SECRET_SERVER;
} else {
tmp += SECRET_CLIENT;
}
var hmac = forge.hmac.create();
hmac.start('sha256', SECRET);
hmac.update(tmp);
return hmac.digest().toHex();
} | javascript | function() {
var cert;
try {
cert = this.keychain.getCertPem();
} catch (e) {
throw new CError({
body: {
code: 'ImATeapot',
message: 'missing certificate',
cause: e
}
}).log('body');
}
if (!cert) {
throw new CError('missing certificate').log();
}
if (!this.getDate()) {
throw new CError('missing date').log();
}
if (!this.getSid()) {
throw new CError('missing session identifier').log();
}
if (!this.getId()) {
throw new CError('missing id').log();
}
if (!this.getApp()) {
throw new CError('missing app').log();
}
var tmp = this.getDate() + '::' + cert +'::' + this.getSid() + '::' + this.getId() + '::' + this.getApp() + '::';
if (this._reply) {
// NOTE: username is not mandatory in non browser environment
// NOTE: SECRET_SERVER is present only when the client is used inside the authorify module
var username = this.getUsername();
if (!username) {
username = 'anonymous';
}
var password = this.getPassword();
if (!password) {
password = forge.util.encode64(forge.random.getBytesSync(16));
}
tmp += username + '::' + password + '::' + SECRET_SERVER;
} else {
tmp += SECRET_CLIENT;
}
var hmac = forge.hmac.create();
hmac.start('sha256', SECRET);
hmac.update(tmp);
return hmac.digest().toHex();
} | [
"function",
"(",
")",
"{",
"var",
"cert",
";",
"try",
"{",
"cert",
"=",
"this",
".",
"keychain",
".",
"getCertPem",
"(",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"throw",
"new",
"CError",
"(",
"{",
"body",
":",
"{",
"code",
":",
"'ImATeapot'",
",",
"message",
":",
"'missing certificate'",
",",
"cause",
":",
"e",
"}",
"}",
")",
".",
"log",
"(",
"'body'",
")",
";",
"}",
"if",
"(",
"!",
"cert",
")",
"{",
"throw",
"new",
"CError",
"(",
"'missing certificate'",
")",
".",
"log",
"(",
")",
";",
"}",
"if",
"(",
"!",
"this",
".",
"getDate",
"(",
")",
")",
"{",
"throw",
"new",
"CError",
"(",
"'missing date'",
")",
".",
"log",
"(",
")",
";",
"}",
"if",
"(",
"!",
"this",
".",
"getSid",
"(",
")",
")",
"{",
"throw",
"new",
"CError",
"(",
"'missing session identifier'",
")",
".",
"log",
"(",
")",
";",
"}",
"if",
"(",
"!",
"this",
".",
"getId",
"(",
")",
")",
"{",
"throw",
"new",
"CError",
"(",
"'missing id'",
")",
".",
"log",
"(",
")",
";",
"}",
"if",
"(",
"!",
"this",
".",
"getApp",
"(",
")",
")",
"{",
"throw",
"new",
"CError",
"(",
"'missing app'",
")",
".",
"log",
"(",
")",
";",
"}",
"var",
"tmp",
"=",
"this",
".",
"getDate",
"(",
")",
"+",
"'::'",
"+",
"cert",
"+",
"'::'",
"+",
"this",
".",
"getSid",
"(",
")",
"+",
"'::'",
"+",
"this",
".",
"getId",
"(",
")",
"+",
"'::'",
"+",
"this",
".",
"getApp",
"(",
")",
"+",
"'::'",
";",
"if",
"(",
"this",
".",
"_reply",
")",
"{",
"// NOTE: username is not mandatory in non browser environment",
"// NOTE: SECRET_SERVER is present only when the client is used inside the authorify module",
"var",
"username",
"=",
"this",
".",
"getUsername",
"(",
")",
";",
"if",
"(",
"!",
"username",
")",
"{",
"username",
"=",
"'anonymous'",
";",
"}",
"var",
"password",
"=",
"this",
".",
"getPassword",
"(",
")",
";",
"if",
"(",
"!",
"password",
")",
"{",
"password",
"=",
"forge",
".",
"util",
".",
"encode64",
"(",
"forge",
".",
"random",
".",
"getBytesSync",
"(",
"16",
")",
")",
";",
"}",
"tmp",
"+=",
"username",
"+",
"'::'",
"+",
"password",
"+",
"'::'",
"+",
"SECRET_SERVER",
";",
"}",
"else",
"{",
"tmp",
"+=",
"SECRET_CLIENT",
";",
"}",
"var",
"hmac",
"=",
"forge",
".",
"hmac",
".",
"create",
"(",
")",
";",
"hmac",
".",
"start",
"(",
"'sha256'",
",",
"SECRET",
")",
";",
"hmac",
".",
"update",
"(",
"tmp",
")",
";",
"return",
"hmac",
".",
"digest",
"(",
")",
".",
"toHex",
"(",
")",
";",
"}"
] | Generate a new token
@returns {String} The generated token | [
"Generate",
"a",
"new",
"token"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L29468-L29516 |
|
56,449 | mgesmundo/authorify-client | build/authorify.js | function(data) {
if (!(data && 'function' === typeof data.isBase64 && data.isBase64())) {
throw new CError('wrong data format to decrypt').log();
}
return JSON.parse(this.encoder.decryptAes(data, this.getSecret()));
} | javascript | function(data) {
if (!(data && 'function' === typeof data.isBase64 && data.isBase64())) {
throw new CError('wrong data format to decrypt').log();
}
return JSON.parse(this.encoder.decryptAes(data, this.getSecret()));
} | [
"function",
"(",
"data",
")",
"{",
"if",
"(",
"!",
"(",
"data",
"&&",
"'function'",
"===",
"typeof",
"data",
".",
"isBase64",
"&&",
"data",
".",
"isBase64",
"(",
")",
")",
")",
"{",
"throw",
"new",
"CError",
"(",
"'wrong data format to decrypt'",
")",
".",
"log",
"(",
")",
";",
"}",
"return",
"JSON",
".",
"parse",
"(",
"this",
".",
"encoder",
".",
"decryptAes",
"(",
"data",
",",
"this",
".",
"getSecret",
"(",
")",
")",
")",
";",
"}"
] | Decrypt content.
@param {String} The data to decrypt
@return {Object} The decrypted result | [
"Decrypt",
"content",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L29599-L29604 |
|
56,450 | mgesmundo/authorify-client | build/authorify.js | getConfigOptions | function getConfigOptions(opts) {
opts = formatOptions(opts);
_.forEach(config, function(value, key) {
opts[key] = opts[key] || value;
});
opts.headers = opts.headers || {};
return opts;
} | javascript | function getConfigOptions(opts) {
opts = formatOptions(opts);
_.forEach(config, function(value, key) {
opts[key] = opts[key] || value;
});
opts.headers = opts.headers || {};
return opts;
} | [
"function",
"getConfigOptions",
"(",
"opts",
")",
"{",
"opts",
"=",
"formatOptions",
"(",
"opts",
")",
";",
"_",
".",
"forEach",
"(",
"config",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"opts",
"[",
"key",
"]",
"=",
"opts",
"[",
"key",
"]",
"||",
"value",
";",
"}",
")",
";",
"opts",
".",
"headers",
"=",
"opts",
".",
"headers",
"||",
"{",
"}",
";",
"return",
"opts",
";",
"}"
] | Get all options with default values if empty
@param {Object/String} opts The options object or string with the required name
@returns {Object} The configuration with default values
@private
@ignore | [
"Get",
"all",
"options",
"with",
"default",
"values",
"if",
"empty"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L30469-L30477 |
56,451 | mgesmundo/authorify-client | build/authorify.js | fixRequestOptions | function fixRequestOptions(method, path, transport, plain, callback) {
var opts = {
method: method,
path: path
};
if (_.isFunction(transport)) {
opts.callback = transport;
opts.plain = false;
opts.transport = 'http';
} else {
if (_.isString(transport)) {
opts.transport = transport;
} else if (_.isBoolean(transport)) {
opts.plain = transport;
}
if (_.isFunction(plain)) {
opts.callback = plain;
opts.plain = opts.plain || false;
} else if (_.isBoolean(plain)) {
opts.callback = callback;
opts.plain = plain;
}
}
return opts;
} | javascript | function fixRequestOptions(method, path, transport, plain, callback) {
var opts = {
method: method,
path: path
};
if (_.isFunction(transport)) {
opts.callback = transport;
opts.plain = false;
opts.transport = 'http';
} else {
if (_.isString(transport)) {
opts.transport = transport;
} else if (_.isBoolean(transport)) {
opts.plain = transport;
}
if (_.isFunction(plain)) {
opts.callback = plain;
opts.plain = opts.plain || false;
} else if (_.isBoolean(plain)) {
opts.callback = callback;
opts.plain = plain;
}
}
return opts;
} | [
"function",
"fixRequestOptions",
"(",
"method",
",",
"path",
",",
"transport",
",",
"plain",
",",
"callback",
")",
"{",
"var",
"opts",
"=",
"{",
"method",
":",
"method",
",",
"path",
":",
"path",
"}",
";",
"if",
"(",
"_",
".",
"isFunction",
"(",
"transport",
")",
")",
"{",
"opts",
".",
"callback",
"=",
"transport",
";",
"opts",
".",
"plain",
"=",
"false",
";",
"opts",
".",
"transport",
"=",
"'http'",
";",
"}",
"else",
"{",
"if",
"(",
"_",
".",
"isString",
"(",
"transport",
")",
")",
"{",
"opts",
".",
"transport",
"=",
"transport",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isBoolean",
"(",
"transport",
")",
")",
"{",
"opts",
".",
"plain",
"=",
"transport",
";",
"}",
"if",
"(",
"_",
".",
"isFunction",
"(",
"plain",
")",
")",
"{",
"opts",
".",
"callback",
"=",
"plain",
";",
"opts",
".",
"plain",
"=",
"opts",
".",
"plain",
"||",
"false",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isBoolean",
"(",
"plain",
")",
")",
"{",
"opts",
".",
"callback",
"=",
"callback",
";",
"opts",
".",
"plain",
"=",
"plain",
";",
"}",
"}",
"return",
"opts",
";",
"}"
] | Make an object with all params
@param {String} method The required method
@param {String} path The required path
@param {String} [transport = 'http'] The transport protocol ('http' or 'ws')
@param {Boolean} [plain = false] The required plain
@param {Function} callback The required callback
@return {Object} An object with all params as properties
@private
@ignore | [
"Make",
"an",
"object",
"with",
"all",
"params"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L30491-L30515 |
56,452 | mgesmundo/authorify-client | build/authorify.js | logResponse | function logResponse(err, res) {
if (err || (res && !res.ok)) {
if (err) {
log.warn('%s on response -> read plaintext body due an error (%s)', app.name, err.message);
} else {
log.warn('%s on response -> read plaintext body due an error (%s)', app.name, res.error);
}
} else if (res && !_.isEmpty(res.body)) {
if (res.body[my.config.encryptedBodyName]) {
log.info('%s on response -> read encrypted body', app.name);
} else {
log.info('%s on response -> read plaintext body', app.name);
}
}
} | javascript | function logResponse(err, res) {
if (err || (res && !res.ok)) {
if (err) {
log.warn('%s on response -> read plaintext body due an error (%s)', app.name, err.message);
} else {
log.warn('%s on response -> read plaintext body due an error (%s)', app.name, res.error);
}
} else if (res && !_.isEmpty(res.body)) {
if (res.body[my.config.encryptedBodyName]) {
log.info('%s on response -> read encrypted body', app.name);
} else {
log.info('%s on response -> read plaintext body', app.name);
}
}
} | [
"function",
"logResponse",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"err",
"||",
"(",
"res",
"&&",
"!",
"res",
".",
"ok",
")",
")",
"{",
"if",
"(",
"err",
")",
"{",
"log",
".",
"warn",
"(",
"'%s on response -> read plaintext body due an error (%s)'",
",",
"app",
".",
"name",
",",
"err",
".",
"message",
")",
";",
"}",
"else",
"{",
"log",
".",
"warn",
"(",
"'%s on response -> read plaintext body due an error (%s)'",
",",
"app",
".",
"name",
",",
"res",
".",
"error",
")",
";",
"}",
"}",
"else",
"if",
"(",
"res",
"&&",
"!",
"_",
".",
"isEmpty",
"(",
"res",
".",
"body",
")",
")",
"{",
"if",
"(",
"res",
".",
"body",
"[",
"my",
".",
"config",
".",
"encryptedBodyName",
"]",
")",
"{",
"log",
".",
"info",
"(",
"'%s on response -> read encrypted body'",
",",
"app",
".",
"name",
")",
";",
"}",
"else",
"{",
"log",
".",
"info",
"(",
"'%s on response -> read plaintext body'",
",",
"app",
".",
"name",
")",
";",
"}",
"}",
"}"
] | Log the response
@param {Object} err The error if occurred
@param {Object} res The response
@private
@ignore | [
"Log",
"the",
"response"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L30538-L30552 |
56,453 | mgesmundo/authorify-client | build/authorify.js | getModuleName | function getModuleName(module) {
var script = module.replace(/[^a-zA-Z0-9]/g, '.'),
parts = script.split('.'),
name = parts.shift();
if (parts.length) {
for (var p in parts) {
name += parts[p].charAt(0).toUpperCase() + parts[p].substr(1, parts[p].length);
}
}
return name;
} | javascript | function getModuleName(module) {
var script = module.replace(/[^a-zA-Z0-9]/g, '.'),
parts = script.split('.'),
name = parts.shift();
if (parts.length) {
for (var p in parts) {
name += parts[p].charAt(0).toUpperCase() + parts[p].substr(1, parts[p].length);
}
}
return name;
} | [
"function",
"getModuleName",
"(",
"module",
")",
"{",
"var",
"script",
"=",
"module",
".",
"replace",
"(",
"/",
"[^a-zA-Z0-9]",
"/",
"g",
",",
"'.'",
")",
",",
"parts",
"=",
"script",
".",
"split",
"(",
"'.'",
")",
",",
"name",
"=",
"parts",
".",
"shift",
"(",
")",
";",
"if",
"(",
"parts",
".",
"length",
")",
"{",
"for",
"(",
"var",
"p",
"in",
"parts",
")",
"{",
"name",
"+=",
"parts",
"[",
"p",
"]",
".",
"charAt",
"(",
"0",
")",
".",
"toUpperCase",
"(",
")",
"+",
"parts",
"[",
"p",
"]",
".",
"substr",
"(",
"1",
",",
"parts",
"[",
"p",
"]",
".",
"length",
")",
";",
"}",
"}",
"return",
"name",
";",
"}"
] | Formats the name of the module loaded into the browser
@param module {String} The original module name
@return {String} Name of the module
@private
@ignore | [
"Formats",
"the",
"name",
"of",
"the",
"module",
"loaded",
"into",
"the",
"browser"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L30562-L30573 |
56,454 | mgesmundo/authorify-client | build/authorify.js | function(opts) {
opts = opts || {};
var path = opts.path || this.path,
callback = opts.callback,
method = opts.method || this.method,
ws = getWebsocketPlugin(),
transports = app.config.transports,
self = this,
i = 0,
error,
response;
if (ws) {
if (transports && transports.length > 0) {
async.whilst(
function () {
return (i < transports.length);
},
function (done) {
self.doConnect(transports[i], method, path, function (err, res) {
error = err;
response = res;
if (!err && res) {
i = transports.length;
} else {
i++;
if (i < transports.length) {
delete self.request;
}
}
done();
});
},
function (err) {
callback(err || error, response);
}
);
} else {
error = 'no transport available';
log.error('%s %s', app.name, error);
callback(error);
}
} else {
this.doConnect('http', method, path, callback);
}
return this;
} | javascript | function(opts) {
opts = opts || {};
var path = opts.path || this.path,
callback = opts.callback,
method = opts.method || this.method,
ws = getWebsocketPlugin(),
transports = app.config.transports,
self = this,
i = 0,
error,
response;
if (ws) {
if (transports && transports.length > 0) {
async.whilst(
function () {
return (i < transports.length);
},
function (done) {
self.doConnect(transports[i], method, path, function (err, res) {
error = err;
response = res;
if (!err && res) {
i = transports.length;
} else {
i++;
if (i < transports.length) {
delete self.request;
}
}
done();
});
},
function (err) {
callback(err || error, response);
}
);
} else {
error = 'no transport available';
log.error('%s %s', app.name, error);
callback(error);
}
} else {
this.doConnect('http', method, path, callback);
}
return this;
} | [
"function",
"(",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"var",
"path",
"=",
"opts",
".",
"path",
"||",
"this",
".",
"path",
",",
"callback",
"=",
"opts",
".",
"callback",
",",
"method",
"=",
"opts",
".",
"method",
"||",
"this",
".",
"method",
",",
"ws",
"=",
"getWebsocketPlugin",
"(",
")",
",",
"transports",
"=",
"app",
".",
"config",
".",
"transports",
",",
"self",
"=",
"this",
",",
"i",
"=",
"0",
",",
"error",
",",
"response",
";",
"if",
"(",
"ws",
")",
"{",
"if",
"(",
"transports",
"&&",
"transports",
".",
"length",
">",
"0",
")",
"{",
"async",
".",
"whilst",
"(",
"function",
"(",
")",
"{",
"return",
"(",
"i",
"<",
"transports",
".",
"length",
")",
";",
"}",
",",
"function",
"(",
"done",
")",
"{",
"self",
".",
"doConnect",
"(",
"transports",
"[",
"i",
"]",
",",
"method",
",",
"path",
",",
"function",
"(",
"err",
",",
"res",
")",
"{",
"error",
"=",
"err",
";",
"response",
"=",
"res",
";",
"if",
"(",
"!",
"err",
"&&",
"res",
")",
"{",
"i",
"=",
"transports",
".",
"length",
";",
"}",
"else",
"{",
"i",
"++",
";",
"if",
"(",
"i",
"<",
"transports",
".",
"length",
")",
"{",
"delete",
"self",
".",
"request",
";",
"}",
"}",
"done",
"(",
")",
";",
"}",
")",
";",
"}",
",",
"function",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
"||",
"error",
",",
"response",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"error",
"=",
"'no transport available'",
";",
"log",
".",
"error",
"(",
"'%s %s'",
",",
"app",
".",
"name",
",",
"error",
")",
";",
"callback",
"(",
"error",
")",
";",
"}",
"}",
"else",
"{",
"this",
".",
"doConnect",
"(",
"'http'",
",",
"method",
",",
"path",
",",
"callback",
")",
";",
"}",
"return",
"this",
";",
"}"
] | A request without Authorization header
@inheritdoc #authorize
@private | [
"A",
"request",
"without",
"Authorization",
"header"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L30885-L30931 |
|
56,455 | mgesmundo/authorify-client | build/authorify.js | function(value) {
if (value) {
if (config.encryptQuery) {
this._pendingQuery = this._pendingQuery || [];
this._pendingQuery.push(value);
} else {
this.request.query(value);
}
}
return this;
} | javascript | function(value) {
if (value) {
if (config.encryptQuery) {
this._pendingQuery = this._pendingQuery || [];
this._pendingQuery.push(value);
} else {
this.request.query(value);
}
}
return this;
} | [
"function",
"(",
"value",
")",
"{",
"if",
"(",
"value",
")",
"{",
"if",
"(",
"config",
".",
"encryptQuery",
")",
"{",
"this",
".",
"_pendingQuery",
"=",
"this",
".",
"_pendingQuery",
"||",
"[",
"]",
";",
"this",
".",
"_pendingQuery",
".",
"push",
"(",
"value",
")",
";",
"}",
"else",
"{",
"this",
".",
"request",
".",
"query",
"(",
"value",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] | Compose a query-string
## Example
To compose a query-string like "?format=json&data=here" in a GET request:
var client = require('authorify-client')({
// set your options
});
client
.get('/someroute')
.query({ format: 'json' })
.query({ data: 'here' })
.end(function(err, res){
// your logic
});
@chainable
@param {Object} value The object to compose the query
@return {Client} The client instance | [
"Compose",
"a",
"query",
"-",
"string"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L31144-L31154 |
|
56,456 | mgesmundo/authorify-client | build/authorify.js | function(callback) {
if (res.session && res.session.cert) {
if (res.parsedHeader.payload.mode === 'handshake') {
if (my.config.crypter.verifyCertificate(res.session.cert)) {
callback(null);
} else {
callback('unknown certificate');
}
} else {
callback(null);
}
} else {
callback('wrong session');
}
} | javascript | function(callback) {
if (res.session && res.session.cert) {
if (res.parsedHeader.payload.mode === 'handshake') {
if (my.config.crypter.verifyCertificate(res.session.cert)) {
callback(null);
} else {
callback('unknown certificate');
}
} else {
callback(null);
}
} else {
callback('wrong session');
}
} | [
"function",
"(",
"callback",
")",
"{",
"if",
"(",
"res",
".",
"session",
"&&",
"res",
".",
"session",
".",
"cert",
")",
"{",
"if",
"(",
"res",
".",
"parsedHeader",
".",
"payload",
".",
"mode",
"===",
"'handshake'",
")",
"{",
"if",
"(",
"my",
".",
"config",
".",
"crypter",
".",
"verifyCertificate",
"(",
"res",
".",
"session",
".",
"cert",
")",
")",
"{",
"callback",
"(",
"null",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"'unknown certificate'",
")",
";",
"}",
"}",
"else",
"{",
"callback",
"(",
"null",
")",
";",
"}",
"}",
"else",
"{",
"callback",
"(",
"'wrong session'",
")",
";",
"}",
"}"
] | verify certificate authenticity | [
"verify",
"certificate",
"authenticity"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L31326-L31340 |
|
56,457 | mgesmundo/authorify-client | build/authorify.js | function(callback) {
if (!res.parsedHeader.signature) {
callback('unsigned');
} else {
var signVerifier = new Crypter({
cert: res.session.cert
});
if (signVerifier.verifySignature(JSON.stringify(res.parsedHeader.content), res.parsedHeader.signature)) {
callback(null);
} else {
callback('forgery');
}
}
} | javascript | function(callback) {
if (!res.parsedHeader.signature) {
callback('unsigned');
} else {
var signVerifier = new Crypter({
cert: res.session.cert
});
if (signVerifier.verifySignature(JSON.stringify(res.parsedHeader.content), res.parsedHeader.signature)) {
callback(null);
} else {
callback('forgery');
}
}
} | [
"function",
"(",
"callback",
")",
"{",
"if",
"(",
"!",
"res",
".",
"parsedHeader",
".",
"signature",
")",
"{",
"callback",
"(",
"'unsigned'",
")",
";",
"}",
"else",
"{",
"var",
"signVerifier",
"=",
"new",
"Crypter",
"(",
"{",
"cert",
":",
"res",
".",
"session",
".",
"cert",
"}",
")",
";",
"if",
"(",
"signVerifier",
".",
"verifySignature",
"(",
"JSON",
".",
"stringify",
"(",
"res",
".",
"parsedHeader",
".",
"content",
")",
",",
"res",
".",
"parsedHeader",
".",
"signature",
")",
")",
"{",
"callback",
"(",
"null",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"'forgery'",
")",
";",
"}",
"}",
"}"
] | verify signature using sender certificate | [
"verify",
"signature",
"using",
"sender",
"certificate"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L31342-L31355 |
|
56,458 | mgesmundo/authorify-client | build/authorify.js | function(callback) {
if (parseInt(config.clockSkew, 10) > 0) {
var now = new Date().toSerialNumber(),
sent = res.parsedHeader.content.date;
if ((now - sent) > config.clockSkew * 1000) {
callback('date too old');
} else {
callback(null);
}
} else {
callback(null);
}
} | javascript | function(callback) {
if (parseInt(config.clockSkew, 10) > 0) {
var now = new Date().toSerialNumber(),
sent = res.parsedHeader.content.date;
if ((now - sent) > config.clockSkew * 1000) {
callback('date too old');
} else {
callback(null);
}
} else {
callback(null);
}
} | [
"function",
"(",
"callback",
")",
"{",
"if",
"(",
"parseInt",
"(",
"config",
".",
"clockSkew",
",",
"10",
")",
">",
"0",
")",
"{",
"var",
"now",
"=",
"new",
"Date",
"(",
")",
".",
"toSerialNumber",
"(",
")",
",",
"sent",
"=",
"res",
".",
"parsedHeader",
".",
"content",
".",
"date",
";",
"if",
"(",
"(",
"now",
"-",
"sent",
")",
">",
"config",
".",
"clockSkew",
"*",
"1000",
")",
"{",
"callback",
"(",
"'date too old'",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"null",
")",
";",
"}",
"}",
"else",
"{",
"callback",
"(",
"null",
")",
";",
"}",
"}"
] | verify the date | [
"verify",
"the",
"date"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L31357-L31369 |
|
56,459 | mgesmundo/authorify-client | build/authorify.js | function(secret) {
var keyIv;
if (!secret) {
throw new CError('missing secret').log();
}
// secret is a Base64 string
if(secret.isBase64()){
try {
keyIv = forge.util.decode64(secret);
} catch (e) {
throw new CError('secret not valid').log();
}
} else {
keyIv = secret;
}
return keyIv;
} | javascript | function(secret) {
var keyIv;
if (!secret) {
throw new CError('missing secret').log();
}
// secret is a Base64 string
if(secret.isBase64()){
try {
keyIv = forge.util.decode64(secret);
} catch (e) {
throw new CError('secret not valid').log();
}
} else {
keyIv = secret;
}
return keyIv;
} | [
"function",
"(",
"secret",
")",
"{",
"var",
"keyIv",
";",
"if",
"(",
"!",
"secret",
")",
"{",
"throw",
"new",
"CError",
"(",
"'missing secret'",
")",
".",
"log",
"(",
")",
";",
"}",
"// secret is a Base64 string",
"if",
"(",
"secret",
".",
"isBase64",
"(",
")",
")",
"{",
"try",
"{",
"keyIv",
"=",
"forge",
".",
"util",
".",
"decode64",
"(",
"secret",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"throw",
"new",
"CError",
"(",
"'secret not valid'",
")",
".",
"log",
"(",
")",
";",
"}",
"}",
"else",
"{",
"keyIv",
"=",
"secret",
";",
"}",
"return",
"keyIv",
";",
"}"
] | Get bytes from a secret key
@param {String} secret The secret in Base64 format
@return {Bytes} The secret bytes
@static
@private | [
"Get",
"bytes",
"from",
"a",
"secret",
"key"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L32309-L32325 |
|
56,460 | mgesmundo/authorify-client | build/authorify.js | function (data, scheme) {
// scheme = RSA-OAEP, RSAES-PKCS1-V1_5
scheme = scheme || SCHEME;
return forge.util.encode64(this._cert.publicKey.encrypt(data, scheme));
} | javascript | function (data, scheme) {
// scheme = RSA-OAEP, RSAES-PKCS1-V1_5
scheme = scheme || SCHEME;
return forge.util.encode64(this._cert.publicKey.encrypt(data, scheme));
} | [
"function",
"(",
"data",
",",
"scheme",
")",
"{",
"// scheme = RSA-OAEP, RSAES-PKCS1-V1_5",
"scheme",
"=",
"scheme",
"||",
"SCHEME",
";",
"return",
"forge",
".",
"util",
".",
"encode64",
"(",
"this",
".",
"_cert",
".",
"publicKey",
".",
"encrypt",
"(",
"data",
",",
"scheme",
")",
")",
";",
"}"
] | Encrypt data using RSA public key inside the X.509 certificate
@param {String} data The data to encrypt
@param {String} [scheme='RSA-OAEP'] The scheme to be used in encryption.
Use 'RSAES-PKCS1-V1_5' in legacy applications.
@return {String} The RSA encryption result in Base64 | [
"Encrypt",
"data",
"using",
"RSA",
"public",
"key",
"inside",
"the",
"X",
".",
"509",
"certificate"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L32413-L32417 |
|
56,461 | mgesmundo/authorify-client | build/authorify.js | function (data, scheme) {
scheme = scheme || SCHEME;
return this._key.decrypt(forge.util.decode64(data), scheme);
} | javascript | function (data, scheme) {
scheme = scheme || SCHEME;
return this._key.decrypt(forge.util.decode64(data), scheme);
} | [
"function",
"(",
"data",
",",
"scheme",
")",
"{",
"scheme",
"=",
"scheme",
"||",
"SCHEME",
";",
"return",
"this",
".",
"_key",
".",
"decrypt",
"(",
"forge",
".",
"util",
".",
"decode64",
"(",
"data",
")",
",",
"scheme",
")",
";",
"}"
] | Decrypt RSA encrypted data
@param {String} data The data to decrypt
@param {String} [scheme='RSA-OAEP'] The mode to use in decryption. 'RSA-OAEP', 'RSAES-PKCS1-V1_5' are allowed schemes.
@return {String} The decrypted data | [
"Decrypt",
"RSA",
"encrypted",
"data"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L32424-L32427 |
|
56,462 | mgesmundo/authorify-client | build/authorify.js | function (data, secret, encoder, mode) {
// mode = CBC, CFB, OFB, CTR
mode = mode || MODE;
var keyIv = this.getBytesFromSecret(secret);
var cipher = forge.aes.createEncryptionCipher(keyIv, mode);
cipher.start(keyIv);
cipher.update(forge.util.createBuffer(data));
cipher.finish();
if (encoder === 'url') {
return base64url(cipher.output.data);
}
return forge.util.encode64(cipher.output.data);
} | javascript | function (data, secret, encoder, mode) {
// mode = CBC, CFB, OFB, CTR
mode = mode || MODE;
var keyIv = this.getBytesFromSecret(secret);
var cipher = forge.aes.createEncryptionCipher(keyIv, mode);
cipher.start(keyIv);
cipher.update(forge.util.createBuffer(data));
cipher.finish();
if (encoder === 'url') {
return base64url(cipher.output.data);
}
return forge.util.encode64(cipher.output.data);
} | [
"function",
"(",
"data",
",",
"secret",
",",
"encoder",
",",
"mode",
")",
"{",
"// mode = CBC, CFB, OFB, CTR",
"mode",
"=",
"mode",
"||",
"MODE",
";",
"var",
"keyIv",
"=",
"this",
".",
"getBytesFromSecret",
"(",
"secret",
")",
";",
"var",
"cipher",
"=",
"forge",
".",
"aes",
".",
"createEncryptionCipher",
"(",
"keyIv",
",",
"mode",
")",
";",
"cipher",
".",
"start",
"(",
"keyIv",
")",
";",
"cipher",
".",
"update",
"(",
"forge",
".",
"util",
".",
"createBuffer",
"(",
"data",
")",
")",
";",
"cipher",
".",
"finish",
"(",
")",
";",
"if",
"(",
"encoder",
"===",
"'url'",
")",
"{",
"return",
"base64url",
"(",
"cipher",
".",
"output",
".",
"data",
")",
";",
"}",
"return",
"forge",
".",
"util",
".",
"encode64",
"(",
"cipher",
".",
"output",
".",
"data",
")",
";",
"}"
] | Encrypt data using AES cipher
@param {String} data The data to encrypt
@param {Bytes} secret The secret to use in encryption
@param {String} [encoder = 'base64'] base64 or url final encoding
@param {String} [mode = 'CTR'] The mode to use in encryption. 'CBC', 'CFB', 'OFB', 'CTR' are allowed modes.
@return {String} The AES encryption result in Base64 | [
"Encrypt",
"data",
"using",
"AES",
"cipher"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L32436-L32448 |
|
56,463 | mgesmundo/authorify-client | build/authorify.js | function (data, secret, encoder, mode) {
// mode = CBC, CFB, OFB, CTR
mode = mode || MODE;
var keyIv = this.getBytesFromSecret(secret);
var cipher = forge.aes.createDecryptionCipher(keyIv, mode);
cipher.start(keyIv);
var decoded;
if (encoder === 'url') {
decoded = base64url.decode(data);
} else {
decoded = forge.util.decode64(data);
}
cipher.update(forge.util.createBuffer(decoded));
cipher.finish();
return cipher.output.data;
} | javascript | function (data, secret, encoder, mode) {
// mode = CBC, CFB, OFB, CTR
mode = mode || MODE;
var keyIv = this.getBytesFromSecret(secret);
var cipher = forge.aes.createDecryptionCipher(keyIv, mode);
cipher.start(keyIv);
var decoded;
if (encoder === 'url') {
decoded = base64url.decode(data);
} else {
decoded = forge.util.decode64(data);
}
cipher.update(forge.util.createBuffer(decoded));
cipher.finish();
return cipher.output.data;
} | [
"function",
"(",
"data",
",",
"secret",
",",
"encoder",
",",
"mode",
")",
"{",
"// mode = CBC, CFB, OFB, CTR",
"mode",
"=",
"mode",
"||",
"MODE",
";",
"var",
"keyIv",
"=",
"this",
".",
"getBytesFromSecret",
"(",
"secret",
")",
";",
"var",
"cipher",
"=",
"forge",
".",
"aes",
".",
"createDecryptionCipher",
"(",
"keyIv",
",",
"mode",
")",
";",
"cipher",
".",
"start",
"(",
"keyIv",
")",
";",
"var",
"decoded",
";",
"if",
"(",
"encoder",
"===",
"'url'",
")",
"{",
"decoded",
"=",
"base64url",
".",
"decode",
"(",
"data",
")",
";",
"}",
"else",
"{",
"decoded",
"=",
"forge",
".",
"util",
".",
"decode64",
"(",
"data",
")",
";",
"}",
"cipher",
".",
"update",
"(",
"forge",
".",
"util",
".",
"createBuffer",
"(",
"decoded",
")",
")",
";",
"cipher",
".",
"finish",
"(",
")",
";",
"return",
"cipher",
".",
"output",
".",
"data",
";",
"}"
] | Decrypt AES encrypted data
@param {String} data The data to decrypt
@param {String} secret The secret to use in decryption in Base64 format
@param {String} [encoder = 'base64'] base64 or url encoding
@param {String} [mode='CTR'] The mode to use in decryption. 'CBC', 'CFB', 'OFB', 'CTR' are allowed modes.
@return {String} The decrypted data | [
"Decrypt",
"AES",
"encrypted",
"data"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L32457-L32472 |
|
56,464 | mgesmundo/authorify-client | build/authorify.js | function (pem) {
var certificate = forge.pki.certificateFromPem(pem);
var issuerCert = caStore.getIssuer(certificate);
if (issuerCert) {
try {
return issuerCert.verify(certificate);
} catch (e) {
return false;
}
}
return false;
} | javascript | function (pem) {
var certificate = forge.pki.certificateFromPem(pem);
var issuerCert = caStore.getIssuer(certificate);
if (issuerCert) {
try {
return issuerCert.verify(certificate);
} catch (e) {
return false;
}
}
return false;
} | [
"function",
"(",
"pem",
")",
"{",
"var",
"certificate",
"=",
"forge",
".",
"pki",
".",
"certificateFromPem",
"(",
"pem",
")",
";",
"var",
"issuerCert",
"=",
"caStore",
".",
"getIssuer",
"(",
"certificate",
")",
";",
"if",
"(",
"issuerCert",
")",
"{",
"try",
"{",
"return",
"issuerCert",
".",
"verify",
"(",
"certificate",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Verify that a X.509 certificate is generated by the CA
@param {String} pem The certificate to verify in pem format
@returns {Boolean} True if the X.509 certificate is original | [
"Verify",
"that",
"a",
"X",
".",
"509",
"certificate",
"is",
"generated",
"by",
"the",
"CA"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L32503-L32514 |
|
56,465 | molecuel/mlcl_collections | index.js | function () {
var self = this;
this.collectionRegistry = {};
// emit molecuel elements pre init event
molecuel.emit('mlcl::collections::init:pre', self);
/**
* Schema directory config
*/
if (molecuel.config.collections && molecuel.config.collections.collectionDir) {
this.collectionDir = molecuel.config.collections.collectionDir;
}
/**
* Execute after successful elasticsearch connection
*/
molecuel.on('mlcl::elements::init:post', function (elements) {
// add the access to all the db's and searchfunctionality
self.elements = elements;
self.elastic = elements.elastic;
self.database = elements.database;
self.registerCollections();
molecuel.emit('mlcl::collections::init:post', self);
});
//register block handler
molecuel.on('mlcl::blocks::init:modules', function(blocks) {
blocks.registerTypeHandler('collection', self.block);
});
return this;
} | javascript | function () {
var self = this;
this.collectionRegistry = {};
// emit molecuel elements pre init event
molecuel.emit('mlcl::collections::init:pre', self);
/**
* Schema directory config
*/
if (molecuel.config.collections && molecuel.config.collections.collectionDir) {
this.collectionDir = molecuel.config.collections.collectionDir;
}
/**
* Execute after successful elasticsearch connection
*/
molecuel.on('mlcl::elements::init:post', function (elements) {
// add the access to all the db's and searchfunctionality
self.elements = elements;
self.elastic = elements.elastic;
self.database = elements.database;
self.registerCollections();
molecuel.emit('mlcl::collections::init:post', self);
});
//register block handler
molecuel.on('mlcl::blocks::init:modules', function(blocks) {
blocks.registerTypeHandler('collection', self.block);
});
return this;
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"collectionRegistry",
"=",
"{",
"}",
";",
"// emit molecuel elements pre init event",
"molecuel",
".",
"emit",
"(",
"'mlcl::collections::init:pre'",
",",
"self",
")",
";",
"/**\n * Schema directory config\n */",
"if",
"(",
"molecuel",
".",
"config",
".",
"collections",
"&&",
"molecuel",
".",
"config",
".",
"collections",
".",
"collectionDir",
")",
"{",
"this",
".",
"collectionDir",
"=",
"molecuel",
".",
"config",
".",
"collections",
".",
"collectionDir",
";",
"}",
"/**\n * Execute after successful elasticsearch connection\n */",
"molecuel",
".",
"on",
"(",
"'mlcl::elements::init:post'",
",",
"function",
"(",
"elements",
")",
"{",
"// add the access to all the db's and searchfunctionality",
"self",
".",
"elements",
"=",
"elements",
";",
"self",
".",
"elastic",
"=",
"elements",
".",
"elastic",
";",
"self",
".",
"database",
"=",
"elements",
".",
"database",
";",
"self",
".",
"registerCollections",
"(",
")",
";",
"molecuel",
".",
"emit",
"(",
"'mlcl::collections::init:post'",
",",
"self",
")",
";",
"}",
")",
";",
"//register block handler",
"molecuel",
".",
"on",
"(",
"'mlcl::blocks::init:modules'",
",",
"function",
"(",
"blocks",
")",
"{",
"blocks",
".",
"registerTypeHandler",
"(",
"'collection'",
",",
"self",
".",
"block",
")",
";",
"}",
")",
";",
"return",
"this",
";",
"}"
] | This module serves the molecuel elements the type definition for database objects
@todo implement the dynamic generation of elements
@constructor | [
"This",
"module",
"serves",
"the",
"molecuel",
"elements",
"the",
"type",
"definition",
"for",
"database",
"objects"
] | 4b3160b1af1632ff3121ad5a1da2b3c70beb2466 | https://github.com/molecuel/mlcl_collections/blob/4b3160b1af1632ff3121ad5a1da2b3c70beb2466/index.js#L18-L50 |
|
56,466 | gummesson/ez-map | index.js | EzMap | function EzMap(arr) {
this._keys = []
this._values = []
if (isArray(arr) && arr.length)
this._initial(arr)
} | javascript | function EzMap(arr) {
this._keys = []
this._values = []
if (isArray(arr) && arr.length)
this._initial(arr)
} | [
"function",
"EzMap",
"(",
"arr",
")",
"{",
"this",
".",
"_keys",
"=",
"[",
"]",
"this",
".",
"_values",
"=",
"[",
"]",
"if",
"(",
"isArray",
"(",
"arr",
")",
"&&",
"arr",
".",
"length",
")",
"this",
".",
"_initial",
"(",
"arr",
")",
"}"
] | Initialize `EzMap`.
@constructor
@param {array} [arr]
@api public | [
"Initialize",
"EzMap",
"."
] | 268157f1b78119d2d7e7e14b35e5283f80c0174a | https://github.com/gummesson/ez-map/blob/268157f1b78119d2d7e7e14b35e5283f80c0174a/index.js#L16-L21 |
56,467 | antonycourtney/tabli-core | src/js/tabWindow.js | getOpenTabInfo | function getOpenTabInfo(tabItems, openTabs) {
const chromeOpenTabItems = Immutable.Seq(openTabs.map(makeOpenTabItem));
// console.log("getOpenTabInfo: openTabs: ", openTabs);
// console.log("getOpenTabInfo: chromeOpenTabItems: " + JSON.stringify(chromeOpenTabItems,null,4));
const openUrlMap = Immutable.Map(chromeOpenTabItems.groupBy((ti) => ti.url));
// console.log("getOpenTabInfo: openUrlMap: ", openUrlMap.toJS());
// Now we need to do two things:
// 1. augment chromeOpenTabItems with bookmark Ids / saved state (if it exists)
// 2. figure out which savedTabItems are not in openTabs
const savedItems = tabItems.filter((ti) => ti.saved);
// Restore the saved items to their base state (no open tab info), since we
// only want to pick up open tab info from what was passed in in openTabs
const baseSavedItems = savedItems.map(resetSavedItem);
// The entries in savedUrlMap *should* be singletons, but we'll use groupBy to
// get a type-compatible Seq so that we can merge with openUrlMap using
// mergeWith:
const savedUrlMap = Immutable.Map(baseSavedItems.groupBy((ti) => ti.url));
// console.log("getOpenTabInfo: savedUrlMap : " + savedUrlMap.toJS());
function mergeTabItems(openItems, mergeSavedItems) {
const savedItem = mergeSavedItems.get(0);
return openItems.map((openItem) => openItem.set('saved', true)
.set('savedBookmarkId', savedItem.savedBookmarkId)
.set('savedBookmarkIndex', savedItem.savedBookmarkIndex)
.set('savedTitle', savedItem.savedTitle));
}
const mergedMap = openUrlMap.mergeWith(mergeTabItems, savedUrlMap);
// console.log("mergedMap: ", mergedMap.toJS());
// console.log("getOpenTabInfo: mergedMap :" + JSON.stringify(mergedMap,null,4));
// partition mergedMap into open and closed tabItems:
const partitionedMap = mergedMap.toIndexedSeq().flatten(true).groupBy((ti) => ti.open);
// console.log("partitionedMap: ", partitionedMap.toJS());
return partitionedMap;
} | javascript | function getOpenTabInfo(tabItems, openTabs) {
const chromeOpenTabItems = Immutable.Seq(openTabs.map(makeOpenTabItem));
// console.log("getOpenTabInfo: openTabs: ", openTabs);
// console.log("getOpenTabInfo: chromeOpenTabItems: " + JSON.stringify(chromeOpenTabItems,null,4));
const openUrlMap = Immutable.Map(chromeOpenTabItems.groupBy((ti) => ti.url));
// console.log("getOpenTabInfo: openUrlMap: ", openUrlMap.toJS());
// Now we need to do two things:
// 1. augment chromeOpenTabItems with bookmark Ids / saved state (if it exists)
// 2. figure out which savedTabItems are not in openTabs
const savedItems = tabItems.filter((ti) => ti.saved);
// Restore the saved items to their base state (no open tab info), since we
// only want to pick up open tab info from what was passed in in openTabs
const baseSavedItems = savedItems.map(resetSavedItem);
// The entries in savedUrlMap *should* be singletons, but we'll use groupBy to
// get a type-compatible Seq so that we can merge with openUrlMap using
// mergeWith:
const savedUrlMap = Immutable.Map(baseSavedItems.groupBy((ti) => ti.url));
// console.log("getOpenTabInfo: savedUrlMap : " + savedUrlMap.toJS());
function mergeTabItems(openItems, mergeSavedItems) {
const savedItem = mergeSavedItems.get(0);
return openItems.map((openItem) => openItem.set('saved', true)
.set('savedBookmarkId', savedItem.savedBookmarkId)
.set('savedBookmarkIndex', savedItem.savedBookmarkIndex)
.set('savedTitle', savedItem.savedTitle));
}
const mergedMap = openUrlMap.mergeWith(mergeTabItems, savedUrlMap);
// console.log("mergedMap: ", mergedMap.toJS());
// console.log("getOpenTabInfo: mergedMap :" + JSON.stringify(mergedMap,null,4));
// partition mergedMap into open and closed tabItems:
const partitionedMap = mergedMap.toIndexedSeq().flatten(true).groupBy((ti) => ti.open);
// console.log("partitionedMap: ", partitionedMap.toJS());
return partitionedMap;
} | [
"function",
"getOpenTabInfo",
"(",
"tabItems",
",",
"openTabs",
")",
"{",
"const",
"chromeOpenTabItems",
"=",
"Immutable",
".",
"Seq",
"(",
"openTabs",
".",
"map",
"(",
"makeOpenTabItem",
")",
")",
";",
"// console.log(\"getOpenTabInfo: openTabs: \", openTabs);",
"// console.log(\"getOpenTabInfo: chromeOpenTabItems: \" + JSON.stringify(chromeOpenTabItems,null,4));",
"const",
"openUrlMap",
"=",
"Immutable",
".",
"Map",
"(",
"chromeOpenTabItems",
".",
"groupBy",
"(",
"(",
"ti",
")",
"=>",
"ti",
".",
"url",
")",
")",
";",
"// console.log(\"getOpenTabInfo: openUrlMap: \", openUrlMap.toJS());",
"// Now we need to do two things:",
"// 1. augment chromeOpenTabItems with bookmark Ids / saved state (if it exists)",
"// 2. figure out which savedTabItems are not in openTabs",
"const",
"savedItems",
"=",
"tabItems",
".",
"filter",
"(",
"(",
"ti",
")",
"=>",
"ti",
".",
"saved",
")",
";",
"// Restore the saved items to their base state (no open tab info), since we",
"// only want to pick up open tab info from what was passed in in openTabs",
"const",
"baseSavedItems",
"=",
"savedItems",
".",
"map",
"(",
"resetSavedItem",
")",
";",
"// The entries in savedUrlMap *should* be singletons, but we'll use groupBy to",
"// get a type-compatible Seq so that we can merge with openUrlMap using",
"// mergeWith:",
"const",
"savedUrlMap",
"=",
"Immutable",
".",
"Map",
"(",
"baseSavedItems",
".",
"groupBy",
"(",
"(",
"ti",
")",
"=>",
"ti",
".",
"url",
")",
")",
";",
"// console.log(\"getOpenTabInfo: savedUrlMap : \" + savedUrlMap.toJS());",
"function",
"mergeTabItems",
"(",
"openItems",
",",
"mergeSavedItems",
")",
"{",
"const",
"savedItem",
"=",
"mergeSavedItems",
".",
"get",
"(",
"0",
")",
";",
"return",
"openItems",
".",
"map",
"(",
"(",
"openItem",
")",
"=>",
"openItem",
".",
"set",
"(",
"'saved'",
",",
"true",
")",
".",
"set",
"(",
"'savedBookmarkId'",
",",
"savedItem",
".",
"savedBookmarkId",
")",
".",
"set",
"(",
"'savedBookmarkIndex'",
",",
"savedItem",
".",
"savedBookmarkIndex",
")",
".",
"set",
"(",
"'savedTitle'",
",",
"savedItem",
".",
"savedTitle",
")",
")",
";",
"}",
"const",
"mergedMap",
"=",
"openUrlMap",
".",
"mergeWith",
"(",
"mergeTabItems",
",",
"savedUrlMap",
")",
";",
"// console.log(\"mergedMap: \", mergedMap.toJS());",
"// console.log(\"getOpenTabInfo: mergedMap :\" + JSON.stringify(mergedMap,null,4));",
"// partition mergedMap into open and closed tabItems:",
"const",
"partitionedMap",
"=",
"mergedMap",
".",
"toIndexedSeq",
"(",
")",
".",
"flatten",
"(",
"true",
")",
".",
"groupBy",
"(",
"(",
"ti",
")",
"=>",
"ti",
".",
"open",
")",
";",
"// console.log(\"partitionedMap: \", partitionedMap.toJS());",
"return",
"partitionedMap",
";",
"}"
] | Gather open tab items and a set of non-open saved tabItems from the given
open tabs and tab items based on URL matching, without regard to
tab ordering. Auxiliary helper function for mergeOpenTabs. | [
"Gather",
"open",
"tab",
"items",
"and",
"a",
"set",
"of",
"non",
"-",
"open",
"saved",
"tabItems",
"from",
"the",
"given",
"open",
"tabs",
"and",
"tab",
"items",
"based",
"on",
"URL",
"matching",
"without",
"regard",
"to",
"tab",
"ordering",
".",
"Auxiliary",
"helper",
"function",
"for",
"mergeOpenTabs",
"."
] | 76cc540891421bc6c8bdcf00f277ebb6e716fdd9 | https://github.com/antonycourtney/tabli-core/blob/76cc540891421bc6c8bdcf00f277ebb6e716fdd9/src/js/tabWindow.js#L232-L277 |
56,468 | directiv/data-hyper-bind | index.js | hyperBind | function hyperBind(store) {
this.compile = function(input) {
var path = input.split('.');
return {
path: input,
target: path[path.length - 1]
};
};
this.state = function(config, state) {
var res = store.get(config.path, state);
if (!res.completed) return false;
return state.set(config.target, res.value);
};
this.children = function(config, state, children) {
var value = state.get(config.target);
if (typeof value === 'undefined') return '';
return value;
};
} | javascript | function hyperBind(store) {
this.compile = function(input) {
var path = input.split('.');
return {
path: input,
target: path[path.length - 1]
};
};
this.state = function(config, state) {
var res = store.get(config.path, state);
if (!res.completed) return false;
return state.set(config.target, res.value);
};
this.children = function(config, state, children) {
var value = state.get(config.target);
if (typeof value === 'undefined') return '';
return value;
};
} | [
"function",
"hyperBind",
"(",
"store",
")",
"{",
"this",
".",
"compile",
"=",
"function",
"(",
"input",
")",
"{",
"var",
"path",
"=",
"input",
".",
"split",
"(",
"'.'",
")",
";",
"return",
"{",
"path",
":",
"input",
",",
"target",
":",
"path",
"[",
"path",
".",
"length",
"-",
"1",
"]",
"}",
";",
"}",
";",
"this",
".",
"state",
"=",
"function",
"(",
"config",
",",
"state",
")",
"{",
"var",
"res",
"=",
"store",
".",
"get",
"(",
"config",
".",
"path",
",",
"state",
")",
";",
"if",
"(",
"!",
"res",
".",
"completed",
")",
"return",
"false",
";",
"return",
"state",
".",
"set",
"(",
"config",
".",
"target",
",",
"res",
".",
"value",
")",
";",
"}",
";",
"this",
".",
"children",
"=",
"function",
"(",
"config",
",",
"state",
",",
"children",
")",
"{",
"var",
"value",
"=",
"state",
".",
"get",
"(",
"config",
".",
"target",
")",
";",
"if",
"(",
"typeof",
"value",
"===",
"'undefined'",
")",
"return",
"''",
";",
"return",
"value",
";",
"}",
";",
"}"
] | Initialize the 'hyper-bind' directive
@param {StoreHyper} store | [
"Initialize",
"the",
"hyper",
"-",
"bind",
"directive"
] | e9d5640f7087a30d90ce2652e9b6713da72f4b7b | https://github.com/directiv/data-hyper-bind/blob/e9d5640f7087a30d90ce2652e9b6713da72f4b7b/index.js#L19-L39 |
56,469 | pgarrison/tweet-matches | lib/get-fields.js | getFields | function getFields(tweet) {
return _.flatten(tweetLikeObjectsToCheck.map(function(tweetLikeName) {
var tweetLike;
if (tweetLikeName === null) {
tweetLike = tweet;
} else {
tweetLike = _.get(tweet, tweetLikeName);
}
if (!tweetLike) return [];
return getFieldsFromTweetLike(tweetLike);
}));
} | javascript | function getFields(tweet) {
return _.flatten(tweetLikeObjectsToCheck.map(function(tweetLikeName) {
var tweetLike;
if (tweetLikeName === null) {
tweetLike = tweet;
} else {
tweetLike = _.get(tweet, tweetLikeName);
}
if (!tweetLike) return [];
return getFieldsFromTweetLike(tweetLike);
}));
} | [
"function",
"getFields",
"(",
"tweet",
")",
"{",
"return",
"_",
".",
"flatten",
"(",
"tweetLikeObjectsToCheck",
".",
"map",
"(",
"function",
"(",
"tweetLikeName",
")",
"{",
"var",
"tweetLike",
";",
"if",
"(",
"tweetLikeName",
"===",
"null",
")",
"{",
"tweetLike",
"=",
"tweet",
";",
"}",
"else",
"{",
"tweetLike",
"=",
"_",
".",
"get",
"(",
"tweet",
",",
"tweetLikeName",
")",
";",
"}",
"if",
"(",
"!",
"tweetLike",
")",
"return",
"[",
"]",
";",
"return",
"getFieldsFromTweetLike",
"(",
"tweetLike",
")",
";",
"}",
")",
")",
";",
"}"
] | Create an array of the strings at the positions in the tweet object specified by the above arrays of field names | [
"Create",
"an",
"array",
"of",
"the",
"strings",
"at",
"the",
"positions",
"in",
"the",
"tweet",
"object",
"specified",
"by",
"the",
"above",
"arrays",
"of",
"field",
"names"
] | e68a59d53b02f65f53edf10b6483dda4196150a2 | https://github.com/pgarrison/tweet-matches/blob/e68a59d53b02f65f53edf10b6483dda4196150a2/lib/get-fields.js#L43-L54 |
56,470 | pgarrison/tweet-matches | lib/get-fields.js | getFieldsFromTweetLike | function getFieldsFromTweetLike(tweetLike) {
var fields = fieldsToCheck.map(function(fieldName) {
return _.get(tweetLike, fieldName);
});
arrayFieldsToCheck.forEach(function(fieldDescription) {
var arr = _.get(tweetLike, fieldDescription.arrayAt);
if (_.isArray(arr)) {
arr.forEach(function(element) {
fields.push(_.get(element, fieldDescription.inEach));
});
}
});
return fields.filter(function(field) {
return typeof field === 'string' && field.trim().length !== 0;
}).map(function(field) {
return field.toLowerCase();
});
} | javascript | function getFieldsFromTweetLike(tweetLike) {
var fields = fieldsToCheck.map(function(fieldName) {
return _.get(tweetLike, fieldName);
});
arrayFieldsToCheck.forEach(function(fieldDescription) {
var arr = _.get(tweetLike, fieldDescription.arrayAt);
if (_.isArray(arr)) {
arr.forEach(function(element) {
fields.push(_.get(element, fieldDescription.inEach));
});
}
});
return fields.filter(function(field) {
return typeof field === 'string' && field.trim().length !== 0;
}).map(function(field) {
return field.toLowerCase();
});
} | [
"function",
"getFieldsFromTweetLike",
"(",
"tweetLike",
")",
"{",
"var",
"fields",
"=",
"fieldsToCheck",
".",
"map",
"(",
"function",
"(",
"fieldName",
")",
"{",
"return",
"_",
".",
"get",
"(",
"tweetLike",
",",
"fieldName",
")",
";",
"}",
")",
";",
"arrayFieldsToCheck",
".",
"forEach",
"(",
"function",
"(",
"fieldDescription",
")",
"{",
"var",
"arr",
"=",
"_",
".",
"get",
"(",
"tweetLike",
",",
"fieldDescription",
".",
"arrayAt",
")",
";",
"if",
"(",
"_",
".",
"isArray",
"(",
"arr",
")",
")",
"{",
"arr",
".",
"forEach",
"(",
"function",
"(",
"element",
")",
"{",
"fields",
".",
"push",
"(",
"_",
".",
"get",
"(",
"element",
",",
"fieldDescription",
".",
"inEach",
")",
")",
";",
"}",
")",
";",
"}",
"}",
")",
";",
"return",
"fields",
".",
"filter",
"(",
"function",
"(",
"field",
")",
"{",
"return",
"typeof",
"field",
"===",
"'string'",
"&&",
"field",
".",
"trim",
"(",
")",
".",
"length",
"!==",
"0",
";",
"}",
")",
".",
"map",
"(",
"function",
"(",
"field",
")",
"{",
"return",
"field",
".",
"toLowerCase",
"(",
")",
";",
"}",
")",
";",
"}"
] | Takes a tweet or a subobject of tweet and looks for strings in the positions listed in fieldsToCheck and arrayFieldsToCheck | [
"Takes",
"a",
"tweet",
"or",
"a",
"subobject",
"of",
"tweet",
"and",
"looks",
"for",
"strings",
"in",
"the",
"positions",
"listed",
"in",
"fieldsToCheck",
"and",
"arrayFieldsToCheck"
] | e68a59d53b02f65f53edf10b6483dda4196150a2 | https://github.com/pgarrison/tweet-matches/blob/e68a59d53b02f65f53edf10b6483dda4196150a2/lib/get-fields.js#L58-L77 |
56,471 | paukan-org/core | service/index.js | Service | function Service(config, callback) {
ld.bindAll(this);
var eventEmitter = new EventEmitter2({ wildcard: true, delimiter: '.'});
this.cfg = {};
this.network = { local: eventEmitter };
ld.defaults(this.cfg, config, {
// id // required, unique service id [^a-zA-Z0-9_]
// version // required
requestTimeout: 3000, // timeout in ms before device answer
port: 6379, // network or proxy port
host: 'paukan', // network or proxy host
throttling: 200, // do not emit same event fired durning this period (on multiple psubscribe)
connections: ['direct', 'remote', 'server'], // try next connection type if previous failed
// - direct: connect to redis queue on specified host and port
// - remote: connect to remote websocket proxy service on specified host and port
// - server: create websocket server and wait incoming connection on specified port
});
this.id = this.cfg.id;
this.hostname = require('os').hostname();
this.version = this.cfg.version;
this.description = this.cfg.description;
this.homepage = this.cfg.homepage;
this.author = this.cfg.author;
this.devices = {}; // list of devices in this service
this.log = this.createLogger(this.cfg.logger);
if(callback) { this.init(callback); }
} | javascript | function Service(config, callback) {
ld.bindAll(this);
var eventEmitter = new EventEmitter2({ wildcard: true, delimiter: '.'});
this.cfg = {};
this.network = { local: eventEmitter };
ld.defaults(this.cfg, config, {
// id // required, unique service id [^a-zA-Z0-9_]
// version // required
requestTimeout: 3000, // timeout in ms before device answer
port: 6379, // network or proxy port
host: 'paukan', // network or proxy host
throttling: 200, // do not emit same event fired durning this period (on multiple psubscribe)
connections: ['direct', 'remote', 'server'], // try next connection type if previous failed
// - direct: connect to redis queue on specified host and port
// - remote: connect to remote websocket proxy service on specified host and port
// - server: create websocket server and wait incoming connection on specified port
});
this.id = this.cfg.id;
this.hostname = require('os').hostname();
this.version = this.cfg.version;
this.description = this.cfg.description;
this.homepage = this.cfg.homepage;
this.author = this.cfg.author;
this.devices = {}; // list of devices in this service
this.log = this.createLogger(this.cfg.logger);
if(callback) { this.init(callback); }
} | [
"function",
"Service",
"(",
"config",
",",
"callback",
")",
"{",
"ld",
".",
"bindAll",
"(",
"this",
")",
";",
"var",
"eventEmitter",
"=",
"new",
"EventEmitter2",
"(",
"{",
"wildcard",
":",
"true",
",",
"delimiter",
":",
"'.'",
"}",
")",
";",
"this",
".",
"cfg",
"=",
"{",
"}",
";",
"this",
".",
"network",
"=",
"{",
"local",
":",
"eventEmitter",
"}",
";",
"ld",
".",
"defaults",
"(",
"this",
".",
"cfg",
",",
"config",
",",
"{",
"// id // required, unique service id [^a-zA-Z0-9_]",
"// version // required",
"requestTimeout",
":",
"3000",
",",
"// timeout in ms before device answer",
"port",
":",
"6379",
",",
"// network or proxy port",
"host",
":",
"'paukan'",
",",
"// network or proxy host",
"throttling",
":",
"200",
",",
"// do not emit same event fired durning this period (on multiple psubscribe)",
"connections",
":",
"[",
"'direct'",
",",
"'remote'",
",",
"'server'",
"]",
",",
"// try next connection type if previous failed",
"// - direct: connect to redis queue on specified host and port",
"// - remote: connect to remote websocket proxy service on specified host and port",
"// - server: create websocket server and wait incoming connection on specified port",
"}",
")",
";",
"this",
".",
"id",
"=",
"this",
".",
"cfg",
".",
"id",
";",
"this",
".",
"hostname",
"=",
"require",
"(",
"'os'",
")",
".",
"hostname",
"(",
")",
";",
"this",
".",
"version",
"=",
"this",
".",
"cfg",
".",
"version",
";",
"this",
".",
"description",
"=",
"this",
".",
"cfg",
".",
"description",
";",
"this",
".",
"homepage",
"=",
"this",
".",
"cfg",
".",
"homepage",
";",
"this",
".",
"author",
"=",
"this",
".",
"cfg",
".",
"author",
";",
"this",
".",
"devices",
"=",
"{",
"}",
";",
"// list of devices in this service",
"this",
".",
"log",
"=",
"this",
".",
"createLogger",
"(",
"this",
".",
"cfg",
".",
"logger",
")",
";",
"if",
"(",
"callback",
")",
"{",
"this",
".",
"init",
"(",
"callback",
")",
";",
"}",
"}"
] | required fields for device
Service - interaction interface between automated network and end devices.
Provice necessary functional and act as router.
@param {object} config configuration parameters for service initialisation
@param {function} callback if not set - only class will be instances | [
"required",
"fields",
"for",
"device",
"Service",
"-",
"interaction",
"interface",
"between",
"automated",
"network",
"and",
"end",
"devices",
".",
"Provice",
"necessary",
"functional",
"and",
"act",
"as",
"router",
"."
] | e6ff0667d50bc9b25ab5678852316e89521942ad | https://github.com/paukan-org/core/blob/e6ff0667d50bc9b25ab5678852316e89521942ad/service/index.js#L18-L48 |
56,472 | paukan-org/core | service/index.js | exitHandler | function exitHandler(options, err) {
if (err) {
log.error(err.stack);
}
if (options.exit) {
process.exit();
}
if(network) {
network.emit('state.'+id+'.service.offline');
}
} | javascript | function exitHandler(options, err) {
if (err) {
log.error(err.stack);
}
if (options.exit) {
process.exit();
}
if(network) {
network.emit('state.'+id+'.service.offline');
}
} | [
"function",
"exitHandler",
"(",
"options",
",",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"log",
".",
"error",
"(",
"err",
".",
"stack",
")",
";",
"}",
"if",
"(",
"options",
".",
"exit",
")",
"{",
"process",
".",
"exit",
"(",
")",
";",
"}",
"if",
"(",
"network",
")",
"{",
"network",
".",
"emit",
"(",
"'state.'",
"+",
"id",
"+",
"'.service.offline'",
")",
";",
"}",
"}"
] | so the program will not close instantly | [
"so",
"the",
"program",
"will",
"not",
"close",
"instantly"
] | e6ff0667d50bc9b25ab5678852316e89521942ad | https://github.com/paukan-org/core/blob/e6ff0667d50bc9b25ab5678852316e89521942ad/service/index.js#L487-L498 |
56,473 | altshift/altshift | lib/altshift/cli/style.js | applyStyle | function applyStyle(str, property, value) {
var styleDefinition = CONSOLE_STYLES[property][value];
//No style defined return non modified string
if (styleDefinition === null) {
return str;
}
return ESCAPE + '[' + styleDefinition[0] + 'm' + str + ESCAPE + '[' + styleDefinition[1] + 'm';
} | javascript | function applyStyle(str, property, value) {
var styleDefinition = CONSOLE_STYLES[property][value];
//No style defined return non modified string
if (styleDefinition === null) {
return str;
}
return ESCAPE + '[' + styleDefinition[0] + 'm' + str + ESCAPE + '[' + styleDefinition[1] + 'm';
} | [
"function",
"applyStyle",
"(",
"str",
",",
"property",
",",
"value",
")",
"{",
"var",
"styleDefinition",
"=",
"CONSOLE_STYLES",
"[",
"property",
"]",
"[",
"value",
"]",
";",
"//No style defined return non modified string",
"if",
"(",
"styleDefinition",
"===",
"null",
")",
"{",
"return",
"str",
";",
"}",
"return",
"ESCAPE",
"+",
"'['",
"+",
"styleDefinition",
"[",
"0",
"]",
"+",
"'m'",
"+",
"str",
"+",
"ESCAPE",
"+",
"'['",
"+",
"styleDefinition",
"[",
"1",
"]",
"+",
"'m'",
";",
"}"
] | Apply one single style on str
@param {string} str
@param {string} property
@param {string} value
@return {string} | [
"Apply",
"one",
"single",
"style",
"on",
"str"
] | 5c051157e6f558636c8e12081b6707caa66249de | https://github.com/altshift/altshift/blob/5c051157e6f558636c8e12081b6707caa66249de/lib/altshift/cli/style.js#L70-L79 |
56,474 | altshift/altshift | lib/altshift/cli/style.js | applyStyles | function applyStyles(str, style) {
//Check if not style
if (! style) {
return str;
}
//Check shortcut if string is empty
//str = '' + str;
if (!str || str.length === 0) {
return str;
}
var output, i, rule, textdecoration;
//style = style || {};
output = str;
//1. font-weight
rule = style['font-weight'];
if (rule) {
output = applyStyle(output, 'font-weight', rule);
}
//2. font-style
rule = style['font-style'];
if (rule) {
output = applyStyle(output, 'font-style', rule);
}
//3. color
rule = style.color;
if (style.color) {
output = applyStyle(output, 'color', rule);
}
//4. background color
rule = style['background-color'];
if (rule) {
output = applyStyle(output, 'background-color', rule);
}
//Normalize as array
rule = style['text-decoration'];
if (isArray(rule)) {
//do all decoration
i = rule.length - 1;
while (i >= 0) {
i -= 1;
output = applyStyle(output, 'text-decoration', rule[i]);
}
} else {
output = applyStyle(output, 'text-decoration', style['text-decoration']);
}
} | javascript | function applyStyles(str, style) {
//Check if not style
if (! style) {
return str;
}
//Check shortcut if string is empty
//str = '' + str;
if (!str || str.length === 0) {
return str;
}
var output, i, rule, textdecoration;
//style = style || {};
output = str;
//1. font-weight
rule = style['font-weight'];
if (rule) {
output = applyStyle(output, 'font-weight', rule);
}
//2. font-style
rule = style['font-style'];
if (rule) {
output = applyStyle(output, 'font-style', rule);
}
//3. color
rule = style.color;
if (style.color) {
output = applyStyle(output, 'color', rule);
}
//4. background color
rule = style['background-color'];
if (rule) {
output = applyStyle(output, 'background-color', rule);
}
//Normalize as array
rule = style['text-decoration'];
if (isArray(rule)) {
//do all decoration
i = rule.length - 1;
while (i >= 0) {
i -= 1;
output = applyStyle(output, 'text-decoration', rule[i]);
}
} else {
output = applyStyle(output, 'text-decoration', style['text-decoration']);
}
} | [
"function",
"applyStyles",
"(",
"str",
",",
"style",
")",
"{",
"//Check if not style",
"if",
"(",
"!",
"style",
")",
"{",
"return",
"str",
";",
"}",
"//Check shortcut if string is empty",
"//str = '' + str;",
"if",
"(",
"!",
"str",
"||",
"str",
".",
"length",
"===",
"0",
")",
"{",
"return",
"str",
";",
"}",
"var",
"output",
",",
"i",
",",
"rule",
",",
"textdecoration",
";",
"//style = style || {};",
"output",
"=",
"str",
";",
"//1. font-weight",
"rule",
"=",
"style",
"[",
"'font-weight'",
"]",
";",
"if",
"(",
"rule",
")",
"{",
"output",
"=",
"applyStyle",
"(",
"output",
",",
"'font-weight'",
",",
"rule",
")",
";",
"}",
"//2. font-style",
"rule",
"=",
"style",
"[",
"'font-style'",
"]",
";",
"if",
"(",
"rule",
")",
"{",
"output",
"=",
"applyStyle",
"(",
"output",
",",
"'font-style'",
",",
"rule",
")",
";",
"}",
"//3. color",
"rule",
"=",
"style",
".",
"color",
";",
"if",
"(",
"style",
".",
"color",
")",
"{",
"output",
"=",
"applyStyle",
"(",
"output",
",",
"'color'",
",",
"rule",
")",
";",
"}",
"//4. background color",
"rule",
"=",
"style",
"[",
"'background-color'",
"]",
";",
"if",
"(",
"rule",
")",
"{",
"output",
"=",
"applyStyle",
"(",
"output",
",",
"'background-color'",
",",
"rule",
")",
";",
"}",
"//Normalize as array",
"rule",
"=",
"style",
"[",
"'text-decoration'",
"]",
";",
"if",
"(",
"isArray",
"(",
"rule",
")",
")",
"{",
"//do all decoration",
"i",
"=",
"rule",
".",
"length",
"-",
"1",
";",
"while",
"(",
"i",
">=",
"0",
")",
"{",
"i",
"-=",
"1",
";",
"output",
"=",
"applyStyle",
"(",
"output",
",",
"'text-decoration'",
",",
"rule",
"[",
"i",
"]",
")",
";",
"}",
"}",
"else",
"{",
"output",
"=",
"applyStyle",
"(",
"output",
",",
"'text-decoration'",
",",
"style",
"[",
"'text-decoration'",
"]",
")",
";",
"}",
"}"
] | Return a formatted str
@param {string} str
@param {Object} style
- font-weight : normal|bold
- font-style : normal|italic
- background-color : transparent|black|red|green|yellow|blue|magenta|cyan|white
- color : default|black|red|green|yellow|blue|magenta|cyan|white
- text-decoration : [underline|blink|reverse|invisible, ...]
@return {string} | [
"Return",
"a",
"formatted",
"str"
] | 5c051157e6f558636c8e12081b6707caa66249de | https://github.com/altshift/altshift/blob/5c051157e6f558636c8e12081b6707caa66249de/lib/altshift/cli/style.js#L94-L147 |
56,475 | robertblackwell/yake | src/yake/yakefile.js | recursiveFindFile | function recursiveFindFile(aDirectory, arrayOfFileNames)
{
if (debug) debugLog(`recursiveFindFile dir: ${aDirectory}, filenames: ${util.inspect(arrayOfFileNames)}`);
// var directory = process.cwd();
let directory = aDirectory;
const tmp = directoryHasFile(directory, arrayOfFileNames);
if ((tmp === undefined) && directory !== '/')
{
directory = path.dirname(directory);
const anotherTmp = recursiveFindFile(directory, arrayOfFileNames);
return anotherTmp;
}
else if (tmp === undefined)
{
// ran out of directories
return undefined;
}
const p = path.resolve(directory, tmp);
return p;
} | javascript | function recursiveFindFile(aDirectory, arrayOfFileNames)
{
if (debug) debugLog(`recursiveFindFile dir: ${aDirectory}, filenames: ${util.inspect(arrayOfFileNames)}`);
// var directory = process.cwd();
let directory = aDirectory;
const tmp = directoryHasFile(directory, arrayOfFileNames);
if ((tmp === undefined) && directory !== '/')
{
directory = path.dirname(directory);
const anotherTmp = recursiveFindFile(directory, arrayOfFileNames);
return anotherTmp;
}
else if (tmp === undefined)
{
// ran out of directories
return undefined;
}
const p = path.resolve(directory, tmp);
return p;
} | [
"function",
"recursiveFindFile",
"(",
"aDirectory",
",",
"arrayOfFileNames",
")",
"{",
"if",
"(",
"debug",
")",
"debugLog",
"(",
"`",
"${",
"aDirectory",
"}",
"${",
"util",
".",
"inspect",
"(",
"arrayOfFileNames",
")",
"}",
"`",
")",
";",
"// var directory = process.cwd();",
"let",
"directory",
"=",
"aDirectory",
";",
"const",
"tmp",
"=",
"directoryHasFile",
"(",
"directory",
",",
"arrayOfFileNames",
")",
";",
"if",
"(",
"(",
"tmp",
"===",
"undefined",
")",
"&&",
"directory",
"!==",
"'/'",
")",
"{",
"directory",
"=",
"path",
".",
"dirname",
"(",
"directory",
")",
";",
"const",
"anotherTmp",
"=",
"recursiveFindFile",
"(",
"directory",
",",
"arrayOfFileNames",
")",
";",
"return",
"anotherTmp",
";",
"}",
"else",
"if",
"(",
"tmp",
"===",
"undefined",
")",
"{",
"// ran out of directories",
"return",
"undefined",
";",
"}",
"const",
"p",
"=",
"path",
".",
"resolve",
"(",
"directory",
",",
"tmp",
")",
";",
"return",
"p",
";",
"}"
] | Search upwards from and including aDirectory to find one of the files named in arrayOfFiles
returns the full path of the file if it exists
@param {string} path to a directory where the search should start
@param {array of strings} arrayOfFileNames The array of file names
@return {string | undefined} full path of the jakefile that was found or undefined if none found | [
"Search",
"upwards",
"from",
"and",
"including",
"aDirectory",
"to",
"find",
"one",
"of",
"the",
"files",
"named",
"in",
"arrayOfFiles",
"returns",
"the",
"full",
"path",
"of",
"the",
"file",
"if",
"it",
"exists"
] | 172b02e29303fb718bac88bbda9b85749c57169c | https://github.com/robertblackwell/yake/blob/172b02e29303fb718bac88bbda9b85749c57169c/src/yake/yakefile.js#L89-L112 |
56,476 | MaiaVictor/dattata | Vector2.js | angle | function angle(a, b){
var ang = (Math.atan2(b.y, b.x) - Math.atan2(a.y, a.x) + Math.PI*2) % (Math.PI*2);
if (ang > Math.PI) ang -= Math.PI*2;
return ang;
} | javascript | function angle(a, b){
var ang = (Math.atan2(b.y, b.x) - Math.atan2(a.y, a.x) + Math.PI*2) % (Math.PI*2);
if (ang > Math.PI) ang -= Math.PI*2;
return ang;
} | [
"function",
"angle",
"(",
"a",
",",
"b",
")",
"{",
"var",
"ang",
"=",
"(",
"Math",
".",
"atan2",
"(",
"b",
".",
"y",
",",
"b",
".",
"x",
")",
"-",
"Math",
".",
"atan2",
"(",
"a",
".",
"y",
",",
"a",
".",
"x",
")",
"+",
"Math",
".",
"PI",
"*",
"2",
")",
"%",
"(",
"Math",
".",
"PI",
"*",
"2",
")",
";",
"if",
"(",
"ang",
">",
"Math",
".",
"PI",
")",
"ang",
"-=",
"Math",
".",
"PI",
"*",
"2",
";",
"return",
"ang",
";",
"}"
] | V2, V2 -> Number | [
"V2",
"V2",
"-",
">",
"Number"
] | 890d83b89b7193ce8863bb9ac9b296b3510e8db9 | https://github.com/MaiaVictor/dattata/blob/890d83b89b7193ce8863bb9ac9b296b3510e8db9/Vector2.js#L8-L12 |
56,477 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/focusmanager.js | function( noDelay ) {
if ( this._.locked )
return;
function doBlur() {
if ( this.hasFocus ) {
this.hasFocus = false;
var ct = this._.editor.container;
ct && ct.removeClass( 'cke_focus' );
this._.editor.fire( 'blur' );
}
}
if ( this._.timer )
clearTimeout( this._.timer );
var delay = CKEDITOR.focusManager._.blurDelay;
if ( noDelay || !delay )
doBlur.call( this );
else {
this._.timer = CKEDITOR.tools.setTimeout( function() {
delete this._.timer;
doBlur.call( this );
}, delay, this );
}
} | javascript | function( noDelay ) {
if ( this._.locked )
return;
function doBlur() {
if ( this.hasFocus ) {
this.hasFocus = false;
var ct = this._.editor.container;
ct && ct.removeClass( 'cke_focus' );
this._.editor.fire( 'blur' );
}
}
if ( this._.timer )
clearTimeout( this._.timer );
var delay = CKEDITOR.focusManager._.blurDelay;
if ( noDelay || !delay )
doBlur.call( this );
else {
this._.timer = CKEDITOR.tools.setTimeout( function() {
delete this._.timer;
doBlur.call( this );
}, delay, this );
}
} | [
"function",
"(",
"noDelay",
")",
"{",
"if",
"(",
"this",
".",
"_",
".",
"locked",
")",
"return",
";",
"function",
"doBlur",
"(",
")",
"{",
"if",
"(",
"this",
".",
"hasFocus",
")",
"{",
"this",
".",
"hasFocus",
"=",
"false",
";",
"var",
"ct",
"=",
"this",
".",
"_",
".",
"editor",
".",
"container",
";",
"ct",
"&&",
"ct",
".",
"removeClass",
"(",
"'cke_focus'",
")",
";",
"this",
".",
"_",
".",
"editor",
".",
"fire",
"(",
"'blur'",
")",
";",
"}",
"}",
"if",
"(",
"this",
".",
"_",
".",
"timer",
")",
"clearTimeout",
"(",
"this",
".",
"_",
".",
"timer",
")",
";",
"var",
"delay",
"=",
"CKEDITOR",
".",
"focusManager",
".",
"_",
".",
"blurDelay",
";",
"if",
"(",
"noDelay",
"||",
"!",
"delay",
")",
"doBlur",
".",
"call",
"(",
"this",
")",
";",
"else",
"{",
"this",
".",
"_",
".",
"timer",
"=",
"CKEDITOR",
".",
"tools",
".",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"delete",
"this",
".",
"_",
".",
"timer",
";",
"doBlur",
".",
"call",
"(",
"this",
")",
";",
"}",
",",
"delay",
",",
"this",
")",
";",
"}",
"}"
] | Used to indicate that the editor instance has been deactivated by the specified
element which has just lost focus.
**Note:** This function acts asynchronously with a delay of 100ms to
avoid temporary deactivation. Use the `noDelay` parameter instead
to deactivate immediately.
var editor = CKEDITOR.instances.editor1;
editor.focusManager.blur();
@param {Boolean} [noDelay=false] Immediately deactivate the editor instance synchronously.
@member CKEDITOR.focusManager | [
"Used",
"to",
"indicate",
"that",
"the",
"editor",
"instance",
"has",
"been",
"deactivated",
"by",
"the",
"specified",
"element",
"which",
"has",
"just",
"lost",
"focus",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/focusmanager.js#L149-L175 |
|
56,478 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/focusmanager.js | function( element, isCapture ) {
var fm = element.getCustomData( SLOT_NAME );
if ( !fm || fm != this ) {
// If this element is already taken by another instance, dismiss it first.
fm && fm.remove( element );
var focusEvent = 'focus',
blurEvent = 'blur';
// Bypass the element's internal DOM focus change.
if ( isCapture ) {
// Use "focusin/focusout" events instead of capture phase in IEs,
// which fires synchronously.
if ( CKEDITOR.env.ie ) {
focusEvent = 'focusin';
blurEvent = 'focusout';
} else {
CKEDITOR.event.useCapture = 1;
}
}
var listeners = {
blur: function() {
if ( element.equals( this.currentActive ) )
this.blur();
},
focus: function() {
this.focus( element );
}
};
element.on( focusEvent, listeners.focus, this );
element.on( blurEvent, listeners.blur, this );
if ( isCapture )
CKEDITOR.event.useCapture = 0;
element.setCustomData( SLOT_NAME, this );
element.setCustomData( SLOT_NAME_LISTENERS, listeners );
}
} | javascript | function( element, isCapture ) {
var fm = element.getCustomData( SLOT_NAME );
if ( !fm || fm != this ) {
// If this element is already taken by another instance, dismiss it first.
fm && fm.remove( element );
var focusEvent = 'focus',
blurEvent = 'blur';
// Bypass the element's internal DOM focus change.
if ( isCapture ) {
// Use "focusin/focusout" events instead of capture phase in IEs,
// which fires synchronously.
if ( CKEDITOR.env.ie ) {
focusEvent = 'focusin';
blurEvent = 'focusout';
} else {
CKEDITOR.event.useCapture = 1;
}
}
var listeners = {
blur: function() {
if ( element.equals( this.currentActive ) )
this.blur();
},
focus: function() {
this.focus( element );
}
};
element.on( focusEvent, listeners.focus, this );
element.on( blurEvent, listeners.blur, this );
if ( isCapture )
CKEDITOR.event.useCapture = 0;
element.setCustomData( SLOT_NAME, this );
element.setCustomData( SLOT_NAME_LISTENERS, listeners );
}
} | [
"function",
"(",
"element",
",",
"isCapture",
")",
"{",
"var",
"fm",
"=",
"element",
".",
"getCustomData",
"(",
"SLOT_NAME",
")",
";",
"if",
"(",
"!",
"fm",
"||",
"fm",
"!=",
"this",
")",
"{",
"// If this element is already taken by another instance, dismiss it first.",
"fm",
"&&",
"fm",
".",
"remove",
"(",
"element",
")",
";",
"var",
"focusEvent",
"=",
"'focus'",
",",
"blurEvent",
"=",
"'blur'",
";",
"// Bypass the element's internal DOM focus change.",
"if",
"(",
"isCapture",
")",
"{",
"// Use \"focusin/focusout\" events instead of capture phase in IEs,",
"// which fires synchronously.",
"if",
"(",
"CKEDITOR",
".",
"env",
".",
"ie",
")",
"{",
"focusEvent",
"=",
"'focusin'",
";",
"blurEvent",
"=",
"'focusout'",
";",
"}",
"else",
"{",
"CKEDITOR",
".",
"event",
".",
"useCapture",
"=",
"1",
";",
"}",
"}",
"var",
"listeners",
"=",
"{",
"blur",
":",
"function",
"(",
")",
"{",
"if",
"(",
"element",
".",
"equals",
"(",
"this",
".",
"currentActive",
")",
")",
"this",
".",
"blur",
"(",
")",
";",
"}",
",",
"focus",
":",
"function",
"(",
")",
"{",
"this",
".",
"focus",
"(",
"element",
")",
";",
"}",
"}",
";",
"element",
".",
"on",
"(",
"focusEvent",
",",
"listeners",
".",
"focus",
",",
"this",
")",
";",
"element",
".",
"on",
"(",
"blurEvent",
",",
"listeners",
".",
"blur",
",",
"this",
")",
";",
"if",
"(",
"isCapture",
")",
"CKEDITOR",
".",
"event",
".",
"useCapture",
"=",
"0",
";",
"element",
".",
"setCustomData",
"(",
"SLOT_NAME",
",",
"this",
")",
";",
"element",
".",
"setCustomData",
"(",
"SLOT_NAME_LISTENERS",
",",
"listeners",
")",
";",
"}",
"}"
] | Registers a UI DOM element to the focus manager, which will make the focus manager "hasFocus"
once the input focus is relieved on the element.
This method is designed to be used by plugins to expand the jurisdiction of the editor focus.
@param {CKEDITOR.dom.element} element The container (topmost) element of one UI part.
@param {Boolean} isCapture If specified, {@link CKEDITOR.event#useCapture} will be used when listening to the focus event.
@member CKEDITOR.focusManager | [
"Registers",
"a",
"UI",
"DOM",
"element",
"to",
"the",
"focus",
"manager",
"which",
"will",
"make",
"the",
"focus",
"manager",
"hasFocus",
"once",
"the",
"input",
"focus",
"is",
"relieved",
"on",
"the",
"element",
".",
"This",
"method",
"is",
"designed",
"to",
"be",
"used",
"by",
"plugins",
"to",
"expand",
"the",
"jurisdiction",
"of",
"the",
"editor",
"focus",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/focusmanager.js#L186-L227 |
|
56,479 | n1ru4l/ember-cli-postcss-fixed | index.js | PostcssCompiler | function PostcssCompiler(inputTrees, inputFile, outputFile, plugins, map, useSass, includePaths) {
if (!(this instanceof PostcssCompiler)) {
return new PostcssCompiler(inputTrees, inputFile, outputFile, plugins, map);
}
if (!Array.isArray(inputTrees)) {
throw new Error('Expected array for first argument - did you mean [tree] instead of tree?');
}
CachingWriter.call(this, inputTrees, inputFile);
this.inputFile = inputFile;
this.outputFile = outputFile;
this.plugins = plugins || [];
this.map = map || {};
this.warningStream = process.stderr;
this.useSass = useSass || false;
this.includePaths = includePaths || [];
} | javascript | function PostcssCompiler(inputTrees, inputFile, outputFile, plugins, map, useSass, includePaths) {
if (!(this instanceof PostcssCompiler)) {
return new PostcssCompiler(inputTrees, inputFile, outputFile, plugins, map);
}
if (!Array.isArray(inputTrees)) {
throw new Error('Expected array for first argument - did you mean [tree] instead of tree?');
}
CachingWriter.call(this, inputTrees, inputFile);
this.inputFile = inputFile;
this.outputFile = outputFile;
this.plugins = plugins || [];
this.map = map || {};
this.warningStream = process.stderr;
this.useSass = useSass || false;
this.includePaths = includePaths || [];
} | [
"function",
"PostcssCompiler",
"(",
"inputTrees",
",",
"inputFile",
",",
"outputFile",
",",
"plugins",
",",
"map",
",",
"useSass",
",",
"includePaths",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"PostcssCompiler",
")",
")",
"{",
"return",
"new",
"PostcssCompiler",
"(",
"inputTrees",
",",
"inputFile",
",",
"outputFile",
",",
"plugins",
",",
"map",
")",
";",
"}",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"inputTrees",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Expected array for first argument - did you mean [tree] instead of tree?'",
")",
";",
"}",
"CachingWriter",
".",
"call",
"(",
"this",
",",
"inputTrees",
",",
"inputFile",
")",
";",
"this",
".",
"inputFile",
"=",
"inputFile",
";",
"this",
".",
"outputFile",
"=",
"outputFile",
";",
"this",
".",
"plugins",
"=",
"plugins",
"||",
"[",
"]",
";",
"this",
".",
"map",
"=",
"map",
"||",
"{",
"}",
";",
"this",
".",
"warningStream",
"=",
"process",
".",
"stderr",
";",
"this",
".",
"useSass",
"=",
"useSass",
"||",
"false",
";",
"this",
".",
"includePaths",
"=",
"includePaths",
"||",
"[",
"]",
";",
"}"
] | rip of broccoli-postcss | [
"rip",
"of",
"broccoli",
"-",
"postcss"
] | 7bcceaba60cfbe74e9db8e643e0ccf5ee0293bcc | https://github.com/n1ru4l/ember-cli-postcss-fixed/blob/7bcceaba60cfbe74e9db8e643e0ccf5ee0293bcc/index.js#L17-L35 |
56,480 | jgrund/grunt-coverjs | tasks/cover.js | coverFile | function coverFile(srcFile) {
var srcCode = grunt.file.read(srcFile);
Instrument = require('coverjs').Instrument;
try {
return new Instrument(srcCode, {name: srcFile}).instrument();
} catch (e) {
grunt.log.error('File ' + srcFile + ' could not be instrumented.');
grunt.fatal(e, 3);
}
} | javascript | function coverFile(srcFile) {
var srcCode = grunt.file.read(srcFile);
Instrument = require('coverjs').Instrument;
try {
return new Instrument(srcCode, {name: srcFile}).instrument();
} catch (e) {
grunt.log.error('File ' + srcFile + ' could not be instrumented.');
grunt.fatal(e, 3);
}
} | [
"function",
"coverFile",
"(",
"srcFile",
")",
"{",
"var",
"srcCode",
"=",
"grunt",
".",
"file",
".",
"read",
"(",
"srcFile",
")",
";",
"Instrument",
"=",
"require",
"(",
"'coverjs'",
")",
".",
"Instrument",
";",
"try",
"{",
"return",
"new",
"Instrument",
"(",
"srcCode",
",",
"{",
"name",
":",
"srcFile",
"}",
")",
".",
"instrument",
"(",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"grunt",
".",
"log",
".",
"error",
"(",
"'File '",
"+",
"srcFile",
"+",
"' could not be instrumented.'",
")",
";",
"grunt",
".",
"fatal",
"(",
"e",
",",
"3",
")",
";",
"}",
"}"
] | Instruments the given source file.
@param srcFile
@return {String} Returns the instrumented source file as a string. | [
"Instruments",
"the",
"given",
"source",
"file",
"."
] | 6727af0446848af11ab36eb5a961fe4735ae7064 | https://github.com/jgrund/grunt-coverjs/blob/6727af0446848af11ab36eb5a961fe4735ae7064/tasks/cover.js#L39-L49 |
56,481 | fieosa/webcomponent-mdl | src/utils/custom-element.js | createBaseCustomElementClass | function createBaseCustomElementClass(win) {
if (win.BaseCustomElementClass) {
return win.BaseCustomElementClass;
}
const htmlElement = win.HTMLElement;
/** @abstract @extends {HTMLElement} */
class BaseCustomElement extends htmlElement {
/**
* @see https://github.com/WebReflection/document-register-element#v1-caveat
* @suppress {checkTypes}
*/
constructor(self) {
self = super(self);
self.createdCallback(self.getChildren());
return self;
}
/**
* Called when elements is created. Sets instance vars since there is no
* constructor.
* @this {!Element}
*/
createdCallback() {
}
attributeChangedCallback(attrName, oldVal, newVal) {
}
/**
* Called when the element is first connected to the DOM. Calls
* {@link firstAttachedCallback} if this is the first attachment.
* @final @this {!Element}
*/
connectedCallback() {
}
/** The Custom Elements V0 sibling to `connectedCallback`. */
attachedCallback() {
this.connectedCallback();
}
/**
* Called when the element is disconnected from the DOM.
* @final @this {!Element}
*/
disconnectedCallback() {
}
/** The Custom Elements V0 sibling to `disconnectedCallback`. */
detachedCallback() {
this.disconnectedCallback();
}
getChildren() {
return [].slice.call(this.childNodes);
}
}
win.BaseCustomElementClass = BaseCustomElement;
return win.BaseCustomElementClass;
} | javascript | function createBaseCustomElementClass(win) {
if (win.BaseCustomElementClass) {
return win.BaseCustomElementClass;
}
const htmlElement = win.HTMLElement;
/** @abstract @extends {HTMLElement} */
class BaseCustomElement extends htmlElement {
/**
* @see https://github.com/WebReflection/document-register-element#v1-caveat
* @suppress {checkTypes}
*/
constructor(self) {
self = super(self);
self.createdCallback(self.getChildren());
return self;
}
/**
* Called when elements is created. Sets instance vars since there is no
* constructor.
* @this {!Element}
*/
createdCallback() {
}
attributeChangedCallback(attrName, oldVal, newVal) {
}
/**
* Called when the element is first connected to the DOM. Calls
* {@link firstAttachedCallback} if this is the first attachment.
* @final @this {!Element}
*/
connectedCallback() {
}
/** The Custom Elements V0 sibling to `connectedCallback`. */
attachedCallback() {
this.connectedCallback();
}
/**
* Called when the element is disconnected from the DOM.
* @final @this {!Element}
*/
disconnectedCallback() {
}
/** The Custom Elements V0 sibling to `disconnectedCallback`. */
detachedCallback() {
this.disconnectedCallback();
}
getChildren() {
return [].slice.call(this.childNodes);
}
}
win.BaseCustomElementClass = BaseCustomElement;
return win.BaseCustomElementClass;
} | [
"function",
"createBaseCustomElementClass",
"(",
"win",
")",
"{",
"if",
"(",
"win",
".",
"BaseCustomElementClass",
")",
"{",
"return",
"win",
".",
"BaseCustomElementClass",
";",
"}",
"const",
"htmlElement",
"=",
"win",
".",
"HTMLElement",
";",
"/** @abstract @extends {HTMLElement} */",
"class",
"BaseCustomElement",
"extends",
"htmlElement",
"{",
"/**\n * @see https://github.com/WebReflection/document-register-element#v1-caveat\n * @suppress {checkTypes}\n */",
"constructor",
"(",
"self",
")",
"{",
"self",
"=",
"super",
"(",
"self",
")",
";",
"self",
".",
"createdCallback",
"(",
"self",
".",
"getChildren",
"(",
")",
")",
";",
"return",
"self",
";",
"}",
"/**\n * Called when elements is created. Sets instance vars since there is no\n * constructor.\n * @this {!Element}\n */",
"createdCallback",
"(",
")",
"{",
"}",
"attributeChangedCallback",
"(",
"attrName",
",",
"oldVal",
",",
"newVal",
")",
"{",
"}",
"/**\n * Called when the element is first connected to the DOM. Calls\n * {@link firstAttachedCallback} if this is the first attachment.\n * @final @this {!Element}\n */",
"connectedCallback",
"(",
")",
"{",
"}",
"/** The Custom Elements V0 sibling to `connectedCallback`. */",
"attachedCallback",
"(",
")",
"{",
"this",
".",
"connectedCallback",
"(",
")",
";",
"}",
"/**\n * Called when the element is disconnected from the DOM.\n * @final @this {!Element}\n */",
"disconnectedCallback",
"(",
")",
"{",
"}",
"/** The Custom Elements V0 sibling to `disconnectedCallback`. */",
"detachedCallback",
"(",
")",
"{",
"this",
".",
"disconnectedCallback",
"(",
")",
";",
"}",
"getChildren",
"(",
")",
"{",
"return",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"this",
".",
"childNodes",
")",
";",
"}",
"}",
"win",
".",
"BaseCustomElementClass",
"=",
"BaseCustomElement",
";",
"return",
"win",
".",
"BaseCustomElementClass",
";",
"}"
] | Creates a base custom element class.
@param {!Window} win The window in which to register the custom element.
@return {!Function} | [
"Creates",
"a",
"base",
"custom",
"element",
"class",
"."
] | 5aec1bfd5110addcbeedd01ba07b8a01c836c511 | https://github.com/fieosa/webcomponent-mdl/blob/5aec1bfd5110addcbeedd01ba07b8a01c836c511/src/utils/custom-element.js#L7-L67 |
56,482 | jsguy/mithril.component.mdl | lib/polyfills/dialog-polyfill.js | function(backdropZ, dialogZ) {
this.backdrop_.style.zIndex = backdropZ;
this.dialog_.style.zIndex = dialogZ;
} | javascript | function(backdropZ, dialogZ) {
this.backdrop_.style.zIndex = backdropZ;
this.dialog_.style.zIndex = dialogZ;
} | [
"function",
"(",
"backdropZ",
",",
"dialogZ",
")",
"{",
"this",
".",
"backdrop_",
".",
"style",
".",
"zIndex",
"=",
"backdropZ",
";",
"this",
".",
"dialog_",
".",
"style",
".",
"zIndex",
"=",
"dialogZ",
";",
"}"
] | Sets the zIndex for the backdrop and dialog.
@param {number} backdropZ
@param {number} dialogZ | [
"Sets",
"the",
"zIndex",
"for",
"the",
"backdrop",
"and",
"dialog",
"."
] | 89a132fd475e55a98b239a229842661745a53372 | https://github.com/jsguy/mithril.component.mdl/blob/89a132fd475e55a98b239a229842661745a53372/lib/polyfills/dialog-polyfill.js#L168-L171 |
|
56,483 | nfantone/mu-koan | lib/server.js | initialize | function initialize(app, options) {
var log = logger.get(options);
app._mukoan = app._mukoan || {};
if (!app._mukoan.initialized) {
var config = defaults({}, options, DEFAULT_CONFIGURATION);
log.info('Starting and configuring Koa server');
// Setup global error handler and logger
app.use(middlewares.error(config.error));
app.on('error', (error) => log.error('Unexpected exception ', error));
app._mukoan.initialized = true;
} else {
log.warn('Trying to initialize the same Koa instance twice (ignoring action)');
}
} | javascript | function initialize(app, options) {
var log = logger.get(options);
app._mukoan = app._mukoan || {};
if (!app._mukoan.initialized) {
var config = defaults({}, options, DEFAULT_CONFIGURATION);
log.info('Starting and configuring Koa server');
// Setup global error handler and logger
app.use(middlewares.error(config.error));
app.on('error', (error) => log.error('Unexpected exception ', error));
app._mukoan.initialized = true;
} else {
log.warn('Trying to initialize the same Koa instance twice (ignoring action)');
}
} | [
"function",
"initialize",
"(",
"app",
",",
"options",
")",
"{",
"var",
"log",
"=",
"logger",
".",
"get",
"(",
"options",
")",
";",
"app",
".",
"_mukoan",
"=",
"app",
".",
"_mukoan",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"app",
".",
"_mukoan",
".",
"initialized",
")",
"{",
"var",
"config",
"=",
"defaults",
"(",
"{",
"}",
",",
"options",
",",
"DEFAULT_CONFIGURATION",
")",
";",
"log",
".",
"info",
"(",
"'Starting and configuring Koa server'",
")",
";",
"// Setup global error handler and logger",
"app",
".",
"use",
"(",
"middlewares",
".",
"error",
"(",
"config",
".",
"error",
")",
")",
";",
"app",
".",
"on",
"(",
"'error'",
",",
"(",
"error",
")",
"=>",
"log",
".",
"error",
"(",
"'Unexpected exception '",
",",
"error",
")",
")",
";",
"app",
".",
"_mukoan",
".",
"initialized",
"=",
"true",
";",
"}",
"else",
"{",
"log",
".",
"warn",
"(",
"'Trying to initialize the same Koa instance twice (ignoring action)'",
")",
";",
"}",
"}"
] | Configures top level middlewares and
error logging. This should be called before `bootstrap`.
@param {Object} app A Koa app instance as created by `new Koa()`
@return {Object} The `app` instance with middleware already declared. | [
"Configures",
"top",
"level",
"middlewares",
"and",
"error",
"logging",
".",
"This",
"should",
"be",
"called",
"before",
"bootstrap",
"."
] | 3a5c5eec94509ef73263d8e30d9ef7df54611ece | https://github.com/nfantone/mu-koan/blob/3a5c5eec94509ef73263d8e30d9ef7df54611ece/lib/server.js#L28-L42 |
56,484 | nfantone/mu-koan | lib/server.js | bootstrap | function bootstrap(app, options) {
var config = defaults({}, options, DEFAULT_CONFIGURATION);
var log = logger.get(options);
app._mukoan = app._mukoan || {};
if (!app._mukoan.initialized) {
initialize(app, options);
}
if (!app._mukoan.bootstrapped) {
// Configure and setup middlewares
app.use(middlewares.bodyparser(config.bodyParser));
app.use(middlewares.morgan(config.morgan.format, config.morgan.options));
app.use(middlewares.responseTime());
app.use(middlewares.helmet(config.helmet));
app.use(middlewares.compress({
flush: zlib.Z_SYNC_FLUSH
}));
app.use(middlewares.conditional());
app.use(middlewares.etag());
app.use(middlewares.cacheControl(config.cacheControl));
app.use(middlewares.cors(config.cors));
app.use(middlewares.favicon(config.favicon));
app.use(middlewares.jwt(config.jwt.options).unless(config.jwt.unless));
app.use(middlewares.json());
app._mukoan.bootstrapped = true;
log.debug('Finished configuring Koa server');
} else {
log.warn('Trying to bootstrap the same Koa instance twice (ignoring action)');
}
return app;
} | javascript | function bootstrap(app, options) {
var config = defaults({}, options, DEFAULT_CONFIGURATION);
var log = logger.get(options);
app._mukoan = app._mukoan || {};
if (!app._mukoan.initialized) {
initialize(app, options);
}
if (!app._mukoan.bootstrapped) {
// Configure and setup middlewares
app.use(middlewares.bodyparser(config.bodyParser));
app.use(middlewares.morgan(config.morgan.format, config.morgan.options));
app.use(middlewares.responseTime());
app.use(middlewares.helmet(config.helmet));
app.use(middlewares.compress({
flush: zlib.Z_SYNC_FLUSH
}));
app.use(middlewares.conditional());
app.use(middlewares.etag());
app.use(middlewares.cacheControl(config.cacheControl));
app.use(middlewares.cors(config.cors));
app.use(middlewares.favicon(config.favicon));
app.use(middlewares.jwt(config.jwt.options).unless(config.jwt.unless));
app.use(middlewares.json());
app._mukoan.bootstrapped = true;
log.debug('Finished configuring Koa server');
} else {
log.warn('Trying to bootstrap the same Koa instance twice (ignoring action)');
}
return app;
} | [
"function",
"bootstrap",
"(",
"app",
",",
"options",
")",
"{",
"var",
"config",
"=",
"defaults",
"(",
"{",
"}",
",",
"options",
",",
"DEFAULT_CONFIGURATION",
")",
";",
"var",
"log",
"=",
"logger",
".",
"get",
"(",
"options",
")",
";",
"app",
".",
"_mukoan",
"=",
"app",
".",
"_mukoan",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"app",
".",
"_mukoan",
".",
"initialized",
")",
"{",
"initialize",
"(",
"app",
",",
"options",
")",
";",
"}",
"if",
"(",
"!",
"app",
".",
"_mukoan",
".",
"bootstrapped",
")",
"{",
"// Configure and setup middlewares",
"app",
".",
"use",
"(",
"middlewares",
".",
"bodyparser",
"(",
"config",
".",
"bodyParser",
")",
")",
";",
"app",
".",
"use",
"(",
"middlewares",
".",
"morgan",
"(",
"config",
".",
"morgan",
".",
"format",
",",
"config",
".",
"morgan",
".",
"options",
")",
")",
";",
"app",
".",
"use",
"(",
"middlewares",
".",
"responseTime",
"(",
")",
")",
";",
"app",
".",
"use",
"(",
"middlewares",
".",
"helmet",
"(",
"config",
".",
"helmet",
")",
")",
";",
"app",
".",
"use",
"(",
"middlewares",
".",
"compress",
"(",
"{",
"flush",
":",
"zlib",
".",
"Z_SYNC_FLUSH",
"}",
")",
")",
";",
"app",
".",
"use",
"(",
"middlewares",
".",
"conditional",
"(",
")",
")",
";",
"app",
".",
"use",
"(",
"middlewares",
".",
"etag",
"(",
")",
")",
";",
"app",
".",
"use",
"(",
"middlewares",
".",
"cacheControl",
"(",
"config",
".",
"cacheControl",
")",
")",
";",
"app",
".",
"use",
"(",
"middlewares",
".",
"cors",
"(",
"config",
".",
"cors",
")",
")",
";",
"app",
".",
"use",
"(",
"middlewares",
".",
"favicon",
"(",
"config",
".",
"favicon",
")",
")",
";",
"app",
".",
"use",
"(",
"middlewares",
".",
"jwt",
"(",
"config",
".",
"jwt",
".",
"options",
")",
".",
"unless",
"(",
"config",
".",
"jwt",
".",
"unless",
")",
")",
";",
"app",
".",
"use",
"(",
"middlewares",
".",
"json",
"(",
")",
")",
";",
"app",
".",
"_mukoan",
".",
"bootstrapped",
"=",
"true",
";",
"log",
".",
"debug",
"(",
"'Finished configuring Koa server'",
")",
";",
"}",
"else",
"{",
"log",
".",
"warn",
"(",
"'Trying to bootstrap the same Koa instance twice (ignoring action)'",
")",
";",
"}",
"return",
"app",
";",
"}"
] | Sets up a Koa app instance.
@param {Object} app A Koa app instance as created by `new Koa()`
@return {Object} The `app` instance with middleware already declared. | [
"Sets",
"up",
"a",
"Koa",
"app",
"instance",
"."
] | 3a5c5eec94509ef73263d8e30d9ef7df54611ece | https://github.com/nfantone/mu-koan/blob/3a5c5eec94509ef73263d8e30d9ef7df54611ece/lib/server.js#L50-L81 |
56,485 | wilmoore/sum.js | sum.js | accessor | function accessor(object) {
var ref = object || (1, eval)('this');
var len = parts.length;
var idx = 0;
// iteratively save each segment's reference
for (; idx < len; idx += 1) {
if (ref) ref = ref[parts[idx]];
}
return ref;
} | javascript | function accessor(object) {
var ref = object || (1, eval)('this');
var len = parts.length;
var idx = 0;
// iteratively save each segment's reference
for (; idx < len; idx += 1) {
if (ref) ref = ref[parts[idx]];
}
return ref;
} | [
"function",
"accessor",
"(",
"object",
")",
"{",
"var",
"ref",
"=",
"object",
"||",
"(",
"1",
",",
"eval",
")",
"(",
"'this'",
")",
";",
"var",
"len",
"=",
"parts",
".",
"length",
";",
"var",
"idx",
"=",
"0",
";",
"// iteratively save each segment's reference",
"for",
"(",
";",
"idx",
"<",
"len",
";",
"idx",
"+=",
"1",
")",
"{",
"if",
"(",
"ref",
")",
"ref",
"=",
"ref",
"[",
"parts",
"[",
"idx",
"]",
"]",
";",
"}",
"return",
"ref",
";",
"}"
] | Accessor function that accepts an object to be queried
@private
@param {Object} object
object to access
@return {Mixed}
value at given reference or undefined if it does not exist | [
"Accessor",
"function",
"that",
"accepts",
"an",
"object",
"to",
"be",
"queried"
] | 23630999bf8b2c4d33bb6acef6387f8597ad3a85 | https://github.com/wilmoore/sum.js/blob/23630999bf8b2c4d33bb6acef6387f8597ad3a85/sum.js#L100-L111 |
56,486 | willmark/img-canvas-helper | index.js | function (imgsrc, width, height, callback) {
var args = new Args(arguments);
checkCommonArgs(args);
var Image = Canvas.Image, fs = require("fs");
var img = new Image();
img.onerror = function(err) {
callback(false, err);
};
img.onload = function() {
var w = img.width;
var h = img.height;
var newx = Math.abs(w / 2 - width / 2);
var newy = Math.abs(h / 2 - height / 2);
var canvas = new Canvas(width, height);
var ctx = canvas.getContext("2d");
ctx.drawImage(img, newx, newy, width, height, 0, 0, width, height);
callback(true, canvas);
};
if (!isValidFile(imgsrc)) {
callback(false, new Error (imgsrc + ' is not a valid file'));
} else {
img.src = imgsrc;
}
} | javascript | function (imgsrc, width, height, callback) {
var args = new Args(arguments);
checkCommonArgs(args);
var Image = Canvas.Image, fs = require("fs");
var img = new Image();
img.onerror = function(err) {
callback(false, err);
};
img.onload = function() {
var w = img.width;
var h = img.height;
var newx = Math.abs(w / 2 - width / 2);
var newy = Math.abs(h / 2 - height / 2);
var canvas = new Canvas(width, height);
var ctx = canvas.getContext("2d");
ctx.drawImage(img, newx, newy, width, height, 0, 0, width, height);
callback(true, canvas);
};
if (!isValidFile(imgsrc)) {
callback(false, new Error (imgsrc + ' is not a valid file'));
} else {
img.src = imgsrc;
}
} | [
"function",
"(",
"imgsrc",
",",
"width",
",",
"height",
",",
"callback",
")",
"{",
"var",
"args",
"=",
"new",
"Args",
"(",
"arguments",
")",
";",
"checkCommonArgs",
"(",
"args",
")",
";",
"var",
"Image",
"=",
"Canvas",
".",
"Image",
",",
"fs",
"=",
"require",
"(",
"\"fs\"",
")",
";",
"var",
"img",
"=",
"new",
"Image",
"(",
")",
";",
"img",
".",
"onerror",
"=",
"function",
"(",
"err",
")",
"{",
"callback",
"(",
"false",
",",
"err",
")",
";",
"}",
";",
"img",
".",
"onload",
"=",
"function",
"(",
")",
"{",
"var",
"w",
"=",
"img",
".",
"width",
";",
"var",
"h",
"=",
"img",
".",
"height",
";",
"var",
"newx",
"=",
"Math",
".",
"abs",
"(",
"w",
"/",
"2",
"-",
"width",
"/",
"2",
")",
";",
"var",
"newy",
"=",
"Math",
".",
"abs",
"(",
"h",
"/",
"2",
"-",
"height",
"/",
"2",
")",
";",
"var",
"canvas",
"=",
"new",
"Canvas",
"(",
"width",
",",
"height",
")",
";",
"var",
"ctx",
"=",
"canvas",
".",
"getContext",
"(",
"\"2d\"",
")",
";",
"ctx",
".",
"drawImage",
"(",
"img",
",",
"newx",
",",
"newy",
",",
"width",
",",
"height",
",",
"0",
",",
"0",
",",
"width",
",",
"height",
")",
";",
"callback",
"(",
"true",
",",
"canvas",
")",
";",
"}",
";",
"if",
"(",
"!",
"isValidFile",
"(",
"imgsrc",
")",
")",
"{",
"callback",
"(",
"false",
",",
"new",
"Error",
"(",
"imgsrc",
"+",
"' is not a valid file'",
")",
")",
";",
"}",
"else",
"{",
"img",
".",
"src",
"=",
"imgsrc",
";",
"}",
"}"
] | Crops an image to bounds specified by width and height
imgsrc - string path to image to crop
width - integer width of cropped image
height - integer height of cropped image
callback - callback function(
result - boolean true on success
data - canvas object on success, Error on failure | [
"Crops",
"an",
"image",
"to",
"bounds",
"specified",
"by",
"width",
"and",
"height",
"imgsrc",
"-",
"string",
"path",
"to",
"image",
"to",
"crop",
"width",
"-",
"integer",
"width",
"of",
"cropped",
"image",
"height",
"-",
"integer",
"height",
"of",
"cropped",
"image",
"callback",
"-",
"callback",
"function",
"(",
"result",
"-",
"boolean",
"true",
"on",
"success",
"data",
"-",
"canvas",
"object",
"on",
"success",
"Error",
"on",
"failure"
] | d05ec8026eb2a74fd2dc8eec85dae3a3491ecaf1 | https://github.com/willmark/img-canvas-helper/blob/d05ec8026eb2a74fd2dc8eec85dae3a3491ecaf1/index.js#L111-L135 |
|
56,487 | mwyatt/dialogue | js/dialogue.js | handleMousedown | function handleMousedown(event) {
// get currently open dialogue
var dialogue = getDialogueCurrent();
if (dialogue.options.hardClose) {
return;
}
var result = helper.isInside(event.target, dialogue.dialogue);
if (!result) {
closeInstance(dialogue);
}
} | javascript | function handleMousedown(event) {
// get currently open dialogue
var dialogue = getDialogueCurrent();
if (dialogue.options.hardClose) {
return;
}
var result = helper.isInside(event.target, dialogue.dialogue);
if (!result) {
closeInstance(dialogue);
}
} | [
"function",
"handleMousedown",
"(",
"event",
")",
"{",
"// get currently open dialogue",
"var",
"dialogue",
"=",
"getDialogueCurrent",
"(",
")",
";",
"if",
"(",
"dialogue",
".",
"options",
".",
"hardClose",
")",
"{",
"return",
";",
"}",
"var",
"result",
"=",
"helper",
".",
"isInside",
"(",
"event",
".",
"target",
",",
"dialogue",
".",
"dialogue",
")",
";",
"if",
"(",
"!",
"result",
")",
"{",
"closeInstance",
"(",
"dialogue",
")",
";",
"}",
"}"
] | clicking anything not inside the most current dialogue | [
"clicking",
"anything",
"not",
"inside",
"the",
"most",
"current",
"dialogue"
] | c3d403262ce44d020438cb1e768556e459a7fd5e | https://github.com/mwyatt/dialogue/blob/c3d403262ce44d020438cb1e768556e459a7fd5e/js/dialogue.js#L152-L165 |
56,488 | mwyatt/dialogue | js/dialogue.js | applyCssPosition | function applyCssPosition(dialogue) {
var positionalEl = dialogue.options.positionTo;
var containerPadding = 20;
var cssSettings = {
top: '',
left: '',
position: '',
margin: '',
marginTop: 0,
marginRight: 0,
marginBottom: 0,
marginLeft: 0,
maxWidth: dialogue.options.width
};
var clientFrame = {
positionVertical: window.pageYOffset,
height: window.innerHeight,
width: window.innerWidth
};
var dialogueHeight = parseInt(dialogue.dialogue.offsetHeight);
// position container
dialogue.container.style.top = parsePx(clientFrame.positionVertical);
// position to element or centrally window
if (positionalEl) {
var boundingRect = positionalEl.getBoundingClientRect();
// calc top
cssSettings.position = 'absolute';
cssSettings.top = parseInt(boundingRect.top);
cssSettings.left = parseInt(boundingRect.left);
// if the right side of the dialogue is poking out of the clientFrame then
// bring it back in plus 50px padding
if ((cssSettings.left + cssSettings['maxWidth']) > clientFrame.width) {
cssSettings.left = clientFrame.width - 50;
cssSettings.left = cssSettings.left - cssSettings['maxWidth'];
};
// no positional element so center to window
} else {
cssSettings.position = 'relative';
cssSettings.left = 'auto';
cssSettings.marginTop = 0;
cssSettings.marginRight = 'auto';
cssSettings.marginBottom = 0;
cssSettings.marginLeft = 'auto';
// center vertically if there is room
// otherwise send to top and then just scroll
if (dialogueHeight < clientFrame.height) {
cssSettings.top = parseInt(clientFrame.height / 2) - parseInt(dialogueHeight / 2) - containerPadding;
} else {
cssSettings.top = 'auto';
};
};
dialogue.container.style.zIndex = 500 + dialoguesOpen.length;
dialogue.dialogue.style.top = parsePx(cssSettings.top);
dialogue.dialogue.style.left = parsePx(cssSettings.left);
dialogue.dialogue.style.position = parsePx(cssSettings.position);
dialogue.dialogue.style.marginTop = parsePx(cssSettings.marginTop);
dialogue.dialogue.style.marginRight = parsePx(cssSettings.marginRight);
dialogue.dialogue.style.marginBottom = parsePx(cssSettings.marginBottom);
dialogue.dialogue.style.marginLeft = parsePx(cssSettings.marginLeft);
dialogue.dialogue.style.maxWidth = parsePx(cssSettings.maxWidth);
} | javascript | function applyCssPosition(dialogue) {
var positionalEl = dialogue.options.positionTo;
var containerPadding = 20;
var cssSettings = {
top: '',
left: '',
position: '',
margin: '',
marginTop: 0,
marginRight: 0,
marginBottom: 0,
marginLeft: 0,
maxWidth: dialogue.options.width
};
var clientFrame = {
positionVertical: window.pageYOffset,
height: window.innerHeight,
width: window.innerWidth
};
var dialogueHeight = parseInt(dialogue.dialogue.offsetHeight);
// position container
dialogue.container.style.top = parsePx(clientFrame.positionVertical);
// position to element or centrally window
if (positionalEl) {
var boundingRect = positionalEl.getBoundingClientRect();
// calc top
cssSettings.position = 'absolute';
cssSettings.top = parseInt(boundingRect.top);
cssSettings.left = parseInt(boundingRect.left);
// if the right side of the dialogue is poking out of the clientFrame then
// bring it back in plus 50px padding
if ((cssSettings.left + cssSettings['maxWidth']) > clientFrame.width) {
cssSettings.left = clientFrame.width - 50;
cssSettings.left = cssSettings.left - cssSettings['maxWidth'];
};
// no positional element so center to window
} else {
cssSettings.position = 'relative';
cssSettings.left = 'auto';
cssSettings.marginTop = 0;
cssSettings.marginRight = 'auto';
cssSettings.marginBottom = 0;
cssSettings.marginLeft = 'auto';
// center vertically if there is room
// otherwise send to top and then just scroll
if (dialogueHeight < clientFrame.height) {
cssSettings.top = parseInt(clientFrame.height / 2) - parseInt(dialogueHeight / 2) - containerPadding;
} else {
cssSettings.top = 'auto';
};
};
dialogue.container.style.zIndex = 500 + dialoguesOpen.length;
dialogue.dialogue.style.top = parsePx(cssSettings.top);
dialogue.dialogue.style.left = parsePx(cssSettings.left);
dialogue.dialogue.style.position = parsePx(cssSettings.position);
dialogue.dialogue.style.marginTop = parsePx(cssSettings.marginTop);
dialogue.dialogue.style.marginRight = parsePx(cssSettings.marginRight);
dialogue.dialogue.style.marginBottom = parsePx(cssSettings.marginBottom);
dialogue.dialogue.style.marginLeft = parsePx(cssSettings.marginLeft);
dialogue.dialogue.style.maxWidth = parsePx(cssSettings.maxWidth);
} | [
"function",
"applyCssPosition",
"(",
"dialogue",
")",
"{",
"var",
"positionalEl",
"=",
"dialogue",
".",
"options",
".",
"positionTo",
";",
"var",
"containerPadding",
"=",
"20",
";",
"var",
"cssSettings",
"=",
"{",
"top",
":",
"''",
",",
"left",
":",
"''",
",",
"position",
":",
"''",
",",
"margin",
":",
"''",
",",
"marginTop",
":",
"0",
",",
"marginRight",
":",
"0",
",",
"marginBottom",
":",
"0",
",",
"marginLeft",
":",
"0",
",",
"maxWidth",
":",
"dialogue",
".",
"options",
".",
"width",
"}",
";",
"var",
"clientFrame",
"=",
"{",
"positionVertical",
":",
"window",
".",
"pageYOffset",
",",
"height",
":",
"window",
".",
"innerHeight",
",",
"width",
":",
"window",
".",
"innerWidth",
"}",
";",
"var",
"dialogueHeight",
"=",
"parseInt",
"(",
"dialogue",
".",
"dialogue",
".",
"offsetHeight",
")",
";",
"// position container",
"dialogue",
".",
"container",
".",
"style",
".",
"top",
"=",
"parsePx",
"(",
"clientFrame",
".",
"positionVertical",
")",
";",
"// position to element or centrally window",
"if",
"(",
"positionalEl",
")",
"{",
"var",
"boundingRect",
"=",
"positionalEl",
".",
"getBoundingClientRect",
"(",
")",
";",
"// calc top",
"cssSettings",
".",
"position",
"=",
"'absolute'",
";",
"cssSettings",
".",
"top",
"=",
"parseInt",
"(",
"boundingRect",
".",
"top",
")",
";",
"cssSettings",
".",
"left",
"=",
"parseInt",
"(",
"boundingRect",
".",
"left",
")",
";",
"// if the right side of the dialogue is poking out of the clientFrame then",
"// bring it back in plus 50px padding",
"if",
"(",
"(",
"cssSettings",
".",
"left",
"+",
"cssSettings",
"[",
"'maxWidth'",
"]",
")",
">",
"clientFrame",
".",
"width",
")",
"{",
"cssSettings",
".",
"left",
"=",
"clientFrame",
".",
"width",
"-",
"50",
";",
"cssSettings",
".",
"left",
"=",
"cssSettings",
".",
"left",
"-",
"cssSettings",
"[",
"'maxWidth'",
"]",
";",
"}",
";",
"// no positional element so center to window",
"}",
"else",
"{",
"cssSettings",
".",
"position",
"=",
"'relative'",
";",
"cssSettings",
".",
"left",
"=",
"'auto'",
";",
"cssSettings",
".",
"marginTop",
"=",
"0",
";",
"cssSettings",
".",
"marginRight",
"=",
"'auto'",
";",
"cssSettings",
".",
"marginBottom",
"=",
"0",
";",
"cssSettings",
".",
"marginLeft",
"=",
"'auto'",
";",
"// center vertically if there is room",
"// otherwise send to top and then just scroll",
"if",
"(",
"dialogueHeight",
"<",
"clientFrame",
".",
"height",
")",
"{",
"cssSettings",
".",
"top",
"=",
"parseInt",
"(",
"clientFrame",
".",
"height",
"/",
"2",
")",
"-",
"parseInt",
"(",
"dialogueHeight",
"/",
"2",
")",
"-",
"containerPadding",
";",
"}",
"else",
"{",
"cssSettings",
".",
"top",
"=",
"'auto'",
";",
"}",
";",
"}",
";",
"dialogue",
".",
"container",
".",
"style",
".",
"zIndex",
"=",
"500",
"+",
"dialoguesOpen",
".",
"length",
";",
"dialogue",
".",
"dialogue",
".",
"style",
".",
"top",
"=",
"parsePx",
"(",
"cssSettings",
".",
"top",
")",
";",
"dialogue",
".",
"dialogue",
".",
"style",
".",
"left",
"=",
"parsePx",
"(",
"cssSettings",
".",
"left",
")",
";",
"dialogue",
".",
"dialogue",
".",
"style",
".",
"position",
"=",
"parsePx",
"(",
"cssSettings",
".",
"position",
")",
";",
"dialogue",
".",
"dialogue",
".",
"style",
".",
"marginTop",
"=",
"parsePx",
"(",
"cssSettings",
".",
"marginTop",
")",
";",
"dialogue",
".",
"dialogue",
".",
"style",
".",
"marginRight",
"=",
"parsePx",
"(",
"cssSettings",
".",
"marginRight",
")",
";",
"dialogue",
".",
"dialogue",
".",
"style",
".",
"marginBottom",
"=",
"parsePx",
"(",
"cssSettings",
".",
"marginBottom",
")",
";",
"dialogue",
".",
"dialogue",
".",
"style",
".",
"marginLeft",
"=",
"parsePx",
"(",
"cssSettings",
".",
"marginLeft",
")",
";",
"dialogue",
".",
"dialogue",
".",
"style",
".",
"maxWidth",
"=",
"parsePx",
"(",
"cssSettings",
".",
"maxWidth",
")",
";",
"}"
] | apply the css to the dialogue to position correctly | [
"apply",
"the",
"css",
"to",
"the",
"dialogue",
"to",
"position",
"correctly"
] | c3d403262ce44d020438cb1e768556e459a7fd5e | https://github.com/mwyatt/dialogue/blob/c3d403262ce44d020438cb1e768556e459a7fd5e/js/dialogue.js#L213-L281 |
56,489 | mwyatt/dialogue | js/dialogue.js | closeInstance | function closeInstance(dialogue) {
// none may be open yet, or one may be open but may be closing another which is not open
if (typeof dialogue === 'undefined' || typeof dialogue.options === 'undefined' || !dialoguesOpen.length) {
return;
}
dialoguesOpen.forEach(function(dialogueSingle, index) {
if (dialogueSingle.options.id == dialogue.options.id) {
dialoguesOpen.splice(index, 1);
}
});
if (!dialoguesOpen.length) {
document.removeEventListener('keyup', handleKeyup);
document.removeEventListener('mousedown', handleMousedown);
}
// .off('click.dialogue.action')
// dialogue.container.off(); // needed?
docBody.removeChild(dialogue.container);
dialogue.options.onClose.call(dialogue);
} | javascript | function closeInstance(dialogue) {
// none may be open yet, or one may be open but may be closing another which is not open
if (typeof dialogue === 'undefined' || typeof dialogue.options === 'undefined' || !dialoguesOpen.length) {
return;
}
dialoguesOpen.forEach(function(dialogueSingle, index) {
if (dialogueSingle.options.id == dialogue.options.id) {
dialoguesOpen.splice(index, 1);
}
});
if (!dialoguesOpen.length) {
document.removeEventListener('keyup', handleKeyup);
document.removeEventListener('mousedown', handleMousedown);
}
// .off('click.dialogue.action')
// dialogue.container.off(); // needed?
docBody.removeChild(dialogue.container);
dialogue.options.onClose.call(dialogue);
} | [
"function",
"closeInstance",
"(",
"dialogue",
")",
"{",
"// none may be open yet, or one may be open but may be closing another which is not open",
"if",
"(",
"typeof",
"dialogue",
"===",
"'undefined'",
"||",
"typeof",
"dialogue",
".",
"options",
"===",
"'undefined'",
"||",
"!",
"dialoguesOpen",
".",
"length",
")",
"{",
"return",
";",
"}",
"dialoguesOpen",
".",
"forEach",
"(",
"function",
"(",
"dialogueSingle",
",",
"index",
")",
"{",
"if",
"(",
"dialogueSingle",
".",
"options",
".",
"id",
"==",
"dialogue",
".",
"options",
".",
"id",
")",
"{",
"dialoguesOpen",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"}",
"}",
")",
";",
"if",
"(",
"!",
"dialoguesOpen",
".",
"length",
")",
"{",
"document",
".",
"removeEventListener",
"(",
"'keyup'",
",",
"handleKeyup",
")",
";",
"document",
".",
"removeEventListener",
"(",
"'mousedown'",
",",
"handleMousedown",
")",
";",
"}",
"// .off('click.dialogue.action')",
"// dialogue.container.off(); // needed?",
"docBody",
".",
"removeChild",
"(",
"dialogue",
".",
"container",
")",
";",
"dialogue",
".",
"options",
".",
"onClose",
".",
"call",
"(",
"dialogue",
")",
";",
"}"
] | call onclose and remove
@param {object} data
@return {null} | [
"call",
"onclose",
"and",
"remove"
] | c3d403262ce44d020438cb1e768556e459a7fd5e | https://github.com/mwyatt/dialogue/blob/c3d403262ce44d020438cb1e768556e459a7fd5e/js/dialogue.js#L288-L311 |
56,490 | UXFoundry/hashdo | lib/template.js | function (file) {
return Path.join(Path.dirname(Path.relative(hbTemplatePath, file)), Path.basename(file, Path.extname(file)));
} | javascript | function (file) {
return Path.join(Path.dirname(Path.relative(hbTemplatePath, file)), Path.basename(file, Path.extname(file)));
} | [
"function",
"(",
"file",
")",
"{",
"return",
"Path",
".",
"join",
"(",
"Path",
".",
"dirname",
"(",
"Path",
".",
"relative",
"(",
"hbTemplatePath",
",",
"file",
")",
")",
",",
"Path",
".",
"basename",
"(",
"file",
",",
"Path",
".",
"extname",
"(",
"file",
")",
")",
")",
";",
"}"
] | Consolidate needs partial paths relative to the main tempalte being rendered and without the extension. | [
"Consolidate",
"needs",
"partial",
"paths",
"relative",
"to",
"the",
"main",
"tempalte",
"being",
"rendered",
"and",
"without",
"the",
"extension",
"."
] | c2a0adcba0cca26d6ebe56bba17017b177609057 | https://github.com/UXFoundry/hashdo/blob/c2a0adcba0cca26d6ebe56bba17017b177609057/lib/template.js#L50-L52 |
|
56,491 | pinyin/outline | vendor/transformation-matrix/scale.js | scale | function scale(sx) {
var sy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
if ((0, _utils.isUndefined)(sy)) sy = sx;
return {
a: sx, c: 0, e: 0,
b: 0, d: sy, f: 0
};
} | javascript | function scale(sx) {
var sy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
if ((0, _utils.isUndefined)(sy)) sy = sx;
return {
a: sx, c: 0, e: 0,
b: 0, d: sy, f: 0
};
} | [
"function",
"scale",
"(",
"sx",
")",
"{",
"var",
"sy",
"=",
"arguments",
".",
"length",
">",
"1",
"&&",
"arguments",
"[",
"1",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"1",
"]",
":",
"undefined",
";",
"if",
"(",
"(",
"0",
",",
"_utils",
".",
"isUndefined",
")",
"(",
"sy",
")",
")",
"sy",
"=",
"sx",
";",
"return",
"{",
"a",
":",
"sx",
",",
"c",
":",
"0",
",",
"e",
":",
"0",
",",
"b",
":",
"0",
",",
"d",
":",
"sy",
",",
"f",
":",
"0",
"}",
";",
"}"
] | Calculate a scaling matrix
@param sx Scaling on axis x
@param [sy = sx] Scaling on axis y (default sx)
@returns {{a: number, b: number, c: number, e: number, d: number, f: number}} Affine matrix | [
"Calculate",
"a",
"scaling",
"matrix"
] | e49f05d2f8ab384f5b1d71b2b10875cd48d41051 | https://github.com/pinyin/outline/blob/e49f05d2f8ab384f5b1d71b2b10875cd48d41051/vendor/transformation-matrix/scale.js#L16-L24 |
56,492 | switer/sutils | url.js | function (surl) {
var search = (surl || window.location.search).match(/\?.*(?=\b|#)/);
search && (search = search[0].replace(/^\?/, ''));
if (!search) return {};
var queries = {},
params = search.split('&');
util.each(params, function (item) {
var param = item.split('=');
queries[param[0]] = param[1];
});
return queries;
} | javascript | function (surl) {
var search = (surl || window.location.search).match(/\?.*(?=\b|#)/);
search && (search = search[0].replace(/^\?/, ''));
if (!search) return {};
var queries = {},
params = search.split('&');
util.each(params, function (item) {
var param = item.split('=');
queries[param[0]] = param[1];
});
return queries;
} | [
"function",
"(",
"surl",
")",
"{",
"var",
"search",
"=",
"(",
"surl",
"||",
"window",
".",
"location",
".",
"search",
")",
".",
"match",
"(",
"/",
"\\?.*(?=\\b|#)",
"/",
")",
";",
"search",
"&&",
"(",
"search",
"=",
"search",
"[",
"0",
"]",
".",
"replace",
"(",
"/",
"^\\?",
"/",
",",
"''",
")",
")",
";",
"if",
"(",
"!",
"search",
")",
"return",
"{",
"}",
";",
"var",
"queries",
"=",
"{",
"}",
",",
"params",
"=",
"search",
".",
"split",
"(",
"'&'",
")",
";",
"util",
".",
"each",
"(",
"params",
",",
"function",
"(",
"item",
")",
"{",
"var",
"param",
"=",
"item",
".",
"split",
"(",
"'='",
")",
";",
"queries",
"[",
"param",
"[",
"0",
"]",
"]",
"=",
"param",
"[",
"1",
"]",
";",
"}",
")",
";",
"return",
"queries",
";",
"}"
] | params in url of location.search | [
"params",
"in",
"url",
"of",
"location",
".",
"search"
] | 2573c2498e62837da132ada8a2109d42d9f9d0ca | https://github.com/switer/sutils/blob/2573c2498e62837da132ada8a2109d42d9f9d0ca/url.js#L44-L57 |
|
56,493 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/skin.js | function( part, fn ) {
if ( CKEDITOR.skin.name != getName() ) {
CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( getConfigPath() + 'skin.js' ), function() {
loadCss( part, fn );
} );
} else {
loadCss( part, fn );
}
} | javascript | function( part, fn ) {
if ( CKEDITOR.skin.name != getName() ) {
CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( getConfigPath() + 'skin.js' ), function() {
loadCss( part, fn );
} );
} else {
loadCss( part, fn );
}
} | [
"function",
"(",
"part",
",",
"fn",
")",
"{",
"if",
"(",
"CKEDITOR",
".",
"skin",
".",
"name",
"!=",
"getName",
"(",
")",
")",
"{",
"CKEDITOR",
".",
"scriptLoader",
".",
"load",
"(",
"CKEDITOR",
".",
"getUrl",
"(",
"getConfigPath",
"(",
")",
"+",
"'skin.js'",
")",
",",
"function",
"(",
")",
"{",
"loadCss",
"(",
"part",
",",
"fn",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"loadCss",
"(",
"part",
",",
"fn",
")",
";",
"}",
"}"
] | Loads a skin part into the page. Does nothing if the part has already been loaded.
**Note:** The "editor" part is always auto loaded upon instance creation,
thus this function is mainly used to **lazy load** other parts of the skin
that do not have to be displayed until requested.
// Load the dialog part.
editor.skin.loadPart( 'dialog' );
@param {String} part The name of the skin part CSS file that resides in the skin directory.
@param {Function} fn The provided callback function which is invoked after the part is loaded. | [
"Loads",
"a",
"skin",
"part",
"into",
"the",
"page",
".",
"Does",
"nothing",
"if",
"the",
"part",
"has",
"already",
"been",
"loaded",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/skin.js#L49-L57 |
|
56,494 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/skin.js | function( name, path, offset, bgsize ) {
name = name.toLowerCase();
if ( !this.icons[ name ] ) {
this.icons[ name ] = {
path: path,
offset: offset || 0,
bgsize: bgsize || '16px'
};
}
} | javascript | function( name, path, offset, bgsize ) {
name = name.toLowerCase();
if ( !this.icons[ name ] ) {
this.icons[ name ] = {
path: path,
offset: offset || 0,
bgsize: bgsize || '16px'
};
}
} | [
"function",
"(",
"name",
",",
"path",
",",
"offset",
",",
"bgsize",
")",
"{",
"name",
"=",
"name",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"!",
"this",
".",
"icons",
"[",
"name",
"]",
")",
"{",
"this",
".",
"icons",
"[",
"name",
"]",
"=",
"{",
"path",
":",
"path",
",",
"offset",
":",
"offset",
"||",
"0",
",",
"bgsize",
":",
"bgsize",
"||",
"'16px'",
"}",
";",
"}",
"}"
] | Registers an icon.
@param {String} name The icon name.
@param {String} path The path to the icon image file.
@param {Number} [offset] The vertical offset position of the icon, if
available inside a strip image.
@param {String} [bgsize] The value of the CSS "background-size" property to
use for this icon | [
"Registers",
"an",
"icon",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/skin.js#L83-L92 |
|
56,495 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/skin.js | function( name, rtl, overridePath, overrideOffset, overrideBgsize ) {
var icon, path, offset, bgsize;
if ( name ) {
name = name.toLowerCase();
// If we're in RTL, try to get the RTL version of the icon.
if ( rtl )
icon = this.icons[ name + '-rtl' ];
// If not in LTR or no RTL version available, get the generic one.
if ( !icon )
icon = this.icons[ name ];
}
path = overridePath || ( icon && icon.path ) || '';
offset = overrideOffset || ( icon && icon.offset );
bgsize = overrideBgsize || ( icon && icon.bgsize ) || '16px';
return path &&
( 'background-image:url(' + CKEDITOR.getUrl( path ) + ');background-position:0 ' + offset + 'px;background-size:' + bgsize + ';' );
} | javascript | function( name, rtl, overridePath, overrideOffset, overrideBgsize ) {
var icon, path, offset, bgsize;
if ( name ) {
name = name.toLowerCase();
// If we're in RTL, try to get the RTL version of the icon.
if ( rtl )
icon = this.icons[ name + '-rtl' ];
// If not in LTR or no RTL version available, get the generic one.
if ( !icon )
icon = this.icons[ name ];
}
path = overridePath || ( icon && icon.path ) || '';
offset = overrideOffset || ( icon && icon.offset );
bgsize = overrideBgsize || ( icon && icon.bgsize ) || '16px';
return path &&
( 'background-image:url(' + CKEDITOR.getUrl( path ) + ');background-position:0 ' + offset + 'px;background-size:' + bgsize + ';' );
} | [
"function",
"(",
"name",
",",
"rtl",
",",
"overridePath",
",",
"overrideOffset",
",",
"overrideBgsize",
")",
"{",
"var",
"icon",
",",
"path",
",",
"offset",
",",
"bgsize",
";",
"if",
"(",
"name",
")",
"{",
"name",
"=",
"name",
".",
"toLowerCase",
"(",
")",
";",
"// If we're in RTL, try to get the RTL version of the icon.",
"if",
"(",
"rtl",
")",
"icon",
"=",
"this",
".",
"icons",
"[",
"name",
"+",
"'-rtl'",
"]",
";",
"// If not in LTR or no RTL version available, get the generic one.",
"if",
"(",
"!",
"icon",
")",
"icon",
"=",
"this",
".",
"icons",
"[",
"name",
"]",
";",
"}",
"path",
"=",
"overridePath",
"||",
"(",
"icon",
"&&",
"icon",
".",
"path",
")",
"||",
"''",
";",
"offset",
"=",
"overrideOffset",
"||",
"(",
"icon",
"&&",
"icon",
".",
"offset",
")",
";",
"bgsize",
"=",
"overrideBgsize",
"||",
"(",
"icon",
"&&",
"icon",
".",
"bgsize",
")",
"||",
"'16px'",
";",
"return",
"path",
"&&",
"(",
"'background-image:url('",
"+",
"CKEDITOR",
".",
"getUrl",
"(",
"path",
")",
"+",
"');background-position:0 '",
"+",
"offset",
"+",
"'px;background-size:'",
"+",
"bgsize",
"+",
"';'",
")",
";",
"}"
] | Gets the CSS background styles to be used to render a specific icon.
@param {String} name The icon name, as registered with {@link #addIcon}.
@param {Boolean} [rtl] Indicates that the RTL version of the icon is
to be used, if available.
@param {String} [overridePath] The path to the icon image file. It
overrides the path defined by the named icon, if available, and is
used if the named icon was not registered.
@param {Number} [overrideOffset] The vertical offset position of the
icon. It overrides the offset defined by the named icon, if
available, and is used if the named icon was not registered.
@param {String} [overrideBgsize] The value of the CSS "background-size" property
to use for the icon. It overrides the value defined by the named icon,
if available, and is used if the named icon was not registered. | [
"Gets",
"the",
"CSS",
"background",
"styles",
"to",
"be",
"used",
"to",
"render",
"a",
"specific",
"icon",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/skin.js#L110-L130 |
|
56,496 | adiwidjaja/frontend-pagebuilder | js/tinymce/tinymce.jquery.js | function (LazyValue, Bounce) {
var nu = function (baseFn) {
var get = function(callback) {
baseFn(Bounce.bounce(callback));
};
/** map :: this Future a -> (a -> b) -> Future b */
var map = function (fab) {
return nu(function (callback) {
get(function (a) {
var value = fab(a);
callback(value);
});
});
};
/** bind :: this Future a -> (a -> Future b) -> Future b */
var bind = function (aFutureB) {
return nu(function (callback) {
get(function (a) {
aFutureB(a).get(callback);
});
});
};
/** anonBind :: this Future a -> Future b -> Future b
* Returns a future, which evaluates the first future, ignores the result, then evaluates the second.
*/
var anonBind = function (futureB) {
return nu(function (callback) {
get(function (a) {
futureB.get(callback);
});
});
};
var toLazy = function () {
return LazyValue.nu(get);
};
return {
map: map,
bind: bind,
anonBind: anonBind,
toLazy: toLazy,
get: get
};
};
/** a -> Future a */
var pure = function (a) {
return nu(function (callback) {
callback(a);
});
};
return {
nu: nu,
pure: pure
};
} | javascript | function (LazyValue, Bounce) {
var nu = function (baseFn) {
var get = function(callback) {
baseFn(Bounce.bounce(callback));
};
/** map :: this Future a -> (a -> b) -> Future b */
var map = function (fab) {
return nu(function (callback) {
get(function (a) {
var value = fab(a);
callback(value);
});
});
};
/** bind :: this Future a -> (a -> Future b) -> Future b */
var bind = function (aFutureB) {
return nu(function (callback) {
get(function (a) {
aFutureB(a).get(callback);
});
});
};
/** anonBind :: this Future a -> Future b -> Future b
* Returns a future, which evaluates the first future, ignores the result, then evaluates the second.
*/
var anonBind = function (futureB) {
return nu(function (callback) {
get(function (a) {
futureB.get(callback);
});
});
};
var toLazy = function () {
return LazyValue.nu(get);
};
return {
map: map,
bind: bind,
anonBind: anonBind,
toLazy: toLazy,
get: get
};
};
/** a -> Future a */
var pure = function (a) {
return nu(function (callback) {
callback(a);
});
};
return {
nu: nu,
pure: pure
};
} | [
"function",
"(",
"LazyValue",
",",
"Bounce",
")",
"{",
"var",
"nu",
"=",
"function",
"(",
"baseFn",
")",
"{",
"var",
"get",
"=",
"function",
"(",
"callback",
")",
"{",
"baseFn",
"(",
"Bounce",
".",
"bounce",
"(",
"callback",
")",
")",
";",
"}",
";",
"/** map :: this Future a -> (a -> b) -> Future b */",
"var",
"map",
"=",
"function",
"(",
"fab",
")",
"{",
"return",
"nu",
"(",
"function",
"(",
"callback",
")",
"{",
"get",
"(",
"function",
"(",
"a",
")",
"{",
"var",
"value",
"=",
"fab",
"(",
"a",
")",
";",
"callback",
"(",
"value",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}",
";",
"/** bind :: this Future a -> (a -> Future b) -> Future b */",
"var",
"bind",
"=",
"function",
"(",
"aFutureB",
")",
"{",
"return",
"nu",
"(",
"function",
"(",
"callback",
")",
"{",
"get",
"(",
"function",
"(",
"a",
")",
"{",
"aFutureB",
"(",
"a",
")",
".",
"get",
"(",
"callback",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}",
";",
"/** anonBind :: this Future a -> Future b -> Future b\n * Returns a future, which evaluates the first future, ignores the result, then evaluates the second.\n */",
"var",
"anonBind",
"=",
"function",
"(",
"futureB",
")",
"{",
"return",
"nu",
"(",
"function",
"(",
"callback",
")",
"{",
"get",
"(",
"function",
"(",
"a",
")",
"{",
"futureB",
".",
"get",
"(",
"callback",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}",
";",
"var",
"toLazy",
"=",
"function",
"(",
")",
"{",
"return",
"LazyValue",
".",
"nu",
"(",
"get",
")",
";",
"}",
";",
"return",
"{",
"map",
":",
"map",
",",
"bind",
":",
"bind",
",",
"anonBind",
":",
"anonBind",
",",
"toLazy",
":",
"toLazy",
",",
"get",
":",
"get",
"}",
";",
"}",
";",
"/** a -> Future a */",
"var",
"pure",
"=",
"function",
"(",
"a",
")",
"{",
"return",
"nu",
"(",
"function",
"(",
"callback",
")",
"{",
"callback",
"(",
"a",
")",
";",
"}",
")",
";",
"}",
";",
"return",
"{",
"nu",
":",
"nu",
",",
"pure",
":",
"pure",
"}",
";",
"}"
] | A future value that is evaluated on demand. The base function is re-evaluated each time 'get' is called. | [
"A",
"future",
"value",
"that",
"is",
"evaluated",
"on",
"demand",
".",
"The",
"base",
"function",
"is",
"re",
"-",
"evaluated",
"each",
"time",
"get",
"is",
"called",
"."
] | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L7181-L7242 |
|
56,497 | adiwidjaja/frontend-pagebuilder | js/tinymce/tinymce.jquery.js | function (elm, rootElm) {
var self = this, x = 0, y = 0, offsetParent, doc = self.doc, body = doc.body, pos;
elm = self.get(elm);
rootElm = rootElm || body;
if (elm) {
// Use getBoundingClientRect if it exists since it's faster than looping offset nodes
// Fallback to offsetParent calculations if the body isn't static better since it stops at the body root
if (rootElm === body && elm.getBoundingClientRect && DomQuery(body).css('position') === 'static') {
pos = elm.getBoundingClientRect();
rootElm = self.boxModel ? doc.documentElement : body;
// Add scroll offsets from documentElement or body since IE with the wrong box model will use d.body and so do WebKit
// Also remove the body/documentelement clientTop/clientLeft on IE 6, 7 since they offset the position
x = pos.left + (doc.documentElement.scrollLeft || body.scrollLeft) - rootElm.clientLeft;
y = pos.top + (doc.documentElement.scrollTop || body.scrollTop) - rootElm.clientTop;
return { x: x, y: y };
}
offsetParent = elm;
while (offsetParent && offsetParent != rootElm && offsetParent.nodeType) {
x += offsetParent.offsetLeft || 0;
y += offsetParent.offsetTop || 0;
offsetParent = offsetParent.offsetParent;
}
offsetParent = elm.parentNode;
while (offsetParent && offsetParent != rootElm && offsetParent.nodeType) {
x -= offsetParent.scrollLeft || 0;
y -= offsetParent.scrollTop || 0;
offsetParent = offsetParent.parentNode;
}
}
return { x: x, y: y };
} | javascript | function (elm, rootElm) {
var self = this, x = 0, y = 0, offsetParent, doc = self.doc, body = doc.body, pos;
elm = self.get(elm);
rootElm = rootElm || body;
if (elm) {
// Use getBoundingClientRect if it exists since it's faster than looping offset nodes
// Fallback to offsetParent calculations if the body isn't static better since it stops at the body root
if (rootElm === body && elm.getBoundingClientRect && DomQuery(body).css('position') === 'static') {
pos = elm.getBoundingClientRect();
rootElm = self.boxModel ? doc.documentElement : body;
// Add scroll offsets from documentElement or body since IE with the wrong box model will use d.body and so do WebKit
// Also remove the body/documentelement clientTop/clientLeft on IE 6, 7 since they offset the position
x = pos.left + (doc.documentElement.scrollLeft || body.scrollLeft) - rootElm.clientLeft;
y = pos.top + (doc.documentElement.scrollTop || body.scrollTop) - rootElm.clientTop;
return { x: x, y: y };
}
offsetParent = elm;
while (offsetParent && offsetParent != rootElm && offsetParent.nodeType) {
x += offsetParent.offsetLeft || 0;
y += offsetParent.offsetTop || 0;
offsetParent = offsetParent.offsetParent;
}
offsetParent = elm.parentNode;
while (offsetParent && offsetParent != rootElm && offsetParent.nodeType) {
x -= offsetParent.scrollLeft || 0;
y -= offsetParent.scrollTop || 0;
offsetParent = offsetParent.parentNode;
}
}
return { x: x, y: y };
} | [
"function",
"(",
"elm",
",",
"rootElm",
")",
"{",
"var",
"self",
"=",
"this",
",",
"x",
"=",
"0",
",",
"y",
"=",
"0",
",",
"offsetParent",
",",
"doc",
"=",
"self",
".",
"doc",
",",
"body",
"=",
"doc",
".",
"body",
",",
"pos",
";",
"elm",
"=",
"self",
".",
"get",
"(",
"elm",
")",
";",
"rootElm",
"=",
"rootElm",
"||",
"body",
";",
"if",
"(",
"elm",
")",
"{",
"// Use getBoundingClientRect if it exists since it's faster than looping offset nodes",
"// Fallback to offsetParent calculations if the body isn't static better since it stops at the body root",
"if",
"(",
"rootElm",
"===",
"body",
"&&",
"elm",
".",
"getBoundingClientRect",
"&&",
"DomQuery",
"(",
"body",
")",
".",
"css",
"(",
"'position'",
")",
"===",
"'static'",
")",
"{",
"pos",
"=",
"elm",
".",
"getBoundingClientRect",
"(",
")",
";",
"rootElm",
"=",
"self",
".",
"boxModel",
"?",
"doc",
".",
"documentElement",
":",
"body",
";",
"// Add scroll offsets from documentElement or body since IE with the wrong box model will use d.body and so do WebKit",
"// Also remove the body/documentelement clientTop/clientLeft on IE 6, 7 since they offset the position",
"x",
"=",
"pos",
".",
"left",
"+",
"(",
"doc",
".",
"documentElement",
".",
"scrollLeft",
"||",
"body",
".",
"scrollLeft",
")",
"-",
"rootElm",
".",
"clientLeft",
";",
"y",
"=",
"pos",
".",
"top",
"+",
"(",
"doc",
".",
"documentElement",
".",
"scrollTop",
"||",
"body",
".",
"scrollTop",
")",
"-",
"rootElm",
".",
"clientTop",
";",
"return",
"{",
"x",
":",
"x",
",",
"y",
":",
"y",
"}",
";",
"}",
"offsetParent",
"=",
"elm",
";",
"while",
"(",
"offsetParent",
"&&",
"offsetParent",
"!=",
"rootElm",
"&&",
"offsetParent",
".",
"nodeType",
")",
"{",
"x",
"+=",
"offsetParent",
".",
"offsetLeft",
"||",
"0",
";",
"y",
"+=",
"offsetParent",
".",
"offsetTop",
"||",
"0",
";",
"offsetParent",
"=",
"offsetParent",
".",
"offsetParent",
";",
"}",
"offsetParent",
"=",
"elm",
".",
"parentNode",
";",
"while",
"(",
"offsetParent",
"&&",
"offsetParent",
"!=",
"rootElm",
"&&",
"offsetParent",
".",
"nodeType",
")",
"{",
"x",
"-=",
"offsetParent",
".",
"scrollLeft",
"||",
"0",
";",
"y",
"-=",
"offsetParent",
".",
"scrollTop",
"||",
"0",
";",
"offsetParent",
"=",
"offsetParent",
".",
"parentNode",
";",
"}",
"}",
"return",
"{",
"x",
":",
"x",
",",
"y",
":",
"y",
"}",
";",
"}"
] | Returns the absolute x, y position of a node. The position will be returned in an object with x, y fields.
@method getPos
@param {Element/String} elm HTML element or element id to get x, y position from.
@param {Element} rootElm Optional root element to stop calculations at.
@return {object} Absolute position of the specified element object with x, y fields. | [
"Returns",
"the",
"absolute",
"x",
"y",
"position",
"of",
"a",
"node",
".",
"The",
"position",
"will",
"be",
"returned",
"in",
"an",
"object",
"with",
"x",
"y",
"fields",
"."
] | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L10391-L10428 |
|
56,498 | adiwidjaja/frontend-pagebuilder | js/tinymce/tinymce.jquery.js | function (element) {
var el = element.dom();
var defaultView = el.ownerDocument.defaultView;
return Element.fromDom(defaultView);
} | javascript | function (element) {
var el = element.dom();
var defaultView = el.ownerDocument.defaultView;
return Element.fromDom(defaultView);
} | [
"function",
"(",
"element",
")",
"{",
"var",
"el",
"=",
"element",
".",
"dom",
"(",
")",
";",
"var",
"defaultView",
"=",
"el",
".",
"ownerDocument",
".",
"defaultView",
";",
"return",
"Element",
".",
"fromDom",
"(",
"defaultView",
")",
";",
"}"
] | The window element associated with the element | [
"The",
"window",
"element",
"associated",
"with",
"the",
"element"
] | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L16094-L16098 |
|
56,499 | adiwidjaja/frontend-pagebuilder | js/tinymce/tinymce.jquery.js | function (dom, selection) {
var caretContainer;
caretContainer = getParentCaretContainer(selection.getStart());
if (caretContainer && !dom.isEmpty(caretContainer)) {
Tools.walk(caretContainer, function (node) {
if (node.nodeType === 1 && node.id !== CARET_ID && !dom.isEmpty(node)) {
dom.setAttrib(node, 'data-mce-bogus', null);
}
}, 'childNodes');
}
} | javascript | function (dom, selection) {
var caretContainer;
caretContainer = getParentCaretContainer(selection.getStart());
if (caretContainer && !dom.isEmpty(caretContainer)) {
Tools.walk(caretContainer, function (node) {
if (node.nodeType === 1 && node.id !== CARET_ID && !dom.isEmpty(node)) {
dom.setAttrib(node, 'data-mce-bogus', null);
}
}, 'childNodes');
}
} | [
"function",
"(",
"dom",
",",
"selection",
")",
"{",
"var",
"caretContainer",
";",
"caretContainer",
"=",
"getParentCaretContainer",
"(",
"selection",
".",
"getStart",
"(",
")",
")",
";",
"if",
"(",
"caretContainer",
"&&",
"!",
"dom",
".",
"isEmpty",
"(",
"caretContainer",
")",
")",
"{",
"Tools",
".",
"walk",
"(",
"caretContainer",
",",
"function",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"nodeType",
"===",
"1",
"&&",
"node",
".",
"id",
"!==",
"CARET_ID",
"&&",
"!",
"dom",
".",
"isEmpty",
"(",
"node",
")",
")",
"{",
"dom",
".",
"setAttrib",
"(",
"node",
",",
"'data-mce-bogus'",
",",
"null",
")",
";",
"}",
"}",
",",
"'childNodes'",
")",
";",
"}",
"}"
] | Checks if the parent caret container node isn't empty if that is the case it will remove the bogus state on all children that isn't empty | [
"Checks",
"if",
"the",
"parent",
"caret",
"container",
"node",
"isn",
"t",
"empty",
"if",
"that",
"is",
"the",
"case",
"it",
"will",
"remove",
"the",
"bogus",
"state",
"on",
"all",
"children",
"that",
"isn",
"t",
"empty"
] | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L17568-L17579 |
Subsets and Splits