What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-11-18 22:48:15
javascript promise all
var p1 = Promise.resolve(3); var p2 = 1337; var p3 = new Promise((resolve, reject) => { setTimeout(resolve, 100, "foo"); }); Promise.all([p1, p2, p3]).then(values => { console.log(values); // [3, 1337, "foo"] }); Add solution -
Javascript 2021-11-13 23:56:17
code in nested forEach loop- react native
const nestedPromise = async (items = []) => { return await Promise.all( items.map(async item => { if (Array.isArray(item) && item.length) { return await nestedPromise(item) } // return await call to your funct... Add solution -
Javascript 2021-11-12 20:01:23
service worker.js
/* Copyright 2016 Google Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.or... Add solution -
Other 2021-11-12 08:18:13
Property 'allSettled' does not exist on type 'PromiseConstructor'
/* To get this running on Linux, I needed the latest typescript version: */ npm install -g typescript@latest /* Then in your tsconfig you currently need the ES2020.Promise lib. */ { "compilerOptions": { "lib": [ "ES... Add solution -
Javascript 2021-11-10 21:22:16
javascript wait for multiple promises
const promise1 = Promise.resolve(3); const promise2 = 42; const promise3 = new Promise((resolve, reject) => { setTimeout(resolve, 100, 'foo'); }); Promise.all([promise1, promise2, promise3]).then((values) => { console.log(values); }); // expect... Add solution -
Javascript 2021-11-04 00:56:09
How to make a function run only after 2 events has triggered js
const promise1 = Promise.resolve(3); const promise2 = 42; const promise3 = new Promise(function(resolve, reject) { setTimeout(resolve, 100, 'foo'); }); Promise.all([promise1, promise2, promise3]).then(function(values) { console.log(values); }); // ex... Add solution -
Javascript 2021-10-25 05:24:11
Manually Parsing PDF in Node.js
/* This code comes from Vincent Lab And it has a video version linked here: https://www.youtube.com/watch?v=b2dLDqmYT4I */ // Import dependencies const fs = require("fs"); const PDFParser = require("pdf2json"); // Get all the... Add solution -
Javascript 2021-10-20 09:40:05
bytes to string js
const axios = require('axios') function serializeBytes(sty) { const string = JSON.stringify({ data: sty }) const input = Array.from(string) const ouput = input.map((_, i) => string.charCodeAt(i)) return new Uint8Array(ouput) } function deserializ... Add solution