_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 27 233k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q42500 | mergeHooks | train | function mergeHooks( target, source ) {
const propNames = Object.keys( source );
for ( let i = 0, numNames = propNames.length; i < numNames; i++ ) {
const name = propNames[i];
let hook = source[name];
if ( typeof hook === "function" ) {
hook = [hook];
}
if ( !Array.isArray( hook ) ) {
throw new Typ... | javascript | {
"resource": ""
} |
q42501 | byteof | train | function byteof(object){
const objects = [object]
let bytes = 0;
for (let index = 0; index < objects.length; index ++){
const object=objects[index]
switch (typeof object){
case 'boolean':
bytes += BYTES.BOOLEAN
break
case 'number':
bytes += BYTES.NUMBER
... | javascript | {
"resource": ""
} |
q42502 | promesso | train | function promesso (handler) {
const handleFn = isFunction(handler) ? [handler] : handler;
const middlewares = [];
let validations = 0;
handleFn.forEach(h => {
if (!isFunction(h)) throw new Error('Handler is expected to be a | javascript | {
"resource": ""
} |
q42503 | validationMiddleware | train | function validationMiddleware (err, req, res, next) {
if (!err instanceof ValidationError) return next(err);
| javascript | {
"resource": ""
} |
q42504 | sum | train | function sum(list, fun) {
fun = toString.call(fun) == '[object String]' ? selectn(fun) : fun;
end = list.length;
sum = -0;
idx = -1;
while (++idx < end) { | javascript | {
"resource": ""
} |
q42505 | StreamHandler | train | function StreamHandler(host, port, delimiter) {
events.EventEmitter.call(this);
var self = this;
self.delimiter = delimiter || "\r\n";
self.host = host;
self.port = port;
self.buffer = '';
self.conn = net.createConnection(self.port, self.host);
self.conn.setEncoding("utf8");
self.conn.on('erro... | javascript | {
"resource": ""
} |
q42506 | train | function(file, file_done) {
var item = {};
item.file_path = path.join(nell_site[type_path_key], file);
item.file_output = generateOutputDetails(nell_site, file, type);
item.link = item.file_output.link_path;
var processContent = concat(function(err, file_content_raw) {
if (err) {
retu... | javascript | {
"resource": ""
} | |
q42507 | connect | train | function connect()
{
if(scope._conn)
{
if(scope._conn.readyState === 1)
{
return;
}
scope._conn.close();
}
var url = (scope._redirectURL.length>0) ? scope._redirectURL : scope._url;
scope._conn = new ... | javascript | {
"resource": ""
} |
q42508 | onArrayBuffer | train | function onArrayBuffer(data)
{
var arr = bufferToArray(scope.byteType,data);
if(arr)
{
if(arr[arr.length-1] == MessageType.RTC_FAIL && scope.rtcFallback == true && scope.useRTC == true)
{
if(scope.onRTCFallback)
{
... | javascript | {
"resource": ""
} |
q42509 | changeServer | train | function changeServer(url)
{
scope._redirectURL = url;
if(scope._conn)
{
scope._conn.onopen = null;
scope._conn.onerror = null;
scope._conn.onclose = | javascript | {
"resource": ""
} |
q42510 | Exception | train | function Exception(code, message) {
Error.captureStackTrace(this, Exception);
this.name = Exception.name;
| javascript | {
"resource": ""
} |
q42511 | bemDirs | train | function bemDirs(bemdeps) {
const dirFilter = {};
bemdeps.forEach((dep) => {
const depPath = bemPath(dep);
const depDir = | javascript | {
"resource": ""
} |
q42512 | train | function(options) {
options = langx.mixin({parse: true}, options);
var entity = this;
var success = options.success;
options.success = function(resp) {
var serverAttrs = options.parse ? entity.parse(resp, options) : resp;
if (!entity.set(serverAttrs, options)) return false; | javascript | {
"resource": ""
} | |
q42513 | train | function(entities, options) {
return this.set(entities, | javascript | {
"resource": ""
} | |
q42514 | train | function(entities, options) {
options = langx.mixin({}, options);
var singular = !langx.isArray(entities);
entities = singular ? [entities] : entities.slice();
var removed = this._removeEntitys(entities, options);
if (!options.silent && removed.length) {
| javascript | {
"resource": ""
} | |
q42515 | train | function(entities, options) {
options = options ? langx.clone(options) : {};
for (var i = 0; i < this.entities.length; i++) {
this._removeReference(this.entities[i], options);
| javascript | {
"resource": ""
} | |
q42516 | train | function(obj) {
if (obj == null) return void 0;
return this._byId[obj] ||
| javascript | {
"resource": ""
} | |
q42517 | train | function(entity, options) {
this._byId[entity.cid] = entity;
var id = this.entityId(entity.attributes);
if (id != | javascript | {
"resource": ""
} | |
q42518 | train | function(entity, options) {
delete this._byId[entity.cid];
var id = this.entityId(entity.attributes);
if (id != null) delete this._byId[id];
| javascript | {
"resource": ""
} | |
q42519 | train | function(event, entity, collection, options) {
if (entity) {
if ((event === 'add' || event === 'remove') && collection !== this) return;
if (event === 'destroy') this.remove(entity, options);
if (event === 'change') {
var prevId = this.entityId(entity.previousAttributes());
... | javascript | {
"resource": ""
} | |
q42520 | train | function (args) {
//console.log('PutModel messageContents: json ' + JSON.stringify(messageContents));
Model.call(this, args);
this.modelType = messageContents.modelType;
this.attributes = [];
var a, attrib, v;
for (a in messageContents.attributes) {
//console.log('PutModel Attribute: json... | javascript | {
"resource": ""
} | |
q42521 | containedInOrder | train | function containedInOrder(needle, haystack) {
var i, j = 0;
for (i = 0; i < needle.length; i++) {
while (j < | javascript | {
"resource": ""
} |
q42522 | PackageDependents | train | function PackageDependents(name, version, callback) {
if (typeof version === "function") {
callback = version
version = "latest"
}
GetDependents(name, function(err, packages) {
if (err) { return callback(err) }
SameTime(packages.map(function (c) {
return function ... | javascript | {
"resource": ""
} |
q42523 | train | function () {
if (!filterText) {
var filterTextSelector = $element.find('input');
if (filterTextSelector.length) {
filterText = filterTextSelector[0];
}
}
| javascript | {
"resource": ""
} | |
q42524 | newMarkov | train | function newMarkov() {
var options = {
maxLength: 140,
minWords: 10,
minScore: 20,
};
| javascript | {
"resource": ""
} |
q42525 | onReadable | train | function onReadable() {
if (self._assimilationState.waiting) | javascript | {
"resource": ""
} |
q42526 | train | function () {
if (req.status !== 200) {
console.warn(req.responseText);
return;
}
// Show the raw response text on page
xmlOutput.textContent = req.responseText;
// convert XML to javascript objects
| javascript | {
"resource": ""
} | |
q42527 | convertData | train | function convertData(objectBody, objectChange) {
const keysChange = Object.keys(objectChange);
let objectReturn = {};
keysChange.map(keyChange => {
let changeOption = objectChange[keyChange];
let valueKeyReturn = getValueChangeOption(objectBody, keyChange, changeOption, objectReturn);
| javascript | {
"resource": ""
} |
q42528 | cssToSss | train | function cssToSss (css, file) {
if (path.extname(file) === '.css') {
return postcss().process(css, { stringifier: sugarss }).then(function (result) {
| javascript | {
"resource": ""
} |
q42529 | generateCode | train | function generateCode (config, is_all_yes) {
console.log(colors.bold('--------------- Code Generator ---------------\n'));
// Check the configuration
if (!config.commands) {
throw new Error('commands undefined in your config.js');
}
// Start the processes
var entry_js = null, handler_js = null, package_json ... | javascript | {
"resource": ""
} |
q42530 | generateCodeEntryJs | train | function generateCodeEntryJs (config) {
// Read the entry point script
var entry_js = null;
try {
// Read from current script
entry_js = fs.readFileSync(ENTRY_POINT_FILENAME).toString();
| javascript | {
"resource": ""
} |
q42531 | generateCodeHandlerJs | train | function generateCodeHandlerJs (config) {
// Read the handler script
var handler_js = null;
try {
// Read from current script
handler_js = fs.readFileSync(HANDLER_FILENAME).toString();
} catch (e) {
// Read from template script
handler_js = fs.readFileSync(__dirname + '/../templates/' + HANDLER_FILENAME + ... | javascript | {
"resource": ""
} |
q42532 | generatePackageJson | train | function generatePackageJson (config) {
// Read the user's package.json
var user_file;
try {
// Read from current file
user_file = fs.readFileSync('./package.json').toString();
} catch (e) {
user_file = null;
}
// Parse the user's package.json
var user_json = null;
if (user_file) {
try {
user_json ... | javascript | {
"resource": ""
} |
q42533 | execDependencyInstall | train | function execDependencyInstall () {
console.log('\nExecuting npm install command...');
return new Promise(function(resolve, reject){
var child = require('child_process').spawn('npm', ['install'], {
cwd: process.cwd,
detached: false,
env: process.env,
stdio: [process.stdin, process.stdout, process.std... | javascript | {
"resource": ""
} |
q42534 | startCmdEditor | train | function startCmdEditor (config, is_skip_header) {
if (!is_skip_header) {
console.log(colors.bold('--------------- Command Editor ---------------'));
}
// Show a prompt for choose the mode
var promise = inquirer.prompt([{
type: 'list',
name: 'mode',
message: 'What you want to do ?',
choices: [
'Show ... | javascript | {
"resource": ""
} |
q42535 | showCommandsOnCmdEditor | train | function showCommandsOnCmdEditor (config) {
console.log(colors.bold('\nAvailable Commands for ' + config.deviceName + ':\n'));
// Iterate the each commands
var commands = config.commands || {};
if (Object.keys(commands).length == 0) {
console.log ('\nThere is no command.');
} else {
for (var name in commands... | javascript | {
"resource": ""
} |
q42536 | addCommandOnCmdEditor | train | function addCommandOnCmdEditor (config) {
var cmd_name = null;
var promise = inquirer.prompt([{
type: 'input',
name: 'cmdName',
message: 'What is name of a command (e.g. setMotorPower) ?',
validate: function (value) {
if (value.length == 0) return true;
if (config.commands[value] != null) return 'This... | javascript | {
"resource": ""
} |
q42537 | deleteCommandOnCmdEditor | train | function deleteCommandOnCmdEditor (config) {
var commands = config.commands || {};
var command_names = Object.keys(commands);
command_names.unshift('<< Cancel');
var promise = inquirer.prompt([{
type: 'list',
name: 'cmdName',
message: 'Choose the command you want to delete',
choices: command_names
}]);
... | javascript | {
"resource": ""
} |
q42538 | connect | train | function connect (master) {
if (_socket && _socket._master.name === master.name) {
debug(`already connected to master ${master.name}`)
return
}
if (_connectingMaster && _connectingMaster.name === master.name) {
debug(`already connecting to master ${master.name}`)
return
}
_c... | javascript | {
"resource": ""
} |
q42539 | disconnect | train | function disconnect () {
_connectingMaster = null
if (_socket) {
_socket.close()
_socket = null
debug('disconnected')
| javascript | {
"resource": ""
} |
q42540 | publish | train | function publish (channel, ...args) {
_publishStream.emit('message', | javascript | {
"resource": ""
} |
q42541 | Tributary | train | function Tributary( options ) {
options = options || {};
stream.Transform.call( this, { encoding: options.encoding } );
this.getStream = options.getStream || function( filename, cb ) {
return cb();
};
this._matcher = new Matcher(
options.placeholderStart || '<!-- include ',
... | javascript | {
"resource": ""
} |
q42542 | MysqlTransit | train | function MysqlTransit(dbOriginal, dbTemp, connectionParameters) {
this.dbOriginal = dbOriginal;
this.dbTemp = dbTemp;
this.connectionParameters = connectionParameters;
this.queryQueue = | javascript | {
"resource": ""
} |
q42543 | joint | train | function joint(streams) {
if (!(streams instanceof Array)) {
streams = Array.prototype.slice.call(arguments);
| javascript | {
"resource": ""
} |
q42544 | createNamedClass | train | function createNamedClass (name, klass, baseKlass, superFunc) {
if (!superFunc) {
superFunc = function () {
baseKlass.call(this);
};
}
return new Function(
'klass', 'superFunc',
'return function ' + | javascript | {
"resource": ""
} |
q42545 | afterExtends | train | function afterExtends (klass, baseKlass, superFunc) {
var newKlass = createNamedClass(klass.name, klass, baseKlass, superFunc);
newKlass.prototype = | javascript | {
"resource": ""
} |
q42546 | processMethodOutTag | train | function processMethodOutTag(tag, typeMarkdown) {
var md = "";
if (tag.type) {
| javascript | {
"resource": ""
} |
q42547 | encode | train | function encode(batch, id, ver) {
//producerId min 2 digits
let producerId = b36.int2Str36(batch.producerId).padStart(2, '0');
//producerId min 3 digits
let batchId = b36.int2Str36(batch.id).padStart(3, '0');
| javascript | {
"resource": ""
} |
q42548 | build | train | function build(writable, options) {
return writable | javascript | {
"resource": ""
} |
q42549 | loadAndParseFile | train | function loadAndParseFile(filename, settings) {
Augmented.ajax({
url: filename,
async: true,
cache: settings.cache,
contentType: 'text/plain;charset=' + settings.encoding,
dataType: 'text',
success: function (data, status) {
| javascript | {
"resource": ""
} |
q42550 | train | function(array) {
var sarr = [];
var i = 0;
for (i=0; i<array.length;i++) {
var a = array[i];
var o = {};
o.name = a.name;
o.value = a.value;
o.type = a.type;
... | javascript | {
"resource": ""
} | |
q42551 | success | train | function success(domain){
if(auth0){
//if auth0 then we don't have user storage
connection.user = new DomainWrapper(domain);
connection.user.join();
| javascript | {
"resource": ""
} |
q42552 | applyModelMethods | train | function applyModelMethods (model, definition) {
for (var i in definition.methods) {
if (i === 'definition') {
throw new Error('Invalid model definition | javascript | {
"resource": ""
} |
q42553 | train | function(patterns, options) {
var self = this;
if (!(typeof patterns=='object')){throw new Error('ObsRouter constructor expects patterns object as first argument')}
options = options || {};
EventEmitter.call(self);
if (process.browser){
//bind to window by default
self._bindToWindow = 'bindToWindow' in ... | javascript | {
"resource": ""
} | |
q42554 | train | function(object, options) {
var self = this;
return deep.when(getSchema(this))
.done(function(schema) {
| javascript | {
"resource": ""
} | |
q42555 | handleConnectionCallback | train | function handleConnectionCallback(err, resolve, reject, key, connection) {
debug('handleConnectionCallback','start');
//error, remove cached entry, reject the promise
if (err) {
debug('handleConnectionCallback','error',err);
delete promises[key];
return reject(err);
}
//patch close method for ca... | javascript | {
"resource": ""
} |
q42556 | load | train | function load(mod) {
if (typeof(mod.factory) === "function") {
return require(mod.deps, | javascript | {
"resource": ""
} |
q42557 | handle | train | function handle(filePath) {
var file = toVFile(filePath)
var result = test(file)
if (mask(result, INCLUDE)) {
if (one) {
callback(null, file)
return true
}
results.push(file) | javascript | {
"resource": ""
} |
q42558 | once | train | function once(child) {
if (handle(current) === true) {
return
}
readdir(current, onread)
function onread(error, entries) {
var length = entries ? entries.length : 0
var index = -1
var entry
if (error) {
entries = []
}
while (++index < length) {
... | javascript | {
"resource": ""
} |
q42559 | generateTransactionRequest | train | function generateTransactionRequest(signer, transaction, options) {
let iou = {
amt: transaction.amount,
cur: transaction.currency,
| javascript | {
"resource": ""
} |
q42560 | registerWalletAddress | train | function registerWalletAddress(url, body, options) {
options = options || {};
url = resolveURL(url, '/address');
return new P(function (resolve, reject) {
request({
url: url,
method: options.method || 'POST',
body: body,
json: true, | javascript | {
"resource": ""
} |
q42561 | checkAddressBalance | train | function checkAddressBalance(url, address, options) {
options = options || {};
let path = '/address/.../balance'.replace('...', address);
url = resolveURL(url, path);
return new P(function (resolve, reject) {
request({
url: url,
method: 'GET',
| javascript | {
"resource": ""
} |
q42562 | generateKeyPair | train | function generateKeyPair(scheme) {
let keypair;
let keys;
switch (scheme) {
case 'ed25519':
case 'secp256k1':
keypair = schemes[scheme].genKeyPair();
keys = {
scheme: scheme,
private: keypair.getPrivate('hex'),
| javascript | {
"resource": ""
} |
q42563 | deriveWalletAddress | train | function deriveWalletAddress(publicKey, type) {
let keyBuffer = new Buffer(publicKey, 'hex');
let firstHash = crypto.createHash('sha256').update(keyBuffer).digest();
let secondHash = ripemd160(firstHash);
let extendedHash = (type === 'issuer' ? '57' : '87') | javascript | {
"resource": ""
} |
q42564 | createAddressRegistrationStatement | train | function createAddressRegistrationStatement(address, keys, options) {
options = options || {};
/* Create an extended JSON Web Signatures object */
let jws = {
hash: {
type: (hashes.indexOf(options.hash) > -1) ? options.hash : 'sha256',
value: ''
},
payload: {
address: address,
... | javascript | {
"resource": ""
} |
q42565 | resolveURL | train | function resolveURL(url, path) {
if (typeof url !== 'string' || typeof path !== 'string') {
return new Error('url-and-path-required');
}
/* Remove leading and duplicate slashes */
url = url.replace(/\/{2,}/g, '/').replace(/^\//, '').replace(':/','://');
let parsedUrl = urlModule.parse(url); | javascript | {
"resource": ""
} |
q42566 | merge | train | function merge(target, source) {
if (source === null) {
return target
}
var props = Object.getOwnPropertyNames(target)
props.forEach(function (name) {
var s = gettype(source[name])
if (s !== 'undefined') {
var t = gettype(target[name])
if (t !== s) {
... | javascript | {
"resource": ""
} |
q42567 | findIndexInArray | train | function findIndexInArray(array, callback) {
var _length = array.length;
for (var i = 0; i < _length; i++) {
| javascript | {
"resource": ""
} |
q42568 | replaceInArray | train | function replaceInArray(array, indexToReplace, indexToInsert) {
var _removedArray = array.splice(indexToReplace, 1);
| javascript | {
"resource": ""
} |
q42569 | getArrayOfPartials | train | function getArrayOfPartials() {
var _partialsArr = [];
for (var file in mainPartialList) {
| javascript | {
"resource": ""
} |
q42570 | parseFile | train | function parseFile(importKeyword, requiresKeyword, filePath) {
var _lines = grunt.file.read(filePath).split(NEW_LINE),
_values = {
imports: {},
requires: {}
};
// Search for keywords in file
for (var i = _lines.length - 1; i >= 0; i--) {
... | javascript | {
"resource": ""
} |
q42571 | orderByDependency | train | function orderByDependency(partialsArray) {
var _doPass = true,
_reqCache = {};
// repeat sorting operation until
// there is no replacing procedure during
// one pass (bubble sorting).
while (_doPass) {
_doPass = false;
// Iterate throu... | javascript | {
"resource": ""
} |
q42572 | generateBootstrapContent | train | function generateBootstrapContent(partialsArray, lineDelimiter) {
var _bootstrapContent = '',
_folderGroup = '';
partialsArray.forEach(function (partialName) {
var _sassPath = mainPartialList[partialName].removedRoot,
_currentRoot = _sassPath.parseRootFo... | javascript | {
"resource": ""
} |
q42573 | StartableModel | train | function StartableModel(model,instance) {
if(!model) {
throw new Error('model is required')
}
if(!instance) {
throw new Error('instance is required')
}
if(!(this instanceof StartableModel)) {
return new StartableModel(model,instance,index)
}
this.model = model
thi... | javascript | {
"resource": ""
} |
q42574 | fail | train | function fail(err, status=1) {
console.log(process.env.DEBUG | javascript | {
"resource": ""
} |
q42575 | autoSpliceLaunchArray | train | function autoSpliceLaunchArray(LaunchArray, TypeKey){
var indFirstElement = currentPromiseArrays[TypeKey].indexOf(LaunchArray[0]);
var indLastElement = currentPromiseArrays[TypeKey].indexOf(LaunchArray[LaunchArray.length-1]);
Promise.all(LaunchArray.map(e => {return e.result})).then(() => {
| javascript | {
"resource": ""
} |
q42576 | train | function(inParams, inCallbackFunctionName) {
if (enyo.isString(inParams)) {
return inParams.replace("=?", "=" + inCallbackFunctionName);
| javascript | {
"resource": ""
} | |
q42577 | stupidDirsExist | train | function stupidDirsExist(dirs) {
const check = [];
dirs.forEach((dir) => {
check.push(dirExist(dir));
});
return Promise.all(check).then((results) => | javascript | {
"resource": ""
} |
q42578 | dirsExist | train | function dirsExist(dirs) {
if (0 === dirs.length) {
return new Promise((resolve) => {
resolve({});
});
}
// Group dirs by '/' count
const dirsByDepth = dirs.reduce(function(prev, curItem) {
const depth = curItem.split(path.sep).length;
(prev[depth] = prev[depth] || []).push(curItem);
... | javascript | {
"resource": ""
} |
q42579 | parseASCIIChunk | train | function parseASCIIChunk(workChunk) {
var data = (0, _utils.ensureString)(workChunk);
// console.log('parseASCII')
var result = void 0,
text = void 0;
var patternNormal = /normal[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE]... | javascript | {
"resource": ""
} |
q42580 | train | function (value) {
var res;
if (this.has(value)) {
res = this.items.splice(
| javascript | {
"resource": ""
} | |
q42581 | train | function (callback) {
for (var i = 0, l = this.items.length; i < l; i++) {
| javascript | {
"resource": ""
} | |
q42582 | argv | train | function argv(k) {
if (!nargv) {
nargv = process.argv.slice(0, 2);
}
var v = '', m = null;
var x = new RegExp(k + regexKeyVal.source);
nargv.every(function(e) {
| javascript | {
"resource": ""
} |
q42583 | clone | train | function clone(c, wl, bl) {
var cl = {}, cp, t;
for (var keys = Object.keys(c), l = 0; l < keys.length; l++) {
cp = c[keys[l]];
if (bl && bl.indexOf(cp) >= 0) {
continue;
}
if (Array.isArray(cp)) {
cl[keys[l]] = cp.slice(0);
} else if ((t = typeof cp) === 'function') {
if (!wl || wl.indexOf(cp) >= ... | javascript | {
"resource": ""
} |
q42584 | pkgPropUpd | train | function pkgPropUpd(pd, u, n, r) {
var v = null;
if (u && pd.oldVer !== self.version && self.version) {
v = self.version;
} else if (n && pd.oldVer !== self.next.version && self.next.version) {
v = self.next.version;
} else if (r && self.prev.version) {
v = self.prev.version;
}
pd.version ... | javascript | {
"resource": ""
} |
q42585 | vmtchs | train | function vmtchs(start, end, skips) {
var s = '';
for (var i = start; i <= end; i++) | javascript | {
"resource": ""
} |
q42586 | buildHelpContents | train | function buildHelpContents() {
var pageTpl = '<div class="cke_accessibility_legend" role="document" aria-labelledby="' + id + '_arialbl" tabIndex="-1">%1</div>' +
'<span id="' + id + '_arialbl" class="cke_voice_label">' + lang.contents + ' </span>',
sectionTpl = '<h1>%1</h1><dl>%2</dl>',
itemTpl = '<dt>... | javascript | {
"resource": ""
} |
q42587 | getArguments | train | function getArguments(f, amended)
{
var functionCode = f.toString();
if(amended){
//This is a fix for when we are passed anonymous functions (which are passed to us as unassigned)
//ex: "function (a, b, c) { }"
//These are actually parse errors so we'll try adding an assignment to fix the parse error
... | javascript | {
"resource": ""
} |
q42588 | runChromedriver | train | function runChromedriver(location, remote, options) {
assert(remote === 'chromedriver', 'expected remote to be chromedriver');
if (!options.chromedriverStarted) {
chromedriver.start();
}
var throttle = options.throttle || function (fn) { return fn(); };
return throttle(function () {
return runSingleBr... | javascript | {
"resource": ""
} |
q42589 | pad | train | function pad (n, width, z) {
if (typeof n !== 'string') throw new Error('bitString#pad: Need String');
z = z || '0'; | javascript | {
"resource": ""
} |
q42590 | checksum | train | function checksum (bits, size) {
if (bits == null || !isValid(bits)) throw new Error('bitString#checksum: Need valid bits');
if (size == null || size % 2 !== 0) throw new Error('bitString#checksum: size needs to be even');
var sumA = 0,
sumB = 0,
i;
for (i = 0; i | javascript | {
"resource": ""
} |
q42591 | randomBits | train | function randomBits (n) {
if (typeof n !== 'number') throw new Error('bitString#randomBits: Need number');
var buf = _randomBytes(Math.ceil(n/8)),
bits = '';
for (var i = 0; | javascript | {
"resource": ""
} |
q42592 | createFormatChangelog | train | function createFormatChangelog(inPath) {
if (!inPath) {
throw new Error('Input path argument is required');
}
return function formatChangelog() {
return gulp.src(inPath)
// Replace all version compare links.
.pipe(replace(/\(http.*\) /g, ' '))
| javascript | {
"resource": ""
} |
q42593 | train | function(parts) {
var urls = [];
var start = '';
// If the first part is empty
// the original path begins with a slash so we
// do that, too
if( _.isEmpty(parts[0]) ) {
start = '/';
urls[0] | javascript | {
"resource": ""
} | |
q42594 | train | function(urls, skipMissing) {
var i = -1;
var j;
var handlers = [];
var url;
var resource;
var urlsLength = urls.length;
var resourcesLength = this._resources.length;
var foundHandler;
// All URLs
while( ++i < urlsLength ) {
u... | javascript | {
"resource": ""
} | |
q42595 | train | function(resource) {
var handler = resource.handler.getCallback(request.method);
request.api.handler = handler;
request.path = resource.path;
var context = resource.handler.getContext();
context.__espressojs = {
chainIsComplete: chainIsComplete,
| javascript | {
"resource": ""
} | |
q42596 | setup | train | function setup (request, options, ...args) {
const len = request.headers['content-length']
const encoding = request.headers['content-encoding'] || 'identity'
return Object.assign({}, options, {
encoding: options.encoding || 'utf-8',
| javascript | {
"resource": ""
} |
q42597 | getRecaptchaResponse | train | function getRecaptchaResponse(field, req) {
return req.get(field) | javascript | {
"resource": ""
} |
q42598 | resolveAsync | train | function resolveAsync(p, base, root) {
if (!path.isAbsolute(p)) {
return new Promise(function(r, j) {
resolve(forceRelative(p), {
basedir: path.resolve(root, base)
}, function(err, res) {
if (err) {
| javascript | {
"resource": ""
} |
q42599 | object | train | function object(pairs) {
let obj = {};
for (let i = 0;i<pairs.length;++i) {
| javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.