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

How to use
unshift
function
in
Array

Best JavaScript code snippets using builtins.Array.unshift(Showing top 15 results out of 5,364)

origin: avwo/whistle

function getReqRaw(req) {
 removeEncodingFields(req.headers);
 var headers = getHeadersRaw(req.headers, req.rawHeaderNames);
 var url = String(req.url || '').replace(/^ws/, 'http');
 headers.unshift([getMethod(req.method), url, 'HTTP/1.1'].join(' '));
 return decodeRaw(headers, req);
}
origin: codeceptjs/CodeceptJS

function print(...msg) {
 if (outputProcess) {
  msg.unshift(outputProcess);
 }
 if (!newline) {
  console.log();
  newline = true;
 }

 console.log.apply(this, msg);
}
origin: discordjs/discord.js

/**
  * An array of cached versions of the message, including the current version
  * Sorted from latest (first) to oldest (last)
  * @type {Message[]}
  * @readonly
  */
 get edits() {
  const copy = this._edits.slice();
  copy.unshift(this);
  return copy;
 }
origin: strapi/strapi

enqueue(payload) {
  debug('Enqueue event in worker queue');
  if (this.running < this.concurrency) {
   this.running++;
   this.execute(payload);
  } else {
   this.queue.unshift(payload);
  }
 }
origin: sindresorhus/eslint-plugin-unicorn

Array.from({length: Math.min(total, length)}, (_, sampleIndex) => {
    let indexRemaining = sampleIndex;
    const combination = [];
    for (let i = combinations.length - 1; i >= 0; i--) {
      const items = combinations[i];
      const {length} = items;
      const index = indexRemaining % length;
      indexRemaining = (indexRemaining - index) / length;
      combination.unshift(items[index]);
    }

    return combination;
  })
origin: standard-things/esm

function init() {
 const ArrayProto = Array.prototype
 const SafeProto = SafeArray.prototype

 return {
  concat: unapply(SafeProto.concat),
  from: SafeArray.from,
  indexOf: unapply(ArrayProto.indexOf),
  join: unapply(ArrayProto.join),
  of: SafeArray.of,
  push: unapply(ArrayProto.push),
  unshift: unapply(ArrayProto.unshift)
 }
}
origin: avwo/whistle

fs.writeFile(path.join(LOCAL_FILES, name), content, function(err) {
   if (!err) {
    var index = indexOfUploadFiles(name);
    if (index !== -1) {
     uploadFiles.splice(index, 1);
    }
    uploadFiles.unshift({
     name: name,
     date: Date.now()
    });
   }
   callback(err);
  });
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: lando/lando

/*
 * Helper to map the cwd on the host to the one in the container
 */
const getContainerPath = appRoot => {
 // Break up our app root and cwd so we can get a diff
 const cwd = process.cwd().split(path.sep);
 const dir = _.drop(cwd, appRoot.split(path.sep).length);
 // Add our in-container app root
 // this will always be /app
 dir.unshift('/app');
 // Return the directory
 return dir.join('/');
}
origin: discordjs/discord.js

playUnknown(input, options) {
  this.destroyDispatcher();

  const isStream = input instanceof ReadableStream;

  const args = isStream ? FFMPEG_ARGUMENTS.slice() : ['-i', input, ...FFMPEG_ARGUMENTS];
  if (options.seek) args.unshift('-ss', String(options.seek));

  const ffmpeg = new prism.FFmpeg({ args });
  const streams = { ffmpeg };
  if (isStream) {
   streams.input = input;
   input.pipe(ffmpeg);
  }
  return this.playPCMStream(ffmpeg, options, streams);
 }
origin: sindresorhus/on-change

test('should only execute once if map is called within callback', t => {
  let count = 0;

  const object = {
    arr: [],
    foo: true
  };

  const proxy = onChange(object, function () {
    count++;
    this.arr.map(item => item);
  });

  proxy.arr.unshift('value');

  t.is(count, 1);
});
origin: lando/lando

/*
  * @TODO, add compose data to the add
  */
 add(data, front = false) {
  if (front) this.composeData.unshift(data);
  else this.composeData.push(data);
 }
origin: lando/lando

_.forEach(_.uniq(_.map(build, 'id')), container => {
   build.unshift({
    id: container,
    cmd: '/helpers/user-perms.sh --silent',
    compose: app.compose,
    project: app.project,
    opts: {
     mode: 'attach',
     prestart,
     user: 'root',
     services: [container.split('_')[1]],
    },
   });
  });
origin: avwo/whistle

function getResRaw(res) {
 removeEncodingFields(res.headers);
 var headers = getHeadersRaw(res.headers, res.rawHeaderNames);
 var statusCode = res.statusCode === 'aborted' ? 502 : res.statusCode;
 var statusMessage = !statusCode ? '' : res.statusMessage || STATUS_CODES[statusCode] || 'unknown';
 headers.unshift(['HTTP/1.1', statusCode, statusMessage].join(' '));
 return decodeRaw(headers, res);
}
origin: strapi/strapi

enqueue(payload) {
  debug('Enqueue event in worker queue');
  if (this.running < this.concurrency) {
   this.running++;
   this.execute(payload);
  } else {
   this.queue.unshift(payload);
  }
 }
builtins(MDN)Arrayunshift

JSDoc

Inserts new elements at the start of an array.

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

  • path
  • body-parser
    Node.js body parsing middleware
  • bluebird
    Full featured Promises/A+ implementation with exceptionally good performance
  • minimatch
    a glob matcher in javascript
  • glob
    a little globber
  • http
  • js-yaml
    YAML 1.2 parser and serializer
  • express
    Fast, unopinionated, minimalist web framework
  • commander
    the complete solution for node.js command-line programs
  • Top 17 Free Sublime Text 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