_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q8300
fixMissing
train
function fixMissing (obj, defaults) { Object.keys(defaults).forEach(function (key) { obj[key] = obj[key] || defaults[key]; }); }
javascript
{ "resource": "" }
q8301
repoIsClean
train
function repoIsClean (done) { proc.exec('git status -z', function (err, stdout) { if (!err) { var msg = stdout.toString().trim(); if (msg && msg.length) { err = new Error('Please commit all changes generated by building'); } } done(err); }); }
javascript
{ "resource": "" }
q8302
Address
train
function Address(options) { if (!(this instanceof Address)) return new Address(options); this.hash = encoding.ZERO_HASH160; this.type = Address.types.PUBKEYHASH; this.version = -1; this.network = Network.primary; if (options) this.fromOptions(options); }
javascript
{ "resource": "" }
q8303
AbstractBlock
train
function AbstractBlock() { if (!(this instanceof AbstractBlock)) return new AbstractBlock(); this.version = 1; this.prevBlock = encoding.NULL_HASH; this.merkleRoot = encoding.NULL_HASH; this.time = 0; this.bits = 0; this.nonce = 0; this.mutable = false; this._hash = null; this._hhash = null; ...
javascript
{ "resource": "" }
q8304
SPVNode
train
function SPVNode(options) { if (!(this instanceof SPVNode)) return new SPVNode(options); Node.call(this, options); // SPV flag. this.spv = true; this.chain = new Chain({ network: this.network, logger: this.logger, db: this.config.str('db'), prefix: this.config.prefix, maxFiles: this...
javascript
{ "resource": "" }
q8305
craftingSteps
train
function craftingSteps (tree, steps = [], index = 0) { // Skip any tree parts where nothing needs to be crafted if (!tree.components || tree.craft === false) { return steps } // Go through the existing steps, and if we already have a step // with this id, just add up the quantities let stepIndex = step...
javascript
{ "resource": "" }
q8306
getAllRemotesUrls
train
function getAllRemotesUrls (getGitInfo) { const remotes = lget(getGitInfo, 'remote', {}); return Object.keys(remotes).map(key => lget(remotes[key],'url')); }
javascript
{ "resource": "" }
q8307
getUrl
train
function getUrl(remoteName){ const gitInfo = getGitInfo(); return remoteName ? getRepoRemoteUrl(gitInfo, remoteName) : getAllRemotesUrls(gitInfo); }
javascript
{ "resource": "" }
q8308
TwilioConnector
train
function TwilioConnector(settings) { assert(typeof settings === 'object', 'cannot initialize TwilioConnector without a settings object'); var connector = this; var accountSid = this.accountSid = settings.accountSid; var authToken = this.authToken = settings.authToken; var sgAPIKey = this.sgAPIKey ...
javascript
{ "resource": "" }
q8309
MasterKey
train
function MasterKey(options) { if (!(this instanceof MasterKey)) return new MasterKey(options); this.encrypted = false; this.iv = null; this.ciphertext = null; this.key = null; this.mnemonic = null; this.alg = MasterKey.alg.PBKDF2; this.N = 50000; this.r = 0; this.p = 0; this.aesKey = null; ...
javascript
{ "resource": "" }
q8310
BIP151Stream
train
function BIP151Stream(cipher) { if (!(this instanceof BIP151Stream)) return new BIP151Stream(cipher); this.cipher = BIP151.ciphers.CHACHAPOLY; this.privateKey = secp256k1.generatePrivateKey(); this.publicKey = null; this.k1 = null; this.k2 = null; this.sid = null; if (cipher != null) { assert(...
javascript
{ "resource": "" }
q8311
BIP151
train
function BIP151(cipher) { if (!(this instanceof BIP151)) return new BIP151(cipher); EventEmitter.call(this); this.input = new BIP151Stream(cipher); this.output = new BIP151Stream(cipher); this.initReceived = false; this.ackReceived = false; this.initSent = false; this.ackSent = false; this.comp...
javascript
{ "resource": "" }
q8312
SOCKS
train
function SOCKS() { if (!(this instanceof SOCKS)) return new SOCKS(); EventEmitter.call(this); this.socket = new net.Socket(); this.state = SOCKS.states.INIT; this.target = SOCKS.states.INIT; this.destHost = '0.0.0.0'; this.destPort = 0; this.username = ''; this.password = ''; this.name = 'loca...
javascript
{ "resource": "" }
q8313
ConfirmStats
train
function ConfirmStats(type, logger) { if (!(this instanceof ConfirmStats)) return new ConfirmStats(type, logger); this.logger = Logger.global; this.type = type; this.decay = 0; this.maxConfirms = 0; this.buckets = new Float64Array(0); this.bucketMap = new DoubleMap(); this.confAvg = []; this.c...
javascript
{ "resource": "" }
q8314
PolicyEstimator
train
function PolicyEstimator(logger) { if (!(this instanceof PolicyEstimator)) return new PolicyEstimator(logger); this.logger = Logger.global; this.minTrackedFee = MIN_FEERATE; this.minTrackedPri = MIN_PRIORITY; this.feeStats = new ConfirmStats('FeeRate'); this.priStats = new ConfirmStats('Priority'); ...
javascript
{ "resource": "" }
q8315
popupNWLogin
train
function popupNWLogin(params) { var url = core.REDIRECT_URL + 'oauth2/authorize?' + util.param(params); var win = nwGUI.Window.open(url, { title: 'Login with TwitchTV', width: WIDTH, height: HEIGHT, toolbar: false, show: false, resizable: true }); win.on('loaded', function() { var w...
javascript
{ "resource": "" }
q8316
popupNW13Login
train
function popupNW13Login(params) { var url = core.REDIRECT_URL + 'oauth2/authorize?' + util.param(params); nw.Window.open(url, { title: 'Login with TwitchTV', width: WIDTH, height: HEIGHT, id: 'login', resizable: true }, function(login) { login.on('loaded', function() { var w = this.win...
javascript
{ "resource": "" }
q8317
popupElectronLogin
train
function popupElectronLogin(params) { if ( require('electron').remote ) BrowserWindow = require('electron').remote.BrowserWindow; else BrowserWindow = require('electron').BrowserWindow; var url = core.REDIRECT_URL + 'oauth2/authorize?' + util.param(params); var win = new BrowserWindow({ width: WIDTH, heig...
javascript
{ "resource": "" }
q8318
setGUIType
train
function setGUIType(name, nwg) { gui_type = name; if ( gui_type == 'nw' ) { if ( nwg ) nwGUI = nwg; else throw new Error('Did not get nw.gui object with GUI type "nw"'); } }
javascript
{ "resource": "" }
q8319
popupLogin
train
function popupLogin(params) { switch(gui_type) { case 'nw': popupNWLogin(params); break; case 'nw13': popupNW13Login(params); break; case 'electron': popupElectronLogin(params); break; default: throw new Error('The Twitch SDK was not initialized with any ' + 'compatible ...
javascript
{ "resource": "" }
q8320
exec
train
function exec(gen) { return new Promise((resolve, reject) => { const step = (value, rejection) => { let next; try { if (rejection) next = gen.throw(value); else next = gen.next(value); } catch (e) { reject(e); return; } if (next.d...
javascript
{ "resource": "" }
q8321
promisify
train
function promisify(func) { return function(...args) { return new Promise((resolve, reject) => { args.push(wrap(resolve, reject)); func.call(this, ...args); }); }; }
javascript
{ "resource": "" }
q8322
callbackify
train
function callbackify(func) { return function(...args) { if (args.length === 0 || typeof args[args.length - 1] !== 'function') { throw new Error(`${func.name || 'Function'} requires a callback.`); } const callback = args.pop(); func.call(this, ...args).then((value) => { setImmedia...
javascript
{ "resource": "" }
q8323
every
train
async function every(jobs) { const result = await Promise.all(jobs); for (const item of result) { if (!item) return false; } return true; }
javascript
{ "resource": "" }
q8324
startInterval
train
function startInterval(func, time, self) { const ctx = { timer: null, stopped: false }; const cb = async () => { assert(ctx.timer != null); ctx.timer = null; try { await func.call(self); } finally { if (!ctx.stopped) ctx.timer = setTimeout(cb, time); } }; ctx...
javascript
{ "resource": "" }
q8325
stopInterval
train
function stopInterval(ctx) { assert(ctx); if (ctx.timer != null) { clearTimeout(ctx.timer); ctx.timer = null; } ctx.stopped = true; }
javascript
{ "resource": "" }
q8326
startTimeout
train
function startTimeout(func, time, self) { return { timer: setTimeout(func.bind(self), time), stopped: false }; }
javascript
{ "resource": "" }
q8327
stopTimeout
train
function stopTimeout(ctx) { assert(ctx); if (ctx.timer != null) { clearTimeout(ctx.timer); ctx.timer = null; } ctx.stopped = true; }
javascript
{ "resource": "" }
q8328
BigPipe
train
function BigPipe(options) { if (!(this instanceof BigPipe)) return new BigPipe(options); options = options || {}; this.expected = +options.pagelets || 0; // Pagelets that this page requires. this.allowed = +options.pagelets || 0; // Pagelets that are allowed for this page. this.maximum = options.limit || 2...
javascript
{ "resource": "" }
q8329
setDeep
train
function setDeep(map, listKey, keyPath, value) { if (!Array.isArray(listKey)) { listKey = [listKey]; } var change = typeof value === 'function' ? 'updateIn' : 'setIn'; var subPaths = getPaths(map, listKey, keyPath); return map.withMutations(function (map) { subPaths.forEach(function (keyPath) { ...
javascript
{ "resource": "" }
q8330
Node
train
function Node(options) { if (!(this instanceof Node)) return new Node(options); AsyncObject.call(this); this.config = new Config('wmcc'); this.config.inject(options); this.config.load(options); if (options.config) this.config.open('wmcc.conf'); this.network = Network.get(this.config.network); ...
javascript
{ "resource": "" }
q8331
train
function (format) { return function (card) { card = getCode(card); if (!card) return undefined; card--; return format({rank: card >> 2, suit: card & 3}); }; }
javascript
{ "resource": "" }
q8332
train
function (format) { var res = _.range(1, deckSize + 1); var buffer = crypto.randomBytes(deckSize << 2); for (var pos = res.length - 1; pos > 0; pos--) { var rand = buffer.readUInt32LE(pos << 2) % (pos + 1); var temp = res[pos]; res[pos] = res[rand]; res[rand] = temp; }; return format ? _.map(res, ...
javascript
{ "resource": "" }
q8333
train
function (cards) { var res = deckSize + 1; for (var c = 0; c < cards.length; c++) res = evaluator[res + getCode(cards[c])]; if (cards.length < 7) res = evaluator[res]; return {name: hands[res >> 12], value: res}; }
javascript
{ "resource": "" }
q8334
train
function () { var freq = new Int32Array(hands.length); var start = Date.now(); for (var c1 = 1; c1 <= deckSize; c1++) { var r1 = evaluator[deckSize + c1 + 1]; for (var c2 = c1 + 1; c2 <= deckSize; c2++) { var r2 = evaluator[r1 + c2]; for (var c3 = c2 + 1; c3 <= deckSize; c3++) { var r3 = evalua...
javascript
{ "resource": "" }
q8335
treeAdjustQuantity
train
function treeAdjustQuantity (amount, tree, availableItems, ignoreAvailable = false, nesting = 0) { tree = {...tree} tree.output = tree.output || 1 // Calculate the total quantity needed let treeQuantity = amount * tree.quantity // Round amount to nearest multiple of the tree output treeQuantity = Math.cei...
javascript
{ "resource": "" }
q8336
request
train
function request(options) { if (typeof options === 'string') options = { uri: options }; options.buffer = true; return new Promise((resolve, reject) => { const req = new Request(options); req.on('error', err => reject(err)); req.on('end', () => resolve(req)); req.start(); req.end(); ...
javascript
{ "resource": "" }
q8337
fileExistsSync
train
function fileExistsSync(path) { try { fs.accessSync(path, fs.F_OK); } catch (e) { return false; } return true; }
javascript
{ "resource": "" }
q8338
traverseLeaf
train
function traverseLeaf(next, requireString, requireIndex) { var reqPath , reqDeps ; if ('.' === requireString[0]) { reqPath = url.resolve('/' + leaf.modulepath, requireString).substr(1); // strip leading '/' } else { // TODO handle absolute paths ...
javascript
{ "resource": "" }
q8339
MempoolEntry
train
function MempoolEntry(options) { if (!(this instanceof MempoolEntry)) return new MempoolEntry(options); this.tx = null; this.height = -1; this.size = 0; this.sigops = 0; this.priority = 0; this.fee = 0; this.deltaFee = 0; this.time = 0; this.value = 0; this.coinbase = false; this.dependenci...
javascript
{ "resource": "" }
q8340
mapByDepth
train
function mapByDepth(rootPackage) { var depth = 0 , allDeps = {} , superDepsList = {} ; function traverseDeps(childPackage) { depth += 1; childPackage.dependencyTree = childPackage.dependencyTree || {}; Object.keys(childPackage.dependencyTree).forEach(function (depName) { ...
javascript
{ "resource": "" }
q8341
init
train
function init() { // initialize the SDK with the domain where Just is running and the // OAuth 2.0 implicit flow parameters sdk = new window.JustSDK({ domain: 'JUSTDOMAIN', oauth2: { // adapt this to point to the correct domain and path red...
javascript
{ "resource": "" }
q8342
MemDB
train
function MemDB(location) { if (!(this instanceof MemDB)) return new MemDB(location); this.location = location || 'memory'; this.options = {}; this.tree = new RBT(cmp, true); }
javascript
{ "resource": "" }
q8343
Input
train
function Input(options) { if (!(this instanceof Input)) return new Input(options); this.prevout = new Outpoint(); this.script = new Script(); this.sequence = 0xffffffff; this.witness = new Witness(); if (options) this.fromOptions(options); }
javascript
{ "resource": "" }
q8344
TimeData
train
function TimeData(limit) { if (!(this instanceof TimeData)) return new TimeData(limit); EventEmitter.call(this); if (limit == null) limit = 200; this.samples = []; this.known = new Map(); this.limit = limit; this.offset = 0; this.checked = false; this.ntp = new NTP(); }
javascript
{ "resource": "" }
q8345
Headers
train
function Headers(options) { if (!(this instanceof Headers)) return new Headers(options); AbstractBlock.call(this); if (options) this.parseOptions(options); }
javascript
{ "resource": "" }
q8346
NodeClient
train
function NodeClient(node) { if (!(this instanceof NodeClient)) return new NodeClient(node); AsyncObject.call(this); this.node = node; this.network = node.network; this.filter = null; this.listen = false; this._init(); }
javascript
{ "resource": "" }
q8347
PaymentDetails
train
function PaymentDetails(options) { if (!(this instanceof PaymentDetails)) return new PaymentDetails(options); this.network = null; this.outputs = []; this.time = util.now(); this.expires = -1; this.memo = null; this.paymentUrl = null; this.merchantData = null; if (options) this.fromOptions(o...
javascript
{ "resource": "" }
q8348
compressScript
train
function compressScript(script, bw) { // Attempt to compress the output scripts. // We can _only_ ever compress them if // they are serialized as minimaldata, as // we need to recreate them when we read // them. // P2PKH -> 0 | key-hash // Saves 5 bytes. const pkh = script.getPubkeyhash(true); if (pk...
javascript
{ "resource": "" }
q8349
sizeScript
train
function sizeScript(script) { if (script.isPubkeyhash(true)) return 21; if (script.isScripthash()) return 21; const pk = script.getPubkey(true); if (pk) { if (publicKeyVerify(pk)) return 33; } let size = 0; size += encoding.sizeVarint(script.raw.length + COMPRESS_TYPES); size += scr...
javascript
{ "resource": "" }
q8350
compressOutput
train
function compressOutput(output, bw) { bw.writeVarint(output.value); compressScript(output.script, bw); return bw; }
javascript
{ "resource": "" }
q8351
sizeOutput
train
function sizeOutput(output) { let size = 0; size += encoding.sizeVarint(output.value); size += sizeScript(output.script); return size; }
javascript
{ "resource": "" }
q8352
compressValue
train
function compressValue(value) { if (value === 0) return 0; let exp = 0; while (value % 10 === 0 && exp < 9) { value /= 10; exp++; } if (exp < 9) { const last = value % 10; value = (value - last) / 10; return 1 + 10 * (9 * value + last - 1) + exp; } return 10 + 10 * (value - 1); ...
javascript
{ "resource": "" }
q8353
decompressValue
train
function decompressValue(value) { if (value === 0) return 0; value--; let exp = value % 10; value = (value - exp) / 10; let n; if (exp < 9) { const last = value % 9; value = (value - last) / 9; n = value * 10 + last + 1; } else { n = value + 1; } while (exp > 0) { n *= 10;...
javascript
{ "resource": "" }
q8354
compressKey
train
function compressKey(key) { let out; switch (key[0]) { case 0x02: case 0x03: // Key is already compressed. out = key; break; case 0x04: // Compress the key normally. out = secp256k1.publicKeyConvert(key, true); // Store the oddness. // Pseudo-hybrid format. ...
javascript
{ "resource": "" }
q8355
decompressKey
train
function decompressKey(key) { const format = key[0]; assert(key.length === 33); switch (format) { case 0x02: case 0x03: return key; case 0x04: key[0] = 0x02; break; case 0x05: key[0] = 0x03; break; default: throw new Error('Bad point format.'); } // D...
javascript
{ "resource": "" }
q8356
Parser
train
function Parser(network) { if (!(this instanceof Parser)) return new Parser(network); EventEmitter.call(this); this.network = Network.get(network); this.pending = []; this.total = 0; this.waiting = 24; this.header = null; }
javascript
{ "resource": "" }
q8357
LowlevelUp
train
function LowlevelUp(backend, location, options) { if (!(this instanceof LowlevelUp)) return new LowlevelUp(backend, location, options); assert(typeof backend === 'function', 'Backend is required.'); assert(typeof location === 'string', 'Filename is required.'); this.options = new LLUOptions(options); th...
javascript
{ "resource": "" }
q8358
MTX
train
function MTX(options) { if (!(this instanceof MTX)) return new MTX(options); TX.call(this); this.mutable = true; this.changeIndex = -1; this.view = new CoinView(); if (options) this.fromOptions(options); }
javascript
{ "resource": "" }
q8359
FundingError
train
function FundingError(msg, available, required) { Error.call(this); this.type = 'FundingError'; this.message = msg; this.availableFunds = -1; this.requiredFunds = -1; if (available != null) { this.message += ` (available=${Amount.wmcc(available)},`; this.message += ` required=${Amount.wmcc(require...
javascript
{ "resource": "" }
q8360
WorkerPool
train
function WorkerPool(options) { if (!(this instanceof WorkerPool)) return new WorkerPool(options); EventEmitter.call(this); this.enabled = false; this.size = getCores(); this.timeout = 120000; this.file = process.env.WMCC_WORKER_FILE || 'worker.js'; this.children = new Map(); this.uid = 0; this...
javascript
{ "resource": "" }
q8361
Worker
train
function Worker(file) { if (!(this instanceof Worker)) return new Worker(file); EventEmitter.call(this); this.id = -1; this.framer = new Framer(); this.parser = new Parser(); this.pending = new Map(); this.child = new Child(file); this.init(); }
javascript
{ "resource": "" }
q8362
invokeConfigFn
train
function invokeConfigFn(tasks) { for (var taskName in tasks) { if (tasks.hasOwnProperty(taskName)) { tasks[taskName](gulp, plugins, growl, path); } } }
javascript
{ "resource": "" }
q8363
create
train
function create(name, parent, defmessage, abstract, construct) { if (typeof name === "object") { return create(name.name, name.parent, name.defmessage, name.abstract, name.construct); } parent = parent || global.Error; if ((defmessage === null) || (defmessage === undefined)) { if (parent...
javascript
{ "resource": "" }
q8364
parent
train
function parent() { var ce = this.constructor.ce; if (ce && ce.parent) { ce = ce.parent.ce; if (ce && (typeof ce.construct === "function")) { ce.construct.apply(this, arguments); } } }
javascript
{ "resource": "" }
q8365
inherit
train
function inherit(name, defmessage, abstract, construct) { if (typeof name === "object") { name.parent = this; return create(name); } return create(name, this, defmessage, abstract, construct); }
javascript
{ "resource": "" }
q8366
Block
train
function Block(errors, namespace, base, lazy) { if ((base === undefined) || (base === true) || (base === null)) { base = "Base"; } else if (base === false) { base = Error; } else if (typeof base !== "function") { base = "" + base; } this.p = { errors: errors, ...
javascript
{ "resource": "" }
q8367
Output
train
function Output(options) { if (!(this instanceof Output)) return new Output(options); this.value = 0; this.script = new Script(); if (options) this.fromOptions(options); }
javascript
{ "resource": "" }
q8368
RPCClient
train
function RPCClient(options) { if (!(this instanceof RPCClient)) return new RPCClient(options); if (!options) options = {}; if (typeof options === 'string') options = { uri: options }; this.options = options; this.network = Network.get(options.network); this.uri = options.uri || `http://local...
javascript
{ "resource": "" }
q8369
train
function (dptid) { var baseId = null; var subId = null; // Parse the dpt id // If it is a raw number if (typeof dptid === 'number' && isFinite(dptid)) { // we're passed in a raw number (9) baseId = dptid; // If it is a string } else if...
javascript
{ "resource": "" }
q8370
api
train
function api(options, callback) { if (!session) { throw new Error('You must call init() before api()'); } var version = options.version || 'v3'; var params = options.params || {}; callback = callback || function() {}; var authenticated = !!session.token, url = REDIRECT_PATH + (options.url || opti...
javascript
{ "resource": "" }
q8371
train
function(apiClient) { this.apiClient = apiClient || ApiClient.instance; /** * Callback function to receive the result of the confirmUser operation. * @callback module:api/RegistrationsApi~confirmUserCallback * @param {String} error Error message, if any. * @param module:model/DeviceRegConf...
javascript
{ "resource": "" }
q8372
Lock
train
function Lock(named) { if (!(this instanceof Lock)) return Lock.create(named); this.named = named === true; this.jobs = []; this.busy = false; this.destroyed = false; this.map = new Map(); this.current = null; this.unlocker = this.unlock.bind(this); }
javascript
{ "resource": "" }
q8373
derive
train
function derive(passwd, salt, N, r, p, len) { if (r * p >= (1 << 30)) throw new Error('EFBIG'); if ((N & (N - 1)) !== 0 || N === 0) throw new Error('EINVAL'); if (N > 0xffffffff) throw new Error('EINVAL'); const XY = Buffer.allocUnsafe(256 * r); const V = Buffer.allocUnsafe(128 * r * N); con...
javascript
{ "resource": "" }
q8374
deriveAsync
train
async function deriveAsync(passwd, salt, N, r, p, len) { if (r * p >= (1 << 30)) throw new Error('EFBIG'); if ((N & (N - 1)) !== 0 || N === 0) throw new Error('EINVAL'); if (N > 0xffffffff) throw new Error('EINVAL'); const XY = Buffer.allocUnsafe(256 * r); const V = Buffer.allocUnsafe(128 * r *...
javascript
{ "resource": "" }
q8375
guessFontStyle
train
function guessFontStyle(basename) { return basename .split('-') .slice(1) .map(item => item.toLowerCase()) .reduce((prev, item) => { if (fontStyleKeywords.indexOf(item) >= 0) { return `font-style:${item};` } return prev }, '') }
javascript
{ "resource": "" }
q8376
guessFontWeight
train
function guessFontWeight(basename) { return basename .split('-') .slice(1) .map(item => item.toLowerCase()) .reduce((prev, item) => { if (item === 'normal') { return prev } if (fontWeightNames[item]) { return `font-weight:${fontWeightNames[item]};` } if ...
javascript
{ "resource": "" }
q8377
Mempool
train
function Mempool(options) { if (!(this instanceof Mempool)) return new Mempool(options); AsyncObject.call(this); this.options = new MempoolOptions(options); this.network = this.options.network; this.logger = this.options.logger.context('mempool'); this.workers = this.options.workers; this.chain = t...
javascript
{ "resource": "" }
q8378
Outpoint
train
function Outpoint(hash, index) { if (!(this instanceof Outpoint)) return new Outpoint(hash, index); this.hash = encoding.NULL_HASH; this.index = 0xffffffff; if (hash != null) { assert(typeof hash === 'string', 'Hash must be a string.'); assert(util.isU32(index), 'Index must be a uint32.'); thi...
javascript
{ "resource": "" }
q8379
addBoundsToArray
train
function addBoundsToArray(bounds, array) { if( !bounds ) return; var bound; for( var j = 0; j < bounds.length; j++ ) { bound = bounds[j]; if( bound.type === 'UBM' || bound.type === 'LBM' ) { array.push(bound); } } }
javascript
{ "resource": "" }
q8380
Address
train
function Address(host, port, type, hostname, raw) { this.host = host || '0.0.0.0'; this.port = port || 0; this.type = type || IP.types.IPV4; this.hostname = hostname || '0.0.0.0:0'; this.raw = raw || ZERO_IP; }
javascript
{ "resource": "" }
q8381
StaticWriter
train
function StaticWriter(size) { if (!(this instanceof StaticWriter)) return new StaticWriter(size); this.data = size ? Buffer.allocUnsafe(size) : EMPTY; this.offset = 0; }
javascript
{ "resource": "" }
q8382
camelize
train
function camelize(s) { return s.replace(STRING_CAMELIZE, function (match, separator, chr) { return chr.toUpperCase(); }).replace(/^([A-Z])/, function (match) { return match.toLowerCase(); }); }
javascript
{ "resource": "" }
q8383
setRawMode
train
function setRawMode (mode) { if (mode) { this.do.suppress_go_ahead() this.will.suppress_go_ahead() this.will.echo() } else { this.dont.suppress_go_ahead() this.wont.suppress_go_ahead() this.wont.echo() } }
javascript
{ "resource": "" }
q8384
each
train
function each(collection, iterator, context) { var i = 0; if ('array' === type(collection)) { for (; i < collection.length; i++) { if (false === iterator.call(context || iterator, collection[i], i, collection)) { return; // If false is returned by the callback we need to bail out. } } ...
javascript
{ "resource": "" }
q8385
size
train
function size(collection) { var x, i = 0; if ('object' === type(collection)) { for (x in collection) i++; return i; } return +collection.length; }
javascript
{ "resource": "" }
q8386
array
train
function array(obj) { if ('array' === type(obj)) return obj; if ('arguments' === type(obj)) return Array.prototype.slice.call(obj, 0); return obj // Only transform objects in to an array when they exist. ? [obj] : []; }
javascript
{ "resource": "" }
q8387
copy
train
function copy() { var result = {} , depth = 2 , seen = []; (function worker() { each(array(arguments), function each(obj) { for (var prop in obj) { if (hasOwn.call(obj, prop) && !~index(seen, obj[prop])) { if (type(obj[prop]) !== 'object' || !depth) { result[prop] = ...
javascript
{ "resource": "" }
q8388
train
function (userInput){ var firstTimeRun = userInput.toLowerCase(); if(firstTimeRun === 'yes'){ createGulpFile({ gulpFileSrcPath: '../templates/gulpfile.js', outputDir: '../../../gulpfile.js' }).exec({ error: function (err){ console.err...
javascript
{ "resource": "" }
q8389
readFiles
train
function readFiles() { /* jshint validthis:true */ var self = this; async.waterfall([ function(callback) { storeFileContent.init(self.options.testSrc, callback); }, function(data, callback) { self.testFiles = data; storeFileContent.init(self.options.viewSrc, callback); }, function(data, callback)...
javascript
{ "resource": "" }
q8390
TypedFastBitSet
train
function TypedFastBitSet(iterable) { this.count = 0 | 0; this.words = new Uint32Array(8); if (isIterable(iterable)) { for (var key of iterable) { this.add(key); } } }
javascript
{ "resource": "" }
q8391
Script
train
function Script(options) { if (!(this instanceof Script)) return new Script(options); this.raw = EMPTY_BUFFER; this.code = []; if (options) this.fromOptions(options); }
javascript
{ "resource": "" }
q8392
validateKey
train
function validateKey(key, flags, version) { assert(Buffer.isBuffer(key)); assert(typeof flags === 'number'); assert(typeof version === 'number'); if (flags & Script.flags.VERIFY_STRICTENC) { if (!common.isKeyEncoding(key)) throw new ScriptError('PUBKEYTYPE'); } if (version === 1) { if (flags...
javascript
{ "resource": "" }
q8393
validateSignature
train
function validateSignature(sig, flags) { assert(Buffer.isBuffer(sig)); assert(typeof flags === 'number'); // Allow empty sigs if (sig.length === 0) return true; if ((flags & Script.flags.VERIFY_DERSIG) || (flags & Script.flags.VERIFY_LOW_S) || (flags & Script.flags.VERIFY_STRICTENC)) { i...
javascript
{ "resource": "" }
q8394
checksig
train
function checksig(msg, sig, key) { return secp256k1.verify(msg, sig.slice(0, -1), key); }
javascript
{ "resource": "" }
q8395
Master
train
function Master() { if (!(this instanceof Master)) return new Master(); EventEmitter.call(this); this.parent = new Parent(); this.framer = new Framer(); this.parser = new Parser(); this.listening = false; this.color = false; this.init(); }
javascript
{ "resource": "" }
q8396
Block
train
function Block(options) { if (!(this instanceof Block)) return new Block(options); AbstractBlock.call(this); this.txs = []; this._raw = null; this._size = -1; this._witness = -1; if (options) this.fromOptions(options); }
javascript
{ "resource": "" }
q8397
isNameAbbreviation
train
function isNameAbbreviation(wordCount, words) { if (words.length > 0) { if (wordCount < 5 && words[0].length < 6 && isCapitalized(words[0])) { return true; } var capitalized = words.filter(function(str) { return /[A-Z]/.test(str.charAt(0)); }); retur...
javascript
{ "resource": "" }
q8398
AsyncObject
train
function AsyncObject() { assert(this instanceof AsyncObject); EventEmitter.call(this); this._asyncLock = new Lock(); this._hooks = Object.create(null); this.loading = false; this.closing = false; this.loaded = false; }
javascript
{ "resource": "" }
q8399
AESKey
train
function AESKey(key, bits) { if (!(this instanceof AESKey)) return new AESKey(key, bits); this.rounds = null; this.userKey = key; this.bits = bits; switch (this.bits) { case 128: this.rounds = 10; break; case 192: this.rounds = 12; break; case 256: this.rounds =...
javascript
{ "resource": "" }