@decohere/core 0.0.1-dev.130 → 0.0.1-dev.20261105.103

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.
Files changed (56) hide show
  1. package/es6/src/system/index.js +1 -0
  2. package/es6/src/system/subject.js +34 -0
  3. package/package.json +11 -20
  4. package/types/src/system/index.d.ts +1 -0
  5. package/types/src/system/subject.d.ts +19 -0
  6. package/commonjs/src/caching/cache-manager.js +0 -98
  7. package/commonjs/src/caching/cache.decorator.js +0 -69
  8. package/commonjs/src/caching/cache.js +0 -6
  9. package/commonjs/src/caching/index.js +0 -23
  10. package/commonjs/src/caching/invalidate-cache.decorator.js +0 -92
  11. package/commonjs/src/caching/map-cache.js +0 -39
  12. package/commonjs/src/caching/memoize.decorator.js +0 -36
  13. package/commonjs/src/collections/collections.js +0 -21
  14. package/commonjs/src/collections/find-duplicates.js +0 -35
  15. package/commonjs/src/collections/index.js +0 -52
  16. package/commonjs/src/collections/merge-arrays.js +0 -34
  17. package/commonjs/src/collections/sum.js +0 -63
  18. package/commonjs/src/collections/unique-objects.js +0 -39
  19. package/commonjs/src/composition/index.js +0 -4
  20. package/commonjs/src/configuration/configuration.types.js +0 -11
  21. package/commonjs/src/configuration/index.js +0 -18
  22. package/commonjs/src/extensibility/decorator-factory-base.js +0 -22
  23. package/commonjs/src/extensibility/decorator-factory.js +0 -31
  24. package/commonjs/src/extensibility/extension.js +0 -37
  25. package/commonjs/src/extensibility/index.js +0 -23
  26. package/commonjs/src/extensibility/mixwith.js +0 -36
  27. package/commonjs/src/extensibility/pipeline.js +0 -56
  28. package/commonjs/src/extensibility/step.js +0 -18
  29. package/commonjs/src/io/copy-file.js +0 -25
  30. package/commonjs/src/io/delete-file.js +0 -21
  31. package/commonjs/src/io/directory-exists.js +0 -24
  32. package/commonjs/src/io/file-exists.js +0 -19
  33. package/commonjs/src/io/index.js +0 -66
  34. package/commonjs/src/io/io.js +0 -25
  35. package/commonjs/src/io/read-file.js +0 -39
  36. package/commonjs/src/io/remove-dir.js +0 -22
  37. package/commonjs/src/io/types/directory.type.js +0 -4
  38. package/commonjs/src/io/types/file.js +0 -28
  39. package/commonjs/src/io/types/index.js +0 -19
  40. package/commonjs/src/io/url-to-path.js +0 -33
  41. package/commonjs/src/io/write-file.js +0 -30
  42. package/commonjs/src/objects/deep-merge.js +0 -67
  43. package/commonjs/src/objects/index.js +0 -11
  44. package/commonjs/src/reflection/index.js +0 -20
  45. package/commonjs/src/reflection/types/index.js +0 -18
  46. package/commonjs/src/reflection/types/reflection.types.js +0 -25
  47. package/commonjs/src/reflection/utilities.js +0 -118
  48. package/commonjs/src/system/camel-case.js +0 -13
  49. package/commonjs/src/system/debounce.js +0 -19
  50. package/commonjs/src/system/decorator.js +0 -46
  51. package/commonjs/src/system/environment.js +0 -23
  52. package/commonjs/src/system/function.types.js +0 -18
  53. package/commonjs/src/system/index.js +0 -24
  54. package/commonjs/src/system/retry.decorator.js +0 -40
  55. package/commonjs/src/system/sleep.js +0 -13
  56. package/commonjs/src/system/type.utils.js +0 -4
@@ -4,4 +4,5 @@ export * from "./decorator.js";
4
4
  export * from "./environment.js";
5
5
  export * from "./function.types.js";
6
6
  export * from "./retry.decorator.js";
7
+ export * from "./subject.js";
7
8
  export * from "./type.utils.js";
@@ -0,0 +1,34 @@
1
+ /** A listener's handle: `unsubscribe` stops it receiving values. */ /**
2
+ * Sends each value to every current listener, synchronously and in subscription order.
3
+ * The part of rxjs's `Subject` the tools used, without loading rxjs on every start.
4
+ */ export class Subject {
5
+ #listeners = new Set();
6
+ subscribe(listener) {
7
+ // An entry per call, so the same function subscribed twice is two listeners.
8
+ const entry = {
9
+ listener
10
+ };
11
+ this.#listeners.add(entry);
12
+ return {
13
+ unsubscribe: ()=>this.#listeners.delete(entry)
14
+ };
15
+ }
16
+ /** Calls every listener; one that throws doesn't stop the rest, and its error is rethrown. */ next(value) {
17
+ const errors = [];
18
+ // A copy: a listener subscribed while this runs gets the next value, not this one.
19
+ for (const { listener } of Array.from(this.#listeners)){
20
+ try {
21
+ listener(value);
22
+ } catch (error) {
23
+ errors.push(error);
24
+ }
25
+ }
26
+ if (errors.length === 1) throw errors[0];
27
+ if (errors.length > 1) throw new AggregateError(errors, "Subject listeners threw");
28
+ }
29
+ asObservable() {
30
+ return {
31
+ subscribe: (listener)=>this.subscribe(listener)
32
+ };
33
+ }
34
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decohere/core",
3
- "version": "0.0.1-dev.130",
3
+ "version": "0.0.1-dev.20261105.103",
4
4
  "description": "The runtime base every Decohere package builds on: reflection, composition, configuration types, extensibility, collections, objects, caching on a Map, and basic file IO. No side effects on import.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -26,55 +26,46 @@
26
26
  "exports": {
27
27
  "./collections": {
28
28
  "types": "./types/src/collections/index.d.ts",
29
- "import": "./es6/src/collections/index.js",
30
- "require": "./commonjs/src/collections/index.js"
29
+ "import": "./es6/src/collections/index.js"
31
30
  },
32
31
  "./caching": {
33
32
  "types": "./types/src/caching/index.d.ts",
34
- "import": "./es6/src/caching/index.js",
35
- "require": "./commonjs/src/caching/index.js"
33
+ "import": "./es6/src/caching/index.js"
36
34
  },
37
35
  "./configuration": {
38
36
  "types": "./types/src/configuration/index.d.ts",
39
- "import": "./es6/src/configuration/index.js",
40
- "require": "./commonjs/src/configuration/index.js"
37
+ "import": "./es6/src/configuration/index.js"
41
38
  },
42
39
  "./extensibility": {
43
40
  "types": "./types/src/extensibility/index.d.ts",
44
- "import": "./es6/src/extensibility/index.js",
45
- "require": "./commonjs/src/extensibility/index.js"
41
+ "import": "./es6/src/extensibility/index.js"
46
42
  },
47
43
  "./io": {
48
44
  "types": "./types/src/io/index.d.ts",
49
- "import": "./es6/src/io/index.js",
50
- "require": "./commonjs/src/io/index.js"
45
+ "import": "./es6/src/io/index.js"
51
46
  },
52
47
  "./objects": {
53
48
  "types": "./types/src/objects/index.d.ts",
54
- "import": "./es6/src/objects/index.js",
55
- "require": "./commonjs/src/objects/index.js"
49
+ "import": "./es6/src/objects/index.js"
56
50
  },
57
51
  "./reflection": {
58
52
  "types": "./types/src/reflection/index.d.ts",
59
- "import": "./es6/src/reflection/index.js",
60
- "require": "./commonjs/src/reflection/index.js"
53
+ "import": "./es6/src/reflection/index.js"
61
54
  },
62
55
  "./system": {
63
56
  "types": "./types/src/system/index.d.ts",
64
- "import": "./es6/src/system/index.js",
65
- "require": "./commonjs/src/system/index.js"
57
+ "import": "./es6/src/system/index.js"
66
58
  },
67
59
  "./composition": {
68
60
  "types": "./types/src/composition/index.d.ts",
69
- "import": "./es6/src/composition/index.js",
70
- "require": "./commonjs/src/composition/index.js"
61
+ "import": "./es6/src/composition/index.js"
71
62
  }
72
63
  },
73
64
  "scripts": {
74
65
  "test": "echo \"Error: no test specified\" && exit 1"
75
66
  },
76
67
  "dependencies": {
77
- "@decohere/scribe": "0.0.1-dev.130",
68
+ "@decohere/scribe": "0.0.1-dev.20261105.103",
78
69
  "reflect-metadata": "^0.2.2"
79
70
  },
80
71
  "devDependencies": {}
@@ -4,4 +4,5 @@ export * from "./decorator.js";
4
4
  export * from "./environment.js";
5
5
  export * from "./function.types.js";
6
6
  export * from "./retry.decorator.js";
7
+ export * from "./subject.js";
7
8
  export * from "./type.utils.js";
@@ -0,0 +1,19 @@
1
+ /** A listener's handle: `unsubscribe` stops it receiving values. */
2
+ export type Subscription = {
3
+ unsubscribe(): void;
4
+ };
5
+ /** The listening side of a {@link Subject}: what a class exposes so callers can't emit. */
6
+ export type Observable<T> = {
7
+ subscribe(listener: (value: T) => void): Subscription;
8
+ };
9
+ /**
10
+ * Sends each value to every current listener, synchronously and in subscription order.
11
+ * The part of rxjs's `Subject` the tools used, without loading rxjs on every start.
12
+ */
13
+ export declare class Subject<T> implements Observable<T> {
14
+ #private;
15
+ subscribe(listener: (value: T) => void): Subscription;
16
+ /** Calls every listener; one that throws doesn't stop the rest, and its error is rethrown. */
17
+ next(value: T): void;
18
+ asObservable(): Observable<T>;
19
+ }
@@ -1,98 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get Caches () {
13
- return Caches;
14
- },
15
- get Caching () {
16
- return Caching;
17
- }
18
- });
19
- const _mapcache = require("./map-cache.js");
20
- const Caches = {
21
- default: "DEFAULT",
22
- memoize: "MEMOIZE_CACHE"
23
- };
24
- /**
25
- * Central cache manager for managing named cache instances
26
- */ class CacheManager {
27
- caches = new Map();
28
- defaultCacheName = Caches.default;
29
- /**
30
- * Set a cache instance with the given name
31
- * @param name - The name of the cache
32
- * @param cache - The cache instance
33
- */ setCache(name, cache) {
34
- this.caches.set(name, cache);
35
- }
36
- /**
37
- * Get a cache instance by name
38
- * @param name - The name of the cache, defaults to "DEFAULT"
39
- * @returns The cache instance
40
- */ getCache(name, memoize = false) {
41
- const cacheName = name ?? this.defaultCacheName;
42
- if (!this.caches.has(cacheName)) {
43
- const cache = new _mapcache.MapCache({
44
- memoize
45
- });
46
- this.caches.set(cacheName, cache);
47
- }
48
- return this.caches.get(cacheName);
49
- }
50
- /**
51
- * Clear a cache by name. If no name is provided, clears the default cache.
52
- * Note: This only works if the cache implements a clear() method.
53
- * @param name - The name of the cache to clear
54
- */ flush(name) {
55
- const cacheName = name ?? this.defaultCacheName;
56
- const cache = this.caches.get(cacheName);
57
- cache.flushAll();
58
- }
59
- flushAllCaches() {
60
- for (const [, cache] of this.caches){
61
- cache.flushAll();
62
- }
63
- }
64
- /**
65
- * Remove a cache instance by name
66
- * @param name - The name of the cache to remove
67
- */ removeCache(name) {
68
- this.caches.delete(name);
69
- }
70
- /**
71
- * Check if a cache with the given name exists
72
- * @param name - The name of the cache
73
- * @returns True if the cache exists, false otherwise
74
- */ hasCache(name) {
75
- return this.caches.has(name);
76
- }
77
- instanceIds = new WeakMap();
78
- instanceIdCounter = 0;
79
- /**
80
- * Generate a cache key for a given instance, function name, and arguments.
81
- * Each instance receives a stable numeric ID so cache entries are never
82
- * shared across instances of the same class.
83
- * @param instance - The class instance (`this` at call time)
84
- * @param functionName - The name of the decorated method
85
- * @param args - The method arguments
86
- * @returns A unique cache key string
87
- */ generateCacheKey(instance, functionName, args) {
88
- if (!this.instanceIds.has(instance)) {
89
- this.instanceIds.set(instance, ++this.instanceIdCounter);
90
- }
91
- const instanceId = this.instanceIds.get(instance);
92
- const argsStr = JSON.stringify({
93
- args
94
- }, (_key, val)=>typeof val === "function" ? `[Function:${val.name}]` : val);
95
- return `${instance.constructor.name}#${instanceId}|${functionName}|${argsStr}`;
96
- }
97
- }
98
- const Caching = new CacheManager();
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get CacheDecorator () {
13
- return CacheDecorator;
14
- },
15
- get cache () {
16
- return cache;
17
- }
18
- });
19
- const _types = require("node:util/types");
20
- const _decorator = require("../system/decorator.js");
21
- const _cachemanager = require("./cache-manager.js");
22
- function _ts_decorate(decorators, target, key, desc) {
23
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
24
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
25
- else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
26
- return c > 3 && r && Object.defineProperty(target, key, r), r;
27
- }
28
- function _ts_metadata(k, v) {
29
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
30
- }
31
- class CacheDecorator extends _decorator.FunctionDecorator {
32
- decorator(_target, propertyKey, descriptor) {
33
- const cacheInstance = this.options?.cache ?? _cachemanager.Caching.getCache(this.options?.name);
34
- const keyFn = this.options?.keyFn;
35
- const originalMethod = descriptor.value;
36
- const wrapped = function(...args) {
37
- const cacheKey = keyFn ? keyFn(...args) : _cachemanager.Caching.generateCacheKey(this, propertyKey, args);
38
- if (cacheInstance.has(cacheKey)) {
39
- const val = cacheInstance.get(cacheKey);
40
- return val;
41
- }
42
- const resultOrPromise = originalMethod.apply(this, args);
43
- if ((0, _types.isPromise)(resultOrPromise)) {
44
- resultOrPromise.then((result)=>{
45
- cacheInstance.set(cacheKey, result);
46
- }, ()=>{
47
- /* rejection propagates via the returned promise */ });
48
- } else {
49
- cacheInstance.set(cacheKey, resultOrPromise);
50
- }
51
- return resultOrPromise;
52
- };
53
- Object.defineProperty(wrapped, "name", {
54
- value: propertyKey
55
- });
56
- descriptor.value = wrapped;
57
- }
58
- }
59
- _ts_decorate([
60
- (0, _decorator.ignoreIf)("FORGE_DISABLE_CACHE"),
61
- _ts_metadata("design:type", Function),
62
- _ts_metadata("design:paramtypes", [
63
- Object,
64
- String,
65
- typeof PropertyDescriptor === "undefined" ? Object : PropertyDescriptor
66
- ]),
67
- _ts_metadata("design:returntype", void 0)
68
- ], CacheDecorator.prototype, "decorator", null);
69
- const cache = new CacheDecorator().decoratorFactory;
@@ -1,6 +0,0 @@
1
- /**
2
- * Interface for cache implementations used by the @cache() decorator
3
- */ "use strict";
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- _export_star(require("./cache.decorator.js"), exports);
6
- _export_star(require("./cache.js"), exports);
7
- _export_star(require("./cache-manager.js"), exports);
8
- _export_star(require("./invalidate-cache.decorator.js"), exports);
9
- _export_star(require("./memoize.decorator.js"), exports);
10
- _export_star(require("./map-cache.js"), exports);
11
- function _export_star(from, to) {
12
- Object.keys(from).forEach(function(k) {
13
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
14
- Object.defineProperty(to, k, {
15
- enumerable: true,
16
- get: function() {
17
- return from[k];
18
- }
19
- });
20
- }
21
- });
22
- return from;
23
- }
@@ -1,92 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get InvalidateCacheDecorator () {
13
- return InvalidateCacheDecorator;
14
- },
15
- get invalidateCache () {
16
- return invalidateCache;
17
- },
18
- get invalidateMemoize () {
19
- return invalidateMemoize;
20
- }
21
- });
22
- const _types = require("node:util/types");
23
- const _decorator = require("../system/decorator.js");
24
- const _cachemanager = require("./cache-manager.js");
25
- function _ts_decorate(decorators, target, key, desc) {
26
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
27
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
28
- else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
29
- return c > 3 && r && Object.defineProperty(target, key, r), r;
30
- }
31
- function _ts_metadata(k, v) {
32
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
- }
34
- class InvalidateCacheDecorator extends _decorator.FunctionDecorator {
35
- decorator(_target, _propertyKey, descriptor) {
36
- const { getKey, cache, name } = this.options;
37
- const cacheInstance = cache ?? _cachemanager.Caching.getCache(name);
38
- const originalMethod = descriptor.value;
39
- descriptor.value = function(...args) {
40
- const resultOrPromise = originalMethod.apply(this, args);
41
- const evict = ()=>{
42
- const key = getKey(this, args);
43
- cacheInstance.del(key);
44
- };
45
- if ((0, _types.isPromise)(resultOrPromise)) {
46
- resultOrPromise.then(evict);
47
- } else {
48
- evict();
49
- }
50
- return resultOrPromise;
51
- };
52
- }
53
- }
54
- _ts_decorate([
55
- (0, _decorator.ignoreIf)("FORGE_DISABLE_CACHE"),
56
- _ts_metadata("design:type", Function),
57
- _ts_metadata("design:paramtypes", [
58
- Object,
59
- String,
60
- typeof PropertyDescriptor === "undefined" ? Object : PropertyDescriptor
61
- ]),
62
- _ts_metadata("design:returntype", void 0)
63
- ], InvalidateCacheDecorator.prototype, "decorator", null);
64
- const buildGetKey = (method, keyFn)=>{
65
- if (typeof method === "string") return ()=>method;
66
- if (keyFn) return (_instance, args)=>keyFn(...args);
67
- return (instance, args)=>_cachemanager.Caching.generateCacheKey(instance, method.name, args);
68
- };
69
- const invalidateCache = (method, options)=>{
70
- const cache = options?.cache ?? _cachemanager.Caching.getCache(options?.name);
71
- return new InvalidateCacheDecorator().decoratorFactory({
72
- getKey: buildGetKey(method, options?.keyFn),
73
- ...options,
74
- cache
75
- });
76
- };
77
- invalidateCache.evict = (instance, method, args = [])=>{
78
- const key = _cachemanager.Caching.generateCacheKey(instance, method.name, args);
79
- _cachemanager.Caching.getCache().del(key);
80
- };
81
- const invalidateMemoize = (method, options)=>{
82
- const cache = options?.cache ?? _cachemanager.Caching.getCache(options?.name ?? _cachemanager.Caches.memoize, true);
83
- return new InvalidateCacheDecorator().decoratorFactory({
84
- getKey: buildGetKey(method),
85
- ...options,
86
- cache
87
- });
88
- };
89
- invalidateMemoize.evict = (instance, method, args = [])=>{
90
- const key = _cachemanager.Caching.generateCacheKey(instance, method.name, args);
91
- _cachemanager.Caching.getCache(_cachemanager.Caches.memoize, true).del(key);
92
- };
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "MapCache", {
6
- enumerable: true,
7
- get: function() {
8
- return MapCache;
9
- }
10
- });
11
- class MapCache {
12
- #entries = new Map();
13
- #memoize;
14
- constructor(options = {}){
15
- this.#memoize = options.memoize ?? false;
16
- }
17
- get isMemoize() {
18
- return this.#memoize;
19
- }
20
- get(key) {
21
- const value = this.#entries.get(key);
22
- if (this.#memoize || value === null || typeof value !== "object") {
23
- return value;
24
- }
25
- return structuredClone(value);
26
- }
27
- set(key, value) {
28
- this.#entries.set(key, value);
29
- }
30
- has(key) {
31
- return this.#entries.has(key);
32
- }
33
- del(key) {
34
- this.#entries.delete(key);
35
- }
36
- flushAll() {
37
- this.#entries.clear();
38
- }
39
- }
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get MemoizeDecorator () {
13
- return MemoizeDecorator;
14
- },
15
- get memoize () {
16
- return memoize;
17
- }
18
- });
19
- const _cachedecorator = require("./cache.decorator.js");
20
- const _cachemanager = require("./cache-manager.js");
21
- class MemoizeDecorator extends _cachedecorator.CacheDecorator {
22
- decorator(target, propertyKey, descriptor) {
23
- const cache = this.options?.cache ?? _cachemanager.Caching.getCache(this.options?.name ?? _cachemanager.Caches.memoize, true);
24
- if (!cache.isMemoize) {
25
- throw new Error("Memoize decorator requires a cache that supports memoization (stores references, not clones)");
26
- }
27
- // Pass the resolved cache to the base class by updating options
28
- // This ensures the base class uses CacheNames.memoize when no cache was provided
29
- this.options = {
30
- ...this.options,
31
- cache
32
- };
33
- return super.decorator(target, propertyKey, descriptor);
34
- }
35
- }
36
- const memoize = new MemoizeDecorator().decoratorFactory;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- _export_star(require("./find-duplicates.js"), exports);
6
- _export_star(require("./merge-arrays.js"), exports);
7
- _export_star(require("./sum.js"), exports);
8
- _export_star(require("./unique-objects.js"), exports);
9
- function _export_star(from, to) {
10
- Object.keys(from).forEach(function(k) {
11
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
12
- Object.defineProperty(to, k, {
13
- enumerable: true,
14
- get: function() {
15
- return from[k];
16
- }
17
- });
18
- }
19
- });
20
- return from;
21
- }
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get findDuplicatesBy () {
13
- return findDuplicatesBy;
14
- },
15
- get findDuplicatesByKey () {
16
- return findDuplicatesByKey;
17
- }
18
- });
19
- function findDuplicatesByKey(items, key) {
20
- return findDuplicatesBy(items, (item)=>String(item[key]));
21
- }
22
- function findDuplicatesBy(items, selector) {
23
- const groups = new Map();
24
- for (const item of items){
25
- const k = selector(item);
26
- const existing = groups.get(k) ?? [];
27
- groups.set(k, [
28
- ...existing,
29
- item
30
- ]);
31
- }
32
- return [
33
- ...groups.entries()
34
- ].filter(([, group])=>group.length > 1);
35
- }
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "collections", {
6
- enumerable: true,
7
- get: function() {
8
- return _collections;
9
- }
10
- });
11
- const _collections = /*#__PURE__*/ _interop_require_wildcard(require("./collections.js"));
12
- function _getRequireWildcardCache(nodeInterop) {
13
- if (typeof WeakMap !== "function") return null;
14
- var cacheBabelInterop = new WeakMap();
15
- var cacheNodeInterop = new WeakMap();
16
- return (_getRequireWildcardCache = function(nodeInterop) {
17
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
18
- })(nodeInterop);
19
- }
20
- function _interop_require_wildcard(obj, nodeInterop) {
21
- if (!nodeInterop && obj && obj.__esModule) {
22
- return obj;
23
- }
24
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
25
- return {
26
- default: obj
27
- };
28
- }
29
- var cache = _getRequireWildcardCache(nodeInterop);
30
- if (cache && cache.has(obj)) {
31
- return cache.get(obj);
32
- }
33
- var newObj = {
34
- __proto__: null
35
- };
36
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
37
- for(var key in obj){
38
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
39
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
40
- if (desc && (desc.get || desc.set)) {
41
- Object.defineProperty(newObj, key, desc);
42
- } else {
43
- newObj[key] = obj[key];
44
- }
45
- }
46
- }
47
- newObj.default = obj;
48
- if (cache) {
49
- cache.set(obj, newObj);
50
- }
51
- return newObj;
52
- }
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get mergeBy () {
13
- return mergeBy;
14
- },
15
- get mergeByKey () {
16
- return mergeByKey;
17
- }
18
- });
19
- function mergeByKey(first, second, key) {
20
- return mergeBy(first, second, (item)=>String(item[key]));
21
- }
22
- function mergeBy(first, second, selector) {
23
- // Second collection values win when keys collide.
24
- const merged = [
25
- ...first,
26
- ...second
27
- ];
28
- return [
29
- ...new Map(merged.map((item)=>[
30
- selector(item),
31
- item
32
- ])).values()
33
- ];
34
- }