1 | import OBJ from 'dot-prop';
|
2 |
|
3 | export function writeTo(stream, data, cb) {
|
4 | if (!stream.write(data)) {
|
5 | stream.once('drain', cb);
|
6 | } else {
|
7 | process.nextTick(cb);
|
8 | }
|
9 | }
|
10 |
|
11 | export function newValue(value, path, data) {
|
12 | if (path === undefined) {
|
13 | return value;
|
14 | }
|
15 | if (typeof data === 'object') {
|
16 | const out = {
|
17 | ...data,
|
18 | };
|
19 | OBJ.set(out, path, value);
|
20 | return out;
|
21 | }
|
22 | const out = {};
|
23 | OBJ.set(out, path, value);
|
24 | return out;
|
25 | }
|