Tabnine Logo For Javascript
Array.shift
Code IndexAdd Tabnine to your IDE (free)

How to use
shift
function
in
Array

Best JavaScript code snippets using builtins.Array.shift(Showing top 15 results out of 7,047)

origin: Flood-UI/flood

sendDefferedMethodCall() {
  if (this.pendingRequests.length > 0) {
   this.isRequestPending = true;

   const nextRequest = this.pendingRequests.shift();

   this.sendMethodCall(nextRequest.methodName, nextRequest.parameters)
    .then(nextRequest.resolve)
    .catch(nextRequest.reject);
  }
 }
origin: FormidableLabs/nodejs-dashboard

_.each(values, (value, seriesName) => {
  if (!this.series[seriesName]) {
   return;
  }
  if (this._isHighwater(seriesName)) {
   this.series[seriesName].y = _.times(this.limit, _.constant(value));
  } else {
   this.series[seriesName].y.shift();
   this.series[seriesName].y.push(value);
  }
 });
origin: pinojs/pino

test('fatal method should call async when sync-flushing fails', ({ equal, fail, doesNotThrow, plan }) => {
 plan(2)
 const messages = [
  'this is fatal 1'
 ]
 const stream = sink((result) => equal(result.msg, messages.shift()))
 stream.flushSync = () => { throw new Error('Error') }
 stream.flush = () => fail('flush should be called')

 const instance = pino(stream)
 doesNotThrow(() => instance.fatal(messages[0]))
})
origin: moleculerjs/moleculer

bench1.run()
    .then(() => {
      if (dataFiles.length > 0)
        return runTest(dataFiles.shift());
    })
origin: lukeed/taskr

co(function * (o) {
    o = o || {};
    const args = [];
    args.push.apply(args, arguments) && args.shift();
    // grab alias to chosen source type
    const arr = this._[opts.files ? 'files' : 'globs'];
    // wrapper pass all arguments to plugin func
    const run = s => co(func).apply(this, [s, o].concat(args));
    // loop thru EACH if `every`, else send full source array
    yield (opts.every ? Promise.all(arr.map(run)) : run(arr));
    // send back instance allow chain
    return this;
  })
origin: stdlib/lib

const formatSize = size => {
 let sizes = [[2, 'M'], [1, 'k']];
 while (sizes.length) {
  let checkSize = sizes.shift();
  let limit = Math.pow(1024, checkSize[0]);
  if (size > limit) {
   return `${(size / limit).toFixed(2)} ${checkSize[1]}B`
  }
 }
 return `${size} B`;
}
origin: Automattic/wp-calypso

runner.on( 'suite end', function ( suite ) {
              if ( suite.root ) {
                return;
              }
              stack.shift();
            } );
origin: parse-community/parse-server

Object.keys(update).forEach((fieldName) => {
   if (fieldName.indexOf('.') > -1) {
    const components = fieldName.split('.');
    const first = components.shift();
    dotNotationOptions[first] = true;
   } else {
    dotNotationOptions[fieldName] = false;
   }
  });
origin: moleculerjs/moleculer

function runTest(dataName) {
  return Promise.resolve()
    .then(() => Promise.mapSeries([
      "Fake",
      "NATS",
      "Redis",
      "MQTT",
      "TCP"
    ], transporter => measureTP(transporter, dataName)))
    .then(() => {
      if (dataFiles.length > 0)
        runTest(dataFiles.shift());
    });
}
origin: codeceptjs/CodeceptJS

event.dispatcher.on(event.step.started, (step) => {
    output.stepShift = 3;
    const printMetaStep = (metaStep) => {
     if (!metaStep) return currentMetaStep.shift();
     if (currentMetaStep.indexOf(metaStep.toString()) >= 0) return; // step is the same
     if (metaStep.metaStep) {
      printMetaStep(metaStep.metaStep);
     }
     currentMetaStep.unshift(metaStep.toString());
     output.step(metaStep);
    };
    printMetaStep(step.metaStep);
    output.step(step);
   });
origin: pinojs/pino

test('resets levels from labels to numbers', async ({ is }) => {
 const expected = [{
  level: 30,
  msg: 'hello world'
 }]
 pino({ useLevelLabels: true })
 const instance = pino({ useLevelLabels: false }, sink((result, enc, cb) => {
  const current = expected.shift()
  check(is, result, current.level, current.msg)
  cb()
 }))

 instance.info('hello world')
})
origin: FormidableLabs/nodejs-dashboard

_.each(data, (values) => {
  _.each(values, (value, seriesName) => {
   if (!this.series[seriesName]) {
    return;
   }
   if (!this._isHighwater(seriesName)) {
    this.series[seriesName].y.shift();
    this.series[seriesName].y.push(value);
   }
  });
 });
origin: discordjs/discord.js

run() {
  if (this.queue.length === 0) return Promise.resolve();
  return this.execute(this.queue.shift());
 }
origin: parse-community/parse-server

Object.keys(update).forEach(fieldName => {
   if (fieldName.indexOf('.') > -1) {
    const components = fieldName.split('.');
    const first = components.shift();
    dotNotationOptions[first] = true;
   } else {
    dotNotationOptions[fieldName] = false;
   }
  });
origin: lukeed/taskr

co(function * (o) {
    o = o || {};
    const args = [];
    args.push.apply(args, arguments) && args.shift();
    // grab alias to chosen source type
    const arr = this._[opts.files ? 'files' : 'globs'];
    // wrapper pass all arguments to plugin func
    const run = s => co(func).apply(this, [s, o].concat(args));
    // loop thru EACH if `every`, else send full source array
    yield (opts.every ? Promise.all(arr.map(run)) : run(arr));
    // send back instance allow chain
    return this;
  })
builtins(MDN)Arrayshift

JSDoc

Removes the first element from an array and returns it.

Most used builtins functions

  • Console.log
  • Console.error
  • Promise.then
    Attaches callbacks for the resolution and/or rejection of the Promise.
  • Promise.catch
    Attaches a callback for only the rejection of the Promise.
  • Array.push
    Appends new elements to an array, and returns the new length of the array.
  • Array.length,
  • Array.map,
  • String.indexOf,
  • fetch,
  • Window.location,
  • Window.addEventListener,
  • ObjectConstructor.keys,
  • Array.forEach,
  • Location.reload,
  • Response.status,
  • Navigator.serviceWorker,
  • ServiceWorkerContainer.register,
  • ServiceWorkerRegistration.installing,
  • ServiceWorkerContainer.controller

Popular in JavaScript

  • colors
    get colors in your node.js console
  • readable-stream
    Streams3, a user-land copy of the stream library from Node.js
  • winston
    A logger for just about everything.
  • js-yaml
    YAML 1.2 parser and serializer
  • postcss
  • mime-types
    The ultimate javascript content-type utility.
  • fs-extra
    fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as mkdir -p, cp -r, and rm -rf.
  • debug
    small debugging utility
  • glob
    a little globber
  • Top 17 PhpStorm Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now