@graffy/core 0.15.11 → 0.15.13-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +9 -8
- package/index.mjs +9 -8
- package/package.json +3 -3
package/index.cjs
CHANGED
|
@@ -114,28 +114,28 @@ function shiftGen(fn, path) {
|
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
const log = debug__default["default"]("graffy:core");
|
|
117
|
-
function resolve(handlers, firstPayload,
|
|
117
|
+
function resolve(handlers, firstPayload, firstOptions) {
|
|
118
118
|
if (!handlers || !handlers.length)
|
|
119
119
|
throw Error("resolve.no_provider");
|
|
120
|
-
function run(i, payload) {
|
|
120
|
+
function run(i, payload, options) {
|
|
121
121
|
if (i >= handlers.length) {
|
|
122
122
|
throw Error("resolve.no_providers_for " + JSON.stringify(payload));
|
|
123
123
|
}
|
|
124
124
|
const { path, handle } = handlers[i];
|
|
125
125
|
if (!common.unwrap(payload, path))
|
|
126
|
-
return run(i + 1, payload);
|
|
126
|
+
return run(i + 1, payload, options);
|
|
127
127
|
let nextCalled = false;
|
|
128
|
-
return handle(payload, options, (nextPayload) => {
|
|
128
|
+
return handle(payload, options, (nextPayload, nextOptions) => {
|
|
129
129
|
if (nextCalled) {
|
|
130
130
|
throw Error("resolve.duplicate_next_call: " + handlers[i].name);
|
|
131
131
|
}
|
|
132
132
|
nextCalled = true;
|
|
133
133
|
if (typeof nextPayload === "undefined" || !nextPayload.length)
|
|
134
134
|
return;
|
|
135
|
-
return run(i + 1, nextPayload);
|
|
135
|
+
return run(i + 1, nextPayload, nextOptions || options);
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
return run(0, firstPayload);
|
|
138
|
+
return run(0, firstPayload, firstOptions);
|
|
139
139
|
}
|
|
140
140
|
class Core {
|
|
141
141
|
constructor() {
|
|
@@ -199,7 +199,8 @@ class Graffy {
|
|
|
199
199
|
}, path));
|
|
200
200
|
}
|
|
201
201
|
use(...args) {
|
|
202
|
-
const [
|
|
202
|
+
const [pathArg, provider] = validateOn(...args);
|
|
203
|
+
const path = this.path.concat(pathArg);
|
|
203
204
|
provider(new Graffy(path, this.core));
|
|
204
205
|
}
|
|
205
206
|
call(type, payload, options = {}) {
|
|
@@ -221,7 +222,7 @@ class Graffy {
|
|
|
221
222
|
}
|
|
222
223
|
async write(...args) {
|
|
223
224
|
const [path, porcelainChange, options] = validateCall(...args);
|
|
224
|
-
const change = common.
|
|
225
|
+
const change = common.encodeGraph(common.wrapObject(porcelainChange, path));
|
|
225
226
|
const writtenChange = await this.core.call("write", change, options || {});
|
|
226
227
|
return common.unwrapObject(common.decodeGraph(writtenChange), common.decodePath(path));
|
|
227
228
|
}
|
package/index.mjs
CHANGED
|
@@ -109,28 +109,28 @@ function shiftGen(fn, path) {
|
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
const log = debug("graffy:core");
|
|
112
|
-
function resolve(handlers, firstPayload,
|
|
112
|
+
function resolve(handlers, firstPayload, firstOptions) {
|
|
113
113
|
if (!handlers || !handlers.length)
|
|
114
114
|
throw Error("resolve.no_provider");
|
|
115
|
-
function run(i, payload) {
|
|
115
|
+
function run(i, payload, options) {
|
|
116
116
|
if (i >= handlers.length) {
|
|
117
117
|
throw Error("resolve.no_providers_for " + JSON.stringify(payload));
|
|
118
118
|
}
|
|
119
119
|
const { path, handle } = handlers[i];
|
|
120
120
|
if (!unwrap(payload, path))
|
|
121
|
-
return run(i + 1, payload);
|
|
121
|
+
return run(i + 1, payload, options);
|
|
122
122
|
let nextCalled = false;
|
|
123
|
-
return handle(payload, options, (nextPayload) => {
|
|
123
|
+
return handle(payload, options, (nextPayload, nextOptions) => {
|
|
124
124
|
if (nextCalled) {
|
|
125
125
|
throw Error("resolve.duplicate_next_call: " + handlers[i].name);
|
|
126
126
|
}
|
|
127
127
|
nextCalled = true;
|
|
128
128
|
if (typeof nextPayload === "undefined" || !nextPayload.length)
|
|
129
129
|
return;
|
|
130
|
-
return run(i + 1, nextPayload);
|
|
130
|
+
return run(i + 1, nextPayload, nextOptions || options);
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
-
return run(0, firstPayload);
|
|
133
|
+
return run(0, firstPayload, firstOptions);
|
|
134
134
|
}
|
|
135
135
|
class Core {
|
|
136
136
|
constructor() {
|
|
@@ -194,7 +194,8 @@ class Graffy {
|
|
|
194
194
|
}, path));
|
|
195
195
|
}
|
|
196
196
|
use(...args) {
|
|
197
|
-
const [
|
|
197
|
+
const [pathArg, provider] = validateOn(...args);
|
|
198
|
+
const path = this.path.concat(pathArg);
|
|
198
199
|
provider(new Graffy(path, this.core));
|
|
199
200
|
}
|
|
200
201
|
call(type, payload, options = {}) {
|
|
@@ -216,7 +217,7 @@ class Graffy {
|
|
|
216
217
|
}
|
|
217
218
|
async write(...args) {
|
|
218
219
|
const [path, porcelainChange, options] = validateCall(...args);
|
|
219
|
-
const change =
|
|
220
|
+
const change = encodeGraph(wrapObject(porcelainChange, path));
|
|
220
221
|
const writtenChange = await this.core.call("write", change, options || {});
|
|
221
222
|
return unwrapObject(decodeGraph(writtenChange), decodePath(path));
|
|
222
223
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graffy/core",
|
|
3
3
|
"description": "The main module for Graffy, a library for intuitive real-time data APIs.",
|
|
4
4
|
"author": "aravind (https://github.com/aravindet)",
|
|
5
|
-
"version": "0.15.
|
|
5
|
+
"version": "0.15.13-alpha.1",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
7
|
"exports": {
|
|
8
8
|
"import": "./index.mjs",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"license": "Apache-2.0",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@graffy/common": "0.15.
|
|
20
|
-
"@graffy/stream": "0.15.
|
|
19
|
+
"@graffy/common": "0.15.13-alpha.1",
|
|
20
|
+
"@graffy/stream": "0.15.13-alpha.1",
|
|
21
21
|
"debug": "^4.3.2"
|
|
22
22
|
}
|
|
23
23
|
}
|