Tabnine Logo For Javascript
builtins
Code IndexAdd Tabnine to your IDE (free)

How to use builtins

Best JavaScript code snippets using builtins(Showing top 15 results out of 206,082)

origin: Netflix/pollyjs

get options() {
  return {
   ...(this.defaultOptions || {}),
   ...((this.polly.config.adapterOptions || {})[this.constructor.id] || {})
  };
 }
origin: Netflix/pollyjs

async record(pollyRequest) {
  pollyRequest.action = ACTIONS.RECORD;

  if ('navigator' in global && !navigator.onLine) {
   console.warn(
    '[Polly] Recording may fail because the browser is offline.\n' +
     `${stringifyRequest(pollyRequest)}`
   );
  }

  return this.onRecord(pollyRequest);
 }
origin: Netflix/pollyjs

export default function isExpired(recordedOn, expiresIn) {
 if (recordedOn && expiresIn) {
  return (
   new Date() >
   new Date(new Date(recordedOn).getTime() + dehumanizeTime(expiresIn))
  );
 }

 return false;
}
origin: Netflix/pollyjs

export default function normalizeRecordedResponse(response) {
 const { status, statusText, headers, content } = response;

 return {
  statusText,
  statusCode: status,
  headers: normalizeHeaders(headers),
  body: content && content.text,
  isBinary: Boolean(content && content._isBinary)
 };
}
origin: Netflix/pollyjs

async findRecording(recordingId) {
  const response = await this.ajax(`/${encodeURIComponent(recordingId)}`, {
   Accept: 'application/json; charset=utf-8'
  });

  return this._normalize(response);
 }
origin: Netflix/pollyjs

export default function buildUrl(...paths) {
 const url = new URL(
  paths
   .map(p => p && (p + '').trim()) // Trim each string
   .filter(Boolean) // Remove empty strings or other falsy paths
   .join('/')
 );

 // Replace 2+ consecutive slashes with 1. (e.g. `///` --> `/`)
 url.set('pathname', url.pathname.replace(/\/{2,}/g, '/'));

 return url.href;
}
origin: Netflix/pollyjs

/**
 * Determine if the given buffer is utf8.
 * @param {Buffer} buffer
 */
export default function isBufferUtf8Representable(buffer) {
 const utfEncodedBuffer = buffer.toString('utf8');
 const reconstructedBuffer = Buffer.from(utfEncodedBuffer, 'utf8');

 return reconstructedBuffer.equals(buffer);
}
origin: Netflix/pollyjs

saveRecording(recordingId, data) {
  /*
   Pass the data through the base persister's stringify method so
   the output will be consistent with the rest of the persisters.
  */
  this.api.saveRecording(recordingId, parse(this.stringify(data)));
 }
origin: Netflix/pollyjs

export default function getBufferFromStream(stream) {
 return new Promise(resolve => {
  const chunks = [];

  stream.on('data', chunk => {
   chunks.push(chunk);
  });

  stream.on('end', () => {
   resolve(Buffer.concat(chunks));
  });
 });
}
origin: Netflix/pollyjs

logError(request, error) {
  this.groupStart(request.recordingName);

  console.group(`Errored ➞ ${request.method} ${request.url}`);
  console.error(error);
  console.log('Request:', request);

  if (request.didRespond) {
   console.log('Response:', request.response);
  }

  console.log('Identifiers:', request.identifiers);
  console.groupEnd();
 }
origin: Netflix/pollyjs

function customizer(objValue, srcValue, key) {
 // Arrays and `context` options should just replace the existing value
 // and not be deep merged.
 if (Array.isArray(objValue) || ['context'].includes(key)) {
  return srcValue;
 }
}
origin: Netflix/pollyjs

it('.emitSync() - stopPropagation', async function() {
   const array = [];

   emitter.on('a', e => {
    e.stopPropagation();
    array.push(1);
   });
   emitter.on('a', () => array.push(2));

   expect(emitter.emitSync('a')).to.be.false;
   expect(array).to.have.ordered.members([1]);
  });
origin: Netflix/pollyjs

export function headers(headers, config, req) {
 const normalizedHeaders = new HTTPHeaders(headers);

 if (isFunction(config)) {
  return config(normalizedHeaders, req);
 }

 if (isObjectLike(config) && isArray(config.exclude)) {
  config.exclude.forEach(header => delete normalizedHeaders[header]);
 }

 return normalizedHeaders;
}
origin: Netflix/pollyjs

static register(Factory) {
  if (!FACTORY_REGISTRATION.has(Factory)) {
   FACTORY_REGISTRATION.set(Factory, container =>
    container.register(Factory)
   );
  }

  this.on('register', FACTORY_REGISTRATION.get(Factory));

  return this;
 }
origin: Netflix/pollyjs

function guidFor(str) {
 const hash = fnv1a(str).toString();
 let slug = slugify(sanitize(str));

 // Max the slug at 100 char
 slug = slug.substring(0, 100 - hash.length - 1);

 return `${slug}_${hash}`;
}
builtins(MDN)

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

  • fs
  • yargs
    yargs the modern, pirate-themed, successor to optimist.
  • mocha
    simple, flexible, fun test framework
  • redis
    Redis client library
  • minimatch
    a glob matcher in javascript
  • aws-sdk
    AWS SDK for JavaScript
  • glob
    a little globber
  • ws
    Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js
  • http
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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