gingersnap 0.26.2 → 0.26.4
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/data/model/model.cjs +21 -5
- package/data/model/model.d.ts +7 -1
- package/data/model/model.mjs +21 -5
- package/files.cjs +2 -1
- package/files.mjs +2 -2
- package/package.json +1 -1
package/data/model/model.cjs
CHANGED
|
@@ -262,12 +262,28 @@ class Model {
|
|
|
262
262
|
csv(options, config) {
|
|
263
263
|
return Papa.unparse([this.object(options)], config);
|
|
264
264
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
265
|
+
/**
|
|
266
|
+
* Creates a deep copy of the current model instance with optional field overrides
|
|
267
|
+
* @param changes optional field values to override in the cloned model, or a function that receives the deep copied
|
|
268
|
+
* data and returns the modified data
|
|
269
|
+
* @returns a new model instance with the same values as the original, with any specified changes applied
|
|
270
|
+
*/
|
|
271
|
+
clone(changes) {
|
|
272
|
+
let jsonPayload;
|
|
273
|
+
const copy = this.object({ keepOptionals: false, removeMissingFields: true });
|
|
274
|
+
if (changes === undefined) {
|
|
275
|
+
jsonPayload = copy;
|
|
276
|
+
}
|
|
277
|
+
else if (typeof changes === "function") {
|
|
278
|
+
jsonPayload = changes(copy);
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
for (const key in changes) {
|
|
282
|
+
copy[key] = changes[key];
|
|
283
|
+
}
|
|
284
|
+
jsonPayload = copy;
|
|
269
285
|
}
|
|
270
|
-
return
|
|
286
|
+
return Object.getPrototypeOf(this).constructor.fromJSON(jsonPayload);
|
|
271
287
|
}
|
|
272
288
|
/**
|
|
273
289
|
* Retrieves the schema of the current model based on the selected format
|
package/data/model/model.d.ts
CHANGED
|
@@ -204,7 +204,13 @@ export declare class Model {
|
|
|
204
204
|
* @returns csv string
|
|
205
205
|
*/
|
|
206
206
|
csv(options?: ModelExportOptions, config?: Papa.UnparseConfig): string;
|
|
207
|
-
|
|
207
|
+
/**
|
|
208
|
+
* Creates a deep copy of the current model instance with optional field overrides
|
|
209
|
+
* @param changes optional field values to override in the cloned model, or a function that receives the deep copied
|
|
210
|
+
* data and returns the modified data
|
|
211
|
+
* @returns a new model instance with the same values as the original, with any specified changes applied
|
|
212
|
+
*/
|
|
213
|
+
clone(changes?: Record<string, any> | ((prev: Record<string, any>) => Record<string, any>)): typeof this;
|
|
208
214
|
/**
|
|
209
215
|
* Retrieves the schema of the current model based on the selected format
|
|
210
216
|
* @param includeTitleAndDraft boolean whether the title and JSON schema draft version should be referenced in the schema
|
package/data/model/model.mjs
CHANGED
|
@@ -241,12 +241,28 @@ class Model {
|
|
|
241
241
|
csv(options, config) {
|
|
242
242
|
return Papa.unparse([this.object(options)], config);
|
|
243
243
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
244
|
+
/**
|
|
245
|
+
* Creates a deep copy of the current model instance with optional field overrides
|
|
246
|
+
* @param changes optional field values to override in the cloned model, or a function that receives the deep copied
|
|
247
|
+
* data and returns the modified data
|
|
248
|
+
* @returns a new model instance with the same values as the original, with any specified changes applied
|
|
249
|
+
*/
|
|
250
|
+
clone(changes) {
|
|
251
|
+
let jsonPayload;
|
|
252
|
+
const copy = this.object({ keepOptionals: false, removeMissingFields: true });
|
|
253
|
+
if (changes === undefined) {
|
|
254
|
+
jsonPayload = copy;
|
|
255
|
+
}
|
|
256
|
+
else if (typeof changes === "function") {
|
|
257
|
+
jsonPayload = changes(copy);
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
for (const key in changes) {
|
|
261
|
+
copy[key] = changes[key];
|
|
262
|
+
}
|
|
263
|
+
jsonPayload = copy;
|
|
248
264
|
}
|
|
249
|
-
return
|
|
265
|
+
return Object.getPrototypeOf(this).constructor.fromJSON(jsonPayload);
|
|
250
266
|
}
|
|
251
267
|
/**
|
|
252
268
|
* Retrieves the schema of the current model based on the selected format
|
package/files.cjs
CHANGED
|
@@ -30,6 +30,7 @@ function _interopNamespaceDefault(e) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
var readline__namespace = /*#__PURE__*/_interopNamespaceDefault(readline);
|
|
33
|
+
var R__namespace = /*#__PURE__*/_interopNamespaceDefault(R);
|
|
33
34
|
|
|
34
35
|
class Files {
|
|
35
36
|
static watch(source, { objectMaxSize, expiryPeriod }) {
|
|
@@ -186,7 +187,7 @@ class Files {
|
|
|
186
187
|
}));
|
|
187
188
|
}
|
|
188
189
|
static watchData(source, { objectMaxSize, expiryPeriod, encoding }) {
|
|
189
|
-
const getQueue =
|
|
190
|
+
const getQueue = R__namespace.once((signal) => {
|
|
190
191
|
const queue = new Queue.Queue(objectMaxSize, expiryPeriod);
|
|
191
192
|
fs.watch(source, { recursive: true, persistent: true, signal, encoding }, (v) => queue.enqueue(v));
|
|
192
193
|
return queue;
|
package/files.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import fs from 'fs';
|
|
|
3
3
|
import * as readline from 'readline';
|
|
4
4
|
import { Stream } from './stream.mjs';
|
|
5
5
|
import { Future } from './future/future.mjs';
|
|
6
|
-
import
|
|
6
|
+
import * as R from 'ramda';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import './data-structures/object/WatchableObject.mjs';
|
|
9
9
|
import 'object-hash';
|
|
@@ -165,7 +165,7 @@ class Files {
|
|
|
165
165
|
}));
|
|
166
166
|
}
|
|
167
167
|
static watchData(source, { objectMaxSize, expiryPeriod, encoding }) {
|
|
168
|
-
const getQueue =
|
|
168
|
+
const getQueue = R.once((signal) => {
|
|
169
169
|
const queue = new Queue(objectMaxSize, expiryPeriod);
|
|
170
170
|
fs.watch(source, { recursive: true, persistent: true, signal, encoding }, (v) => queue.enqueue(v));
|
|
171
171
|
return queue;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"gingersnap","version":"0.26.
|
|
1
|
+
{"name":"gingersnap","version":"0.26.4","description":"A general purpose library built with the aim of filling the gaps of javascript shortcomings","dependencies":{"@msgpack/msgpack":"^3.0.0-beta2","browser-or-node":"^3.0.0-pre.0","modern-isomorphic-ws":"^1.0.5","object-hash":"^3.0.0","papaparse":"^5.4.1","protobufjs":"^7.2.6","ramda":"^0.30.1","reflect-metadata":"^0.2.2","tslib":"^2.6.3","uuid":"^9.0.1","ws":"^8.16.0","x2js":"^3.4.4"},"author":"CookieNerds LLC","exports":{"./synchronize":{"import":{"types":"./synchronize.d.ts","default":"./synchronize.mjs"},"require":{"types":"./synchronize.d.ts","default":"./synchronize.cjs"}},"./mocks":{"import":{"types":"./mocks.d.ts","default":"./mocks.mjs"},"require":{"types":"./mocks.d.ts","default":"./mocks.cjs"}},"./socket":{"import":{"types":"./socket.d.ts","default":"./socket.mjs"},"require":{"types":"./socket.d.ts","default":"./socket.cjs"}},"./typing/types":{"import":{"types":"./typing/types.d.ts","default":"./typing/types.mjs"},"require":{"types":"./typing/types.d.ts","default":"./typing/types.cjs"}},"./stream":{"import":{"types":"./stream/index.d.ts","default":"./stream.mjs"},"require":{"types":"./stream/index.d.ts","default":"./stream.cjs"}},"./reflection/injector":{"import":{"types":"./reflection/injector.d.ts","default":"./reflection/injector.mjs"},"require":{"types":"./reflection/injector.d.ts","default":"./reflection/injector.cjs"}},"./stream/call":{"import":{"types":"./stream/call.d.ts","default":"./stream/call.mjs"},"require":{"types":"./stream/call.d.ts","default":"./stream/call.cjs"}},"./stream/state":{"import":{"types":"./stream/state.d.ts","default":"./stream/state.mjs"},"require":{"types":"./stream/state.d.ts","default":"./stream/state.cjs"}},"./stream/collector":{"import":{"types":"./stream/collector.d.ts","default":"./stream/collector.mjs"},"require":{"types":"./stream/collector.d.ts","default":"./stream/collector.cjs"}},"./stream/observable":{"import":{"types":"./stream/observable.d.ts","default":"./stream/observable.mjs"},"require":{"types":"./stream/observable.d.ts","default":"./stream/observable.cjs"}},"./networking":{"import":{"types":"./networking/index.d.ts","default":"./networking.mjs"},"require":{"types":"./networking/index.d.ts","default":"./networking.cjs"}},"./managers":{"import":{"types":"./managers/index.d.ts","default":"./managers.mjs"},"require":{"types":"./managers/index.d.ts","default":"./managers.cjs"}},"./future":{"import":{"types":"./future/index.d.ts","default":"./future.mjs"},"require":{"types":"./future/index.d.ts","default":"./future.cjs"}},"./errors":{"import":{"types":"./errors/index.d.ts","default":"./errors.mjs"},"require":{"types":"./errors/index.d.ts","default":"./errors.cjs"}},"./data-structures/array":{"import":{"types":"./data-structures/array/index.d.ts","default":"./data-structures/array.mjs"},"require":{"types":"./data-structures/array/index.d.ts","default":"./data-structures/array.cjs"}},"./data-structures/object":{"import":{"types":"./data-structures/object/index.d.ts","default":"./data-structures/object.mjs"},"require":{"types":"./data-structures/object/index.d.ts","default":"./data-structures/object.cjs"}},"./data/decoders":{"import":{"types":"./data/decoders/index.d.ts","default":"./data/decoders.mjs"},"require":{"types":"./data/decoders/index.d.ts","default":"./data/decoders.cjs"}},"./data/model":{"import":{"types":"./data/model/index.d.ts","default":"./data/model.mjs"},"require":{"types":"./data/model/index.d.ts","default":"./data/model.cjs"}},"./data/bus":{"import":{"types":"./data/bus.d.ts","default":"./data/bus.mjs"},"require":{"types":"./data/bus.d.ts","default":"./data/bus.cjs"}},"./data/AtomicValue":{"import":{"types":"./data/AtomicValue.d.ts","default":"./data/AtomicValue.mjs"},"require":{"types":"./data/AtomicValue.d.ts","default":"./data/AtomicValue.cjs"}},"./data/store":{"import":{"types":"./data/store/index.d.ts","default":"./data/store.mjs"},"require":{"types":"./data/store/index.d.ts","default":"./data/store.cjs"}},"./functools":{"import":{"types":"./functools/index.d.ts","default":"./functools.mjs"},"require":{"types":"./functools/index.d.ts","default":"./functools.cjs"}},"./files":{"import":{"types":"./files.d.ts","default":"./files.mjs"},"require":{"types":"./files.d.ts","default":"./files.cjs"}}}}
|