MCPcopy Index your code
hub / github.com/nodejs/node / produce

Function produce

test/parallel/test-vm-cached-data.js:11–36  ·  view source on GitHub ↗
(source, count)

Source from the content-addressed store, hash-verified

9}
10
11function produce(source, count) {
12 count ||= 1;
13
14 const out = spawnSync(process.execPath, [ '-e', `
15 'use strict';
16 const assert = require('assert');
17 const vm = require('vm');
18
19 var data;
20 for (var i = 0; i < ${count}; i++) {
21 var script = new vm.Script(process.argv[1], {
22 produceCachedData: true
23 });
24
25 assert(!script.cachedDataProduced || script.cachedData instanceof Buffer);
26
27 if (script.cachedDataProduced)
28 data = script.cachedData.toString('base64');
29 }
30 console.log(data);
31 `, source]);
32
33 assert.strictEqual(out.status, 0, String(out.stderr));
34
35 return Buffer.from(out.stdout.toString(), 'base64');
36}
37
38function testProduceConsume() {
39 const source = getSource('original');

Callers 5

testProduceConsumeFunction · 0.85
testProduceMultipleFunction · 0.85
testRejectInvalidFunction · 0.85
testRejectSliceFunction · 0.85
flowFunction · 0.85

Calls 4

StringClass · 0.85
spawnSyncFunction · 0.50
fromMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…