_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
27
233k
language
stringclasses
1 value
meta_information
dict
q9600
compileEntity
train
function compileEntity() { var entity = extend({ buildId: bff.key(payload), extension: file.extension, filename: file.filename,
javascript
{ "resource": "" }
q9601
train
function(){ _prompt.question("You entered '" + _destination + "'. Is this correct?
javascript
{ "resource": "" }
q9602
train
function(){ console.log("Unknown Response"); if (_pathConfirmationCounter < 3){ console.log("Please enter a 'Y' or an 'N' when answering.\n");
javascript
{ "resource": "" }
q9603
train
function(){ if (destinationIsRelative){ _destination = _path.join(process.cwd(), "../..", _destination); } if(!_fs.existsSync(_destination)){ _fs.mkdirSync(_destination); } var destinationPath = _path.join(_destination, "/" + SCRIPT_NAME); var sourcePath = _path.resolve(_path.dirname(module.file...
javascript
{ "resource": "" }
q9604
pipeRunStep
train
function pipeRunStep(){ //Public APIs /** * run: run this step * Should be implemented by subclasses */ this.run = function( callback ){ throw new Error("Called run method from abstract pipeRunStep class"); } this.getLabel = function(){ return this.label || "Unknown label"; } this.getPipe = functio...
javascript
{ "resource": "" }
q9605
genValuePartial_fromObject
train
function genValuePartial_fromObject(gen, field, fieldIndex, prop) { if (field.resolvedType) { if (field.resolvedType instanceof Enum) { gen('switch(d%s){', prop); for (let values = field.resolvedType.values, keys = Object.keys(values), i = 0; i < keys.length; ++i) { if (field.repeated && value...
javascript
{ "resource": "" }
q9606
genValuePartial_toObject
train
function genValuePartial_toObject(gen, field, fieldIndex, prop, map) { if (field.resolvedType) { if (field.resolvedType instanceof Enum) { if (map) { gen('d%s.set(k, o.enums===String?types[%i].values[m%s.get(k)]:m%s.get(k));', prop, fieldIndex, prop, prop); } else { gen('d%s=o.enums===...
javascript
{ "resource": "" }
q9607
checkSum
train
function checkSum(num) { if (num == null) { return 0; } var doubled = _splitDigits(num).reverse().map(function(v, idx) { return idx % 2 === 0 ? v * 2 : v; }); var sum = doubled.reduce(function(tmp, v) {
javascript
{ "resource": "" }
q9608
isValid
train
function isValid(checkNumber) { if (checkNumber == null) { return false;
javascript
{ "resource": "" }
q9609
generate
train
function generate(length) { var len = length - 1; var ary = new Array(len); for (var i = 0; i < len; i++) { ary.push(Math.floor(Math.random() * 10));
javascript
{ "resource": "" }
q9610
bufferSplice
train
function bufferSplice (buffer, start, count/*, [...items] */) { var args = assertArgs(arguments, { buffer: [Buffer, 'object'], '[start]': 'integer', '[count]': 'integer', '[...items]': [Buffer, 'string', 'array', 'object', 'number'] }) defaults(args, { start: buffer.length, count: buffer.l...
javascript
{ "resource": "" }
q9611
mapCOW
train
function mapCOW(arr, func) { var res = null; for(var i=0; i<arr.length; i++) { var item = func(arr[i]); if(item !== arr[i]) { if(!res) {
javascript
{ "resource": "" }
q9612
FrameHandler
train
function FrameHandler(deviceOrFrameHandler) { var self = this; // call super class EventEmitter2.call(this, { wildcard: true, delimiter: ':', maxListeners: 1000 // default would be 10! }); if (this.log) { this.log = _.wrap(this.log, function(func, msg) { func(self.constructor.name + ':...
javascript
{ "resource": "" }
q9613
isValidTransition
train
function isValidTransition (link, context) { var isValid = true; if (!(PromisePipe.envTransitions[context._env] && PromisePipe.envTransitions[context._env][link._env])) {
javascript
{ "resource": "" }
q9614
passChains
train
function passChains (first, last, sequence) { return sequence.map(function (el) {
javascript
{ "resource": "" }
q9615
lastChain
train
function lastChain (first, sequence) { var index = getIndexOfNextEnvAppearance(first,
javascript
{ "resource": "" }
q9616
getChainIndexById
train
function getChainIndexById(id, sequence){ return
javascript
{ "resource": "" }
q9617
getIndexOfNextEnvAppearance
train
function getIndexOfNextEnvAppearance(fromIndex, env, sequence){ return sequence.map(function(el){
javascript
{ "resource": "" }
q9618
rangeChain
train
function rangeChain (id, sequence) { var first = getChainIndexById(id, sequence);
javascript
{ "resource": "" }
q9619
setMessage
train
function setMessage (msg) { if (msg && typeof msg === 'string') { this.message = msg } else if (this.constructor.name !== 'CustomError') { this.message
javascript
{ "resource": "" }
q9620
createStackTrace
train
function createStackTrace () { var stack = new Error().stack var splited = stack.split('\n') var modifiedStack
javascript
{ "resource": "" }
q9621
EventedSerialDeviceLoader
train
function EventedSerialDeviceLoader(Device, vendorId, productId) { // call super class SerialDeviceLoader.call(this, Device, false); this.vidPidPairs = []; if (!productId && _.isArray(vendorId)) {
javascript
{ "resource": "" }
q9622
getMaxLines
train
function getMaxLines(height) { var availHeight = height || element.clientHeight, lineHeight = getLineHeight(element);
javascript
{ "resource": "" }
q9623
getLineHeight
train
function getLineHeight(elem) { var lh = computeStyle(elem, 'line-height'); if (lh == 'normal') { // Normal line heights vary from browser to browser. The spec recommends // a value
javascript
{ "resource": "" }
q9624
getLastChild
train
function getLastChild(elem) { //Current element has children, need to go deeper and get last child as a text node if (elem.lastChild.children && elem.lastChild.children.length > 0) { return getLastChild(Array.prototype.slice.call(elem.children).pop()); } //This is the absolute ...
javascript
{ "resource": "" }
q9625
truncate
train
function truncate(target, maxHeight) { if (!maxHeight) { return; } /** * Resets global variables. */ function reset() { splitOnChars = opt.splitOnChars.slice(0); splitChar = splitOnChars[0]; chunks = null; lastChunk = n...
javascript
{ "resource": "" }
q9626
reset
train
function reset() { splitOnChars = opt.splitOnChars.slice(0); splitChar = splitOnChars[0];
javascript
{ "resource": "" }
q9627
_animateFunc
train
function _animateFunc(func, element, duration, opts) { opts = Object.assign({}, opts); var tween; return new Promise(function(resolve, reject,
javascript
{ "resource": "" }
q9628
animate
train
function animate(Promise, TweenModule) { var animateTo = _animateFunc.bind(null, TweenModule.to); var util = animateTo; util.to = animateTo; util.from = _animateFunc.bind(null, TweenModule.from); util.set = function animateSet(element, params) { params = Object.assign({}, params); return new Promise...
javascript
{ "resource": "" }
q9629
binOpEmitter
train
function binOpEmitter(str) { return function(node, frame) { this.compile(node.left, frame);
javascript
{ "resource": "" }
q9630
train
function( fn ){ // Get the object's base var objectBase = getObjectBase( this, fn ); // If the function is not found anywhere in the prototype chain // there is a pretty big problem if( ! objectBase.base ) throw new Error( "inherited coun't find method in chain (getIn...
javascript
{ "resource": "" }
q9631
train
function(){ // These will be worked out from `arguments` var SuperCtorList, protoMixin; var MixedClass, ResultClass; var list = []; var i, l, ii, ll; var proto; var r = workoutDeclareArguments( arguments ); SuperCtorList = r.SuperCtorLi...
javascript
{ "resource": "" }
q9632
elementType
train
function elementType(element) { var name = element.nodeName.toLowerCase(); if (name !== "input") { if (name === "select" && element.multiple) { return "select-multiple"; }
javascript
{ "resource": "" }
q9633
getValue
train
function getValue(element) { var name = elementType(element); switch (name) { case "checkbox": case "radio": if (!element.checked) { return false; } var val = element.getAttribute('value'); return val == null ? true : val;
javascript
{ "resource": "" }
q9634
getActivity
train
function getActivity(activityId) { var activity = activities[activityId]; if (activity === undefined) { throw new
javascript
{ "resource": "" }
q9635
writeActivity
train
function writeActivity(template, activity) { if (!enabled) { return; } var handlers = outputHandlers.get();
javascript
{ "resource": "" }
q9636
createActivity
train
function createActivity(activityMessage) { if (activityMessage === undefined || activityMessage === undefined || typeof activityMessage !== 'string') { throw new Error('Creating a new activity requires an activity message.'); } var activityId =
javascript
{ "resource": "" }
q9637
markActivity
train
function markActivity(activityId) { var activity = getActivity(activityId);
javascript
{ "resource": "" }
q9638
startActivity
train
function startActivity(activityMessage) { var activityId = createActivity(activityMessage); markActivity(activityId); var activity = getActivity(activityId);
javascript
{ "resource": "" }
q9639
endActivity
train
function endActivity(activityId) { markActivity(activityId); var activity = destroyActivity(activityId)
javascript
{ "resource": "" }
q9640
JSONPathNode
train
function JSONPathNode(n) { // Create a RED node RED.nodes.createNode(this,n); // Store local copies of the node configuration (as defined in the .html) this.expression = n.expression; this.split = n.split; var node = this; this.on("input", function(msg) { ...
javascript
{ "resource": "" }
q9641
Template
train
function Template (filename, context) { // Save the context for reuse in sub-templates this.context = context || {} this.context.include = this.render.bind(this) this.context.forEach = forEach // Save the filename
javascript
{ "resource": "" }
q9642
SerialDeviceGuider
train
function SerialDeviceGuider(deviceLoader) { var self = this; // call super class DeviceGuider.call(this, deviceLoader); this.currentState.getDeviceByPort = function(port) { return _.find(self.currentState.plugged, function(d) { return d.get('portName') && port && d.get('portName').toLowerCase() === ...
javascript
{ "resource": "" }
q9643
HashCodeContext
train
function HashCodeContext(value, hashCode, options) { if (options == null) { options = {}; } /** * A reference to {@link Nevis.hashCode} which can be called within a {@link HashCodeGenerator}. * * @private * @type {Function} */ this._hashCode = hashCode; /** * The options to be used to ...
javascript
{ "resource": "" }
q9644
checkPackageJsonInGit
train
function checkPackageJsonInGit () { return exec('git', ['status', '--porcelain', 'package.json']) .then(function ([stdout, stderr]) { debug('git status --porcelain package.json', 'stdout', stdout, 'stderr', stderr) if (stdout.indexOf('package.json') >= 0) { throw new Error('package.json has ch...
javascript
{ "resource": "" }
q9645
combineStatsAndIndexes
train
function combineStatsAndIndexes(done, results) { var indexes = results.getIndexes; var stats = results.getIndexStats; var sizes = results.getIndexSizes; _.each(indexes, function(idx, i) {
javascript
{ "resource": "" }
q9646
OpenConnection
train
function OpenConnection(connection) { let base = new pg.Client({ host: connection.Hostname || 'localhost', port: parseInt(connection.Port) || 5432, user: connection.Username,
javascript
{ "resource": "" }
q9647
train
function(renderData){ var renderArr = Object.keys(renderData).map(function(mask){ return { mask: mask, context: renderData[mask].context, component: renderData[mask].component, params: renderData[mask].params, data: renderData[mask].data } })...
javascript
{ "resource": "" }
q9648
DeviceLoader
train
function DeviceLoader() { var self = this; // call super class EventEmitter2.call(this, { wildcard: true, delimiter: ':', maxListeners: 1000 // default would be 10! }); if (this.log) { this.log = _.wrap(this.log, function(func, msg) { func(self.constructor.name + ': ' + msg); }); ...
javascript
{ "resource": "" }
q9649
createLogger
train
function createLogger (config) { config = config || {} let level if (process.env.KOOP_LOG_LEVEL) { level = process.env.KOOP_LOG_LEVEL } else if (process.env.NODE_ENV === 'production') { level = 'info' } else { level = 'debug' } if (!config.logfile) { // no logfile defined, log to STDOUT a...
javascript
{ "resource": "" }
q9650
formatter
train
function formatter (options) { const line = [ new Date().toISOString(), options.level ] if (options.message !== undefined) line.push(options.message) if (options.meta &&
javascript
{ "resource": "" }
q9651
difference
train
function difference(object, base) { return transform(object, (result, value, key) => { if (!isEqual(value, base[key])) {
javascript
{ "resource": "" }
q9652
train
function ( method, params, cb ) { if ( typeof params === 'function' ) { cb = params; params = {}; } params = extend(params, {request: method}); this.__request({ method: 'get', url: this.options.api_url, qs: params }, fun...
javascript
{ "resource": "" }
q9653
_createBiquadFilter
train
function _createBiquadFilter (defaults) { return function (context, opts) { if (audioContext) { opts = context; context = audioContext; } opts = assign(opts, defaults); var filter = context.createBiquadFilter(); Object.keys(opts).forEach(function (op...
javascript
{ "resource": "" }
q9654
train
function(options, ...rest) { Entity.apply(this, [options, ...rest]); this.itemType = options.itemType; this.itemFactory = options.itemFactory; this.body = defaults(options.body, { count: 0, items: [] });
javascript
{ "resource": "" }
q9655
set_references
train
function set_references( vm_options ) { if ( vm_options.Dialog ) { Dialog = vm_options.Dialog; } if ( !Dialog ) { if ( typeof window !== 'undefined' && window.Dialog ) { Dialog = window.Dialog; } else { throw new Error( 'No refe...
javascript
{ "resource": "" }
q9656
patch
train
function patch(element, previous, attrs) { if (!previous && !attrs) { return attrs; } var attrName, ns, name, value, split; previous = previous || {}; attrs = attrs || {}; for (attrName in previous) { if (previous[attrName] && !attrs[attrName]) { split = splitAttrName(attrName); ns = na...
javascript
{ "resource": "" }
q9657
getFile
train
function getFile(filepath) { var fileObj = { path: filepath, content: null }; try { fs.accessSync(filepath, fs.F_OK); } catch(e) { console.log(e.message);
javascript
{ "resource": "" }
q9658
Floppy
train
function Floppy(url, fn) { if (!(this instanceof Floppy)) return new Floppy(url, fn); this.readyState = Floppy.LOADING; this.start = +new Date(); this.callbacks = []; this.dependent = 0;
javascript
{ "resource": "" }
q9659
translateResponse
train
function translateResponse(obj){ for(var k in obj){ if(obj[k] instanceof Array){ for(var i=0;i<obj[k].length;i++){ // just an array of strings if(obj[k][i] instanceof Buffer){ obj[k][i] = obj[k][i].toString() } else { // and array of objects.. for(var k...
javascript
{ "resource": "" }
q9660
train
function(req) { if(!req || !req.url) return false; if(typeof(path) === 'string') { return (req.url).match(path) && ((req.url).match(path).index === 0);
javascript
{ "resource": "" }
q9661
ignoreValue
train
function ignoreValue(value) { if (value === null || value === undefined || value.length === 0) { return true; } if (value.length === 0) { return true; } if (typeof (value) === 'object') { return false; } value = value.toLowerCase(); var ignoreValues = ['not availa...
javascript
{ "resource": "" }
q9662
LDA
train
function LDA(...classes) { // Compute pairwise LDA classes (needed for multiclass LDA) if(classes.length < 2) { throw new Error('Please pass at least 2 classes'); } let numberOfPairs = classes.length * (classes.length - 1) / 2;
javascript
{ "resource": "" }
q9663
train
function(Device, filter) { var sub = new EventEmitter2({ wildcard: true, delimiter: ':', maxListeners: 1000 // default would be 10! }); sub.Device = Device; sub.filter = filter; sub.oldDevices = []; sub.newDevices = []; /** * Calls the callback with an array of device...
javascript
{ "resource": "" }
q9664
train
function(callback) { sp.list(function(err, ports) { if (err && !err.name) { err = new Error(err); } if (err && callback) { return callback(err); } async.forEach(subscribers, function(s, callback) { if (s) { var resPorts = s.filter(ports); var devices = _...
javascript
{ "resource": "" }
q9665
train
function(callback) { globalSerialDeviceLoader.lookup(function(err) { if (err && !err.name) { err = new Error(err); } if (err && callback) { return callback(err); } async.forEach(subscribers, function(s, callback) { if (s && s.oldDevices.length !== s.newDevices.length) { ...
javascript
{ "resource": "" }
q9666
train
function(interval, callback) { if (lookupIntervalId) { return; } isRunning = true; if (!callback && _.isFunction(interval)) { callback = interval; interval = null; } interval = interval || 500; globalSerialDeviceLoader.trigger(function(err) { var triggering = fals...
javascript
{ "resource": "" }
q9667
cpy32
train
function cpy32 (d, s) { for (var i = 0; i < 32; i++)
javascript
{ "resource": "" }
q9668
forLeftButton
train
function forLeftButton(props) { const { position, scene, scenes } = props; const interpolate = getSceneIndicesForInterpolationInputRange(props); if (!interpolate) return { opacity: 0 }; const { first, last } = interpolate; const index = scene.index; return { opacity: position.interpolate({ inpu...
javascript
{ "resource": "" }
q9669
all
train
function all (extent, minZoom, maxZoom) { const tiles = [] const grid = single(extent, minZoom,
javascript
{ "resource": "" }
q9670
levels
train
function levels (extent, minZoom, maxZoom) { const extents = [] if (extent === undefined) throw new Error('extent is required') if (minZoom === undefined) throw new Error('minZoom is required') if (maxZoom === undefined) throw new Error('maxZoom is required') // Single Array if (extent.length === 4 && exte...
javascript
{ "resource": "" }
q9671
count
train
function count (extent, minZoom, maxZoom, quick) { quick = quick || 1000 let count = 0 // Quick count if (quick !== -1) { for (const [columns, rows] of levels(extent, minZoom, maxZoom)) { count += rows.length * columns.length } if (count > quick) { return count } } //
javascript
{ "resource": "" }
q9672
normalize
train
function normalize(file, fn) { var orig = utils.extend({}, file); // support paths if (typeof fn === 'string') { file.type = 'path'; file.path = fn; file.origPath = fn; file = resolve(file, file.options); // support functions } else if (typeof fn === 'function') { file.type = 'function';...
javascript
{ "resource": "" }
q9673
genTypePartial
train
function genTypePartial(gen, field, fieldIndex, ref) { return field.resolvedType.group ? gen('types[%i].encode(%s,w.uint32(%i)).uint32(%i)', fieldIndex, ref, (field.id << 3 | 3) >>> 0, (field.id << 3 | 4) >>> 0) :
javascript
{ "resource": "" }
q9674
patch
train
function patch(element, previous, attrs) { if (!previous && !attrs) { return attrs; } var name, value; previous = previous || {}; attrs = attrs || {}; for (name in previous) { if (previous[name] && !attrs[name]) { unset(name, element, previous); } } for (name in attrs) { if
javascript
{ "resource": "" }
q9675
set
train
function set(name, element, previous, attrs) { if (set.handlers[name]) { set.handlers[name](name, element, previous, attrs); } else if (attrs[name]
javascript
{ "resource": "" }
q9676
unset
train
function unset(name, element, previous) { if (unset.handlers[name])
javascript
{ "resource": "" }
q9677
getParent
train
function getParent(tile) { // top left if (tile[0] % 2 === 0 && tile[1] % 2 === 0) { return [tile[0] / 2, tile[1] / 2, tile[2] - 1]; } // bottom left if ((tile[0] % 2 === 0) && (!tile[1] % 2 === 0)) { return [tile[0] / 2, (tile[1] - 1) / 2, tile[2] - 1]; } // top
javascript
{ "resource": "" }
q9678
copyFile
train
function copyFile (src, dest) { return new Promise((resolve, reject) => { const read = fs.createReadStream(src); read.on('error', reject); const write = fs.createWriteStream(dest);
javascript
{ "resource": "" }
q9679
parseCMS
train
function parseCMS(fileString) { var intObj = txtToIntObj(fileString);
javascript
{ "resource": "" }
q9680
clean
train
function clean(cmsString) { if (cmsString.indexOf('\r\n') >= 0) { cmsString = cmsString.replace(/\r\n/g, '\n'); cmsString = cmsString.replace(/\r/g, '\n'); }
javascript
{ "resource": "" }
q9681
separateSections
train
function separateSections(data) { //Separated regular expression into many distinct pieces //specical metaMatchCode goes first. // 1st regular expression for meta, need to do var metaMatchCode = '^(-).[\\S\\s]+?(\\n){2,}'; //this isn't used anywhere... /* 2nd regular expression for claims, becaus...
javascript
{ "resource": "" }
q9682
cleanUpTitle
train
function cleanUpTitle(rawTitleString) { /*dashChar is most commonly the dash of the title string, or a the first repeating character surrounding the title */ var dashChar = rawTitleString.charAt(0); //beginning and ending index of the dash var dashBegIndex = 0; var dashEndIndex = rawTitleString.la...
javascript
{ "resource": "" }
q9683
processClaimsLineChild
train
function processClaimsLineChild(objectString) { var claimLineObj = {}; var obj = {}; var objArray = []; var keyValuePairRegExp = /(\n){1,}[\S\s,]+?(:)[\S\s]+?(?=((\n){1,})|$)/gi; var keyValuePairArray = objectString.match(keyValuePairRegExp); //unusual steps are required to parse meta data and ...
javascript
{ "resource": "" }
q9684
getSectionBody
train
function getSectionBody(sectionString) { /*first, use regular expressions to parse the section body into different objects */ var sectionBody = {}; var sectionBodyData = []; var objectFromBodyRegExp = /-*(\n){2,}(?!-{4,})[\S\s,]+?((?=((\n){3,}?))|\n\n$)/gi; //or go to the end of the string. va...
javascript
{ "resource": "" }
q9685
getMetaBody
train
function getMetaBody(sectionString) { var sectionBody = {}; var sectionBodyObj = {}; var metaBodyCode = /-{2,}((\n*?\*{3,}[\S\s]+\*{3,})|(\n{2,}))[\S\s]+?\n{3,}/gi; var objectStrings = sectionString.match(metaBodyCode); for (var obj = 0; obj < objectStrings.length; obj++) { var sectionChild ...
javascript
{ "resource": "" }
q9686
convertToObject
train
function convertToObject(sectionString) { var sectionObj = {}; //get the section title(get it raw, clean it) var sectionTitleRegExp = /(-){3,}([\S\s]+?)(-){3,}/; var sectionRawTitle = sectionString.match(sectionTitleRegExp)[0]; var sectionTitle = cleanUpTitle(sectionRawTitle).toLowerCase(); //...
javascript
{ "resource": "" }
q9687
getTitles
train
function getTitles(fileString) { var headerMatchCode = '(-){4,}[\\S\\s]+?(\\n){2,}(-){4,}'; var headerRegExp = new RegExp(headerMatchCode, 'gi'); var rawTitleArray = fileString.match(headerRegExp); var titleArray = []; if (rawTitleArray === null) { return null; } for (var i = 0, len ...
javascript
{ "resource": "" }
q9688
Socket
train
function Socket (options) { this.$ipaddress = ip.address(); this.$port = options.port; this.$host = options.host || '224.1.1.1'; this.$ttl = options.ttl || 128; this.$dispatcher = options.dispatcher;
javascript
{ "resource": "" }
q9689
patch
train
function patch(element, previous, style) { if (!previous && !style) { return style; } var rule; if (typeof style === 'object') { if (typeof previous === 'object') { for (rule in previous) { if (!style[rule]) { domElementCss(element, rule, null); }
javascript
{ "resource": "" }
q9690
patch
train
function patch(element, previous, props) { if (!previous && !props) { return props; } var name, value; previous = previous || {}; props = props || {}; for (name in previous) { if (previous[name] === undefined || props[name] !== undefined) { continue; }
javascript
{ "resource": "" }
q9691
set
train
function set(name, element, previous, props) { if (set.handlers[name]) { set.handlers[name](name,
javascript
{ "resource": "" }
q9692
unset
train
function unset(name, element, previous) { if (unset.handlers[name])
javascript
{ "resource": "" }
q9693
$cond
train
function $cond(params) { if ( Array.isArray(params) && params.length === 3 && typeof params[0] === 'boolean'
javascript
{ "resource": "" }
q9694
broadcastInserted
train
function broadcastInserted(node) { if (node.hooks && node.hooks.inserted) { return node.hooks.inserted(node, node.element); } if (node.children) { for (var i = 0, len
javascript
{ "resource": "" }
q9695
walk
train
function walk(dir, before, after, handler, name = null, depth = 0) { const listed = fs.readdirAsync( dir ).then((list) => Promise.map(list, (item) => { const child = path.resolve(dir, item); const result = fs.lstatAsync( child ).then((stat) => ({ path: child, name: item, isFile: stat.isFile(), ...
javascript
{ "resource": "" }
q9696
filterChildren
train
function filterChildren(children, depth) { if(depth == 1) { let found = false; for(let item of children) {
javascript
{ "resource": "" }
q9697
random
train
function random(min, max, float) { if (min === undefined) { return Math.random(); } if (max === undefined) { max = min; min = 0; } if (max < min) { var tmp = max; max = min; min = tmp; } if (float) { var result = Math.random() * (max - min) + min;
javascript
{ "resource": "" }
q9698
checkName
train
function checkName(name, cb) { request(`https://registry.npmjs.org/${name}/latest`, {}, function(err, res, msg) { if (err) return cb(err); if (typeof msg === 'string' && msg === 'Package not found') { cb(null, false); return;
javascript
{ "resource": "" }
q9699
upTo
train
function upTo(el, tagName) { tagName = tagName.toLowerCase(); while (el && el.parentNode) { el = el.parentNode; if (el.tagName && el.tagName.toLowerCase() == tagName)
javascript
{ "resource": "" }