MCPcopy Create free account
hub / github.com/nodejs/node-addon-api / success

Function success

test/async_progress_queue_worker.js:147–167  ·  view source on GitHub ↗
(binding)

Source from the content-addressed store, hash-verified

145}
146
147function success (binding) {
148 return new Promise((resolve, reject) => {
149 const expected = [0, 1, 2, 3];
150 const actual = [];
151 const worker = binding.createWork(expected.length,
152 common.mustCall((err) => {
153 if (err) {
154 reject(err);
155 } else {
156 // All queued items shall be invoked before complete callback.
157 assert.deepEqual(actual, expected);
158 resolve();
159 }
160 }),
161 common.mustCall((_progress) => {
162 actual.push(_progress);
163 }, expected.length)
164 );
165 binding.queueWork(worker);
166 });
167}
168
169function fail (binding) {
170 return new Promise((resolve, reject) => {

Callers 1

testFunction · 0.70

Calls

no outgoing calls

Tested by 1

testFunction · 0.56