@e-mc/types 0.9.5 → 0.9.6
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/README.md +3 -3
- package/constant.d.ts +1 -1
- package/index.d.ts +1 -1
- package/index.js +85 -38
- package/lib/index.d.ts +3 -3
- package/lib/module.d.ts +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.9.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.9.6/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { LogArguments } from "./lib/logger";
|
|
@@ -194,8 +194,8 @@ const IMPORT_MAP: Record<string, string | undefined>;
|
|
|
194
194
|
|
|
195
195
|
## References
|
|
196
196
|
|
|
197
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
198
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
197
|
+
- https://www.unpkg.com/@e-mc/types@0.9.6/lib/logger.d.ts
|
|
198
|
+
- https://www.unpkg.com/@e-mc/types@0.9.6/lib/module.d.ts
|
|
199
199
|
|
|
200
200
|
* https://nodejs.org/api/perf_hooks.html
|
|
201
201
|
* https://www.npmjs.com/package/@types/bytes
|
package/constant.d.ts
CHANGED
package/index.d.ts
CHANGED
|
@@ -311,7 +311,7 @@ declare namespace types {
|
|
|
311
311
|
function getEncoding(value: unknown, fallback?: BufferEncoding): BufferEncoding;
|
|
312
312
|
function encryptUTF8(algorithm: CipherGCMTypes, key: BinaryLike, iv: BinaryLike, data: string, encoding?: Encoding): Undef<string>;
|
|
313
313
|
function decryptUTF8(algorithm: CipherGCMTypes, key: BinaryLike, iv: BinaryLike, data: string, encoding?: Encoding): Undef<string>;
|
|
314
|
-
|
|
314
|
+
/** @deprecated crypto.randomUUID */
|
|
315
315
|
function generateUUID(): string;
|
|
316
316
|
function incrementUUID(restart?: boolean): string;
|
|
317
317
|
function validateUUID(value: unknown): boolean;
|
package/index.js
CHANGED
|
@@ -145,6 +145,63 @@ function recurseObject(data, parseString, completed, cache) {
|
|
|
145
145
|
}
|
|
146
146
|
return data;
|
|
147
147
|
}
|
|
148
|
+
function mergedArray(target, attr, data, type) {
|
|
149
|
+
const prop = target[attr];
|
|
150
|
+
if (type && Array.isArray(prop) && Array.isArray(data)) {
|
|
151
|
+
let arg1, arg2;
|
|
152
|
+
if (Array.isArray(type)) {
|
|
153
|
+
[type, arg1, arg2] = type;
|
|
154
|
+
}
|
|
155
|
+
switch (type) {
|
|
156
|
+
case 'concat':
|
|
157
|
+
target[attr] = prop.concat(data);
|
|
158
|
+
break;
|
|
159
|
+
case 'concat-pre':
|
|
160
|
+
target[attr] = data.concat(prop);
|
|
161
|
+
break;
|
|
162
|
+
case 'push':
|
|
163
|
+
case 'unshift':
|
|
164
|
+
case 'includes':
|
|
165
|
+
for (let i = 0, length = data.length; i < length; ++i) {
|
|
166
|
+
if (type !== 'includes' || !prop.includes(data[i])) {
|
|
167
|
+
prop[type](data[i]);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
break;
|
|
171
|
+
case 'flat':
|
|
172
|
+
target[attr] = data.flat(arg1);
|
|
173
|
+
case 'join':
|
|
174
|
+
target[attr] = data.join(arg1);
|
|
175
|
+
break;
|
|
176
|
+
case 'slice':
|
|
177
|
+
target[attr] = data.slice(arg1, arg2);
|
|
178
|
+
break;
|
|
179
|
+
case 'reverse':
|
|
180
|
+
target[attr] = data.slice(0).reverse();
|
|
181
|
+
break;
|
|
182
|
+
default:
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
function getProperties(obj, inherited, nonenumerable, symbol) {
|
|
190
|
+
let attrs;
|
|
191
|
+
if (inherited === false) {
|
|
192
|
+
attrs = nonenumerable ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
attrs = [];
|
|
196
|
+
for (const attr in obj) {
|
|
197
|
+
attrs.push(attr);
|
|
198
|
+
}
|
|
199
|
+
if (nonenumerable) {
|
|
200
|
+
attrs = Array.from(new Set(attrs.concat(Object.getOwnPropertyNames(obj))));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return symbol ? attrs.concat(Object.getOwnPropertySymbols(obj)) : attrs;
|
|
204
|
+
}
|
|
148
205
|
const convertScrypt = (key, iv, data) => crypto.scryptSync(key, iv, Math.ceil(data.length / 16) * 16);
|
|
149
206
|
const isFunction = (value) => typeof value === 'function';
|
|
150
207
|
var LOG_TYPE;
|
|
@@ -653,7 +710,7 @@ function cascadeObject(data, query, fallback) {
|
|
|
653
710
|
}
|
|
654
711
|
exports.cascadeObject = cascadeObject;
|
|
655
712
|
function cloneObject(data, options) {
|
|
656
|
-
let target, deep, deepIgnore, typedArray, inherited, nonenumerable, symbol, preserve;
|
|
713
|
+
let target, deep, deepIgnore, mergeArray, mergeDepth = Infinity, typedArray, inherited, nonenumerable, symbol, preserve;
|
|
657
714
|
if (options === true) {
|
|
658
715
|
deep = true;
|
|
659
716
|
}
|
|
@@ -662,23 +719,30 @@ function cloneObject(data, options) {
|
|
|
662
719
|
deepIgnore = options;
|
|
663
720
|
}
|
|
664
721
|
else if (options) {
|
|
665
|
-
({ target, deep, deepIgnore, typedArray, inherited, nonenumerable, symbol, preserve } = options);
|
|
722
|
+
({ target, deep, deepIgnore, mergeArray, typedArray, inherited, nonenumerable, symbol, preserve } = options);
|
|
723
|
+
if (options.mergeDepth !== undefined) {
|
|
724
|
+
mergeDepth = options.mergeDepth - 1;
|
|
725
|
+
}
|
|
666
726
|
}
|
|
667
727
|
let nested;
|
|
668
728
|
if (deep) {
|
|
669
729
|
deepIgnore || (deepIgnore = new WeakSet());
|
|
670
|
-
nested = { deep, deepIgnore, typedArray, preserve };
|
|
730
|
+
nested = { deep, deepIgnore, mergeArray, mergeDepth, typedArray, preserve };
|
|
671
731
|
}
|
|
672
732
|
if (Array.isArray(data)) {
|
|
673
|
-
|
|
674
|
-
deepIgnore.add(data);
|
|
675
|
-
}
|
|
733
|
+
deepIgnore?.add(data);
|
|
676
734
|
const length = data.length;
|
|
677
|
-
if (
|
|
678
|
-
|
|
735
|
+
if (Array.isArray(target)) {
|
|
736
|
+
if (mergeArray && mergeDepth >= 0 && !(mergeArray === 'join' || Array.isArray(mergeArray) && mergeArray[0] === 'join')) {
|
|
737
|
+
const out = { target };
|
|
738
|
+
if (mergedArray(out, 'target', data, mergeArray)) {
|
|
739
|
+
return out.target;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
target.length = 0;
|
|
679
743
|
}
|
|
680
744
|
else {
|
|
681
|
-
target
|
|
745
|
+
target = new Array(length);
|
|
682
746
|
}
|
|
683
747
|
for (let i = 0; i < length; ++i) {
|
|
684
748
|
const value = data[i];
|
|
@@ -691,29 +755,11 @@ function cloneObject(data, options) {
|
|
|
691
755
|
}
|
|
692
756
|
}
|
|
693
757
|
else if (isObject(data)) {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
}
|
|
697
|
-
if (!target || !isObject(target)) {
|
|
758
|
+
deepIgnore?.add(data);
|
|
759
|
+
if (!isObject(target)) {
|
|
698
760
|
target = {};
|
|
699
761
|
}
|
|
700
|
-
const getProperties
|
|
701
|
-
let attrs;
|
|
702
|
-
if (inherited === false) {
|
|
703
|
-
attrs = nonenumerable ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
704
|
-
}
|
|
705
|
-
else {
|
|
706
|
-
attrs = [];
|
|
707
|
-
for (const attr in obj) {
|
|
708
|
-
attrs.push(attr);
|
|
709
|
-
}
|
|
710
|
-
if (nonenumerable) {
|
|
711
|
-
attrs = Array.from(new Set(attrs.concat(Object.getOwnPropertyNames(obj))));
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
return symbol ? attrs.concat(Object.getOwnPropertySymbols(obj)) : attrs;
|
|
715
|
-
};
|
|
716
|
-
for (const attr of getProperties(data)) {
|
|
762
|
+
for (const attr of getProperties(data, inherited, nonenumerable, symbol)) {
|
|
717
763
|
const value = data[attr];
|
|
718
764
|
let merge;
|
|
719
765
|
if (deepIgnore) {
|
|
@@ -722,23 +768,24 @@ function cloneObject(data, options) {
|
|
|
722
768
|
else {
|
|
723
769
|
merge = Array.isArray(value) ? value.slice(0) : value;
|
|
724
770
|
}
|
|
725
|
-
|
|
771
|
+
const prop = target[attr];
|
|
772
|
+
if (preserve && isPlainObject(prop) && isPlainObject(merge)) {
|
|
726
773
|
(function recurse(current, next) {
|
|
727
|
-
for (const item of getProperties(next)) {
|
|
774
|
+
for (const item of getProperties(next, inherited, nonenumerable, symbol)) {
|
|
728
775
|
const b = next[item];
|
|
729
|
-
if (
|
|
730
|
-
current[item] = b;
|
|
731
|
-
}
|
|
732
|
-
else {
|
|
776
|
+
if (item in current) {
|
|
733
777
|
const a = current[item];
|
|
734
778
|
if (isPlainObject(a) && isPlainObject(b)) {
|
|
735
779
|
recurse(a, b);
|
|
736
780
|
}
|
|
737
781
|
}
|
|
782
|
+
else if (!(mergeArray && mergeDepth >= 0 && mergedArray(current, item, b, mergeArray))) {
|
|
783
|
+
current[item] = b;
|
|
784
|
+
}
|
|
738
785
|
}
|
|
739
|
-
})(
|
|
786
|
+
})(prop, merge);
|
|
740
787
|
}
|
|
741
|
-
else {
|
|
788
|
+
else if (!(mergeArray && mergeDepth >= 0 && mergedArray(target, attr, merge, mergeArray))) {
|
|
742
789
|
target[attr] = merge;
|
|
743
790
|
}
|
|
744
791
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -255,9 +255,9 @@ declare namespace functions {
|
|
|
255
255
|
|
|
256
256
|
interface DocumentConstructor<T extends IFileManager<U>, U extends ExternalAsset = ExternalAsset, V extends ClientModule = DocumentModule, W extends DocumentComponent = DocumentComponent, X extends DocumentComponentOption = DocumentComponentOption, Y extends ICloud = ICloud<T>> extends ModuleConstructor {
|
|
257
257
|
finalize(this: T, instance: IDocument<T, U, V, W, X, Y>): Promise<unknown>;
|
|
258
|
-
|
|
258
|
+
/** @deprecated */
|
|
259
259
|
createSourceMap(code: string, remove: boolean): SourceMap;
|
|
260
|
-
|
|
260
|
+
/** @deprecated */
|
|
261
261
|
createSourceMap(code: string, uri?: string, remove?: boolean): SourceMap;
|
|
262
262
|
writeSourceMap(uri: string, data: SourceCode, options?: SourceMapOptions): Undef<string>;
|
|
263
263
|
updateGradle(source: string, namespaces: string[], value: string, upgrade: boolean): string;
|
|
@@ -579,7 +579,7 @@ declare namespace functions {
|
|
|
579
579
|
interface IModule<T extends IHost = IHost> extends EventEmitter, IAbortComponent {
|
|
580
580
|
readonly status: LogStatus<StatusType>[];
|
|
581
581
|
readonly errors: unknown[];
|
|
582
|
-
|
|
582
|
+
/** @deprecated */
|
|
583
583
|
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
584
584
|
supports(name: string, value?: boolean): boolean;
|
|
585
585
|
getTempDir(options: GetTempDirOptions): string;
|
package/lib/module.d.ts
CHANGED
|
@@ -71,6 +71,8 @@ export interface CloneObjectOptions<T = unknown> {
|
|
|
71
71
|
deep?: boolean;
|
|
72
72
|
deepIgnore?: WeakSet<object>;
|
|
73
73
|
typedArray?: boolean;
|
|
74
|
+
mergeArray?: MergeArrayMethod;
|
|
75
|
+
mergeDepth?: number;
|
|
74
76
|
symbol?: boolean;
|
|
75
77
|
inherited?: boolean;
|
|
76
78
|
nonenumerable?: boolean;
|
|
@@ -138,4 +140,5 @@ export interface IncludeAction<T = string[]> {
|
|
|
138
140
|
export type NormalizeFlags = typeof NORMALIZE_FLAGS[keyof typeof NORMALIZE_FLAGS];
|
|
139
141
|
export type ReadTextOptions = ReadBufferOptions;
|
|
140
142
|
export type ReadFileCallback<T extends Bufferable = Bufferable> = (err: Null<NodeJS.ErrnoException>, data?: T) => void;
|
|
141
|
-
export type ProtocolType = "http" | "https" | "http/s" | "ftp" | "sftp" | "s/ftp" | "torrent" | "unc" | "file";
|
|
143
|
+
export type ProtocolType = "http" | "https" | "http/s" | "ftp" | "sftp" | "s/ftp" | "torrent" | "unc" | "file";
|
|
144
|
+
export type MergeArrayMethod = "concat" | "concat-pre" | "includes" | "unshift" | "push" | "flat" | "join" | "slice" | "reverse" | ["flat", number] | ["join", string] | ["slice", number, number?];
|