@easy-ds-bot/utils
Advanced tools
+10
-1
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.arrayFromIterator = exports.wait = exports.includesAll = exports.quickTextCompare = exports.equal = exports.chanceRandom = exports.arrRandom = exports.random = exports.reportMemory = exports.formatNumber = void 0; | ||
| exports.deepCopy = exports.arrayFromIterator = exports.wait = exports.includesAll = exports.quickTextCompare = exports.equal = exports.chanceRandom = exports.arrRandom = exports.random = exports.reportMemory = exports.formatNumber = void 0; | ||
| const tslib_1 = require("tslib"); | ||
@@ -133,1 +133,10 @@ const array_equal_1 = tslib_1.__importDefault(require("array-equal")); | ||
| exports.arrayFromIterator = arrayFromIterator; | ||
| /** | ||
| * Creates a [deep copy](https://developer.mozilla.org/en-US/docs/Glossary/Deep_copy) of an object | ||
| * | ||
| * Supports only serializable objects (JSON-like) | ||
| */ | ||
| function deepCopy(source) { | ||
| return JSON.parse(JSON.stringify(source)); | ||
| } | ||
| exports.deepCopy = deepCopy; |
@@ -119,1 +119,9 @@ import arr_equal from "array-equal"; | ||
| } | ||
| /** | ||
| * Creates a [deep copy](https://developer.mozilla.org/en-US/docs/Glossary/Deep_copy) of an object | ||
| * | ||
| * Supports only serializable objects (JSON-like) | ||
| */ | ||
| export function deepCopy(source) { | ||
| return JSON.parse(JSON.stringify(source)); | ||
| } |
@@ -44,1 +44,11 @@ /** | ||
| export declare function arrayFromIterator<T>(iterator: IterableIterator<T>): T[]; | ||
| /** | ||
| * Creates a [deep copy](https://developer.mozilla.org/en-US/docs/Glossary/Deep_copy) of an object | ||
| * | ||
| * Supports only serializable objects (JSON-like) | ||
| */ | ||
| export declare function deepCopy<S extends JSONLike>(source: S): S; | ||
| type SingleJSONSupportedValueTypes = string | number | boolean | object | null; | ||
| export type JSONSupportedValueTypes = SingleJSONSupportedValueTypes | SingleJSONSupportedValueTypes[]; | ||
| export type JSONLike = Record<string, JSONSupportedValueTypes>; | ||
| export {}; |
+1
-1
@@ -17,3 +17,3 @@ { | ||
| "name": "@easy-ds-bot/utils", | ||
| "version": "1.0.3", | ||
| "version": "1.1.0", | ||
| "description": "Tiny TypeScript utils: wait(), arrayFromIterator(), chanceRandom(), formatNumber(), equal(), quickTextCompare() and more", | ||
@@ -20,0 +20,0 @@ "main": "index", |
+2
-0
@@ -23,4 +23,6 @@ <p align="center"> | ||
| - *async* `wait(time_ms: number): Promise<void>` | ||
| # Requirements | ||
| - [NodeJS](https://nodejs.org/en), recommended `v18` or newer | ||
| # Setup | ||
@@ -27,0 +29,0 @@ 1. Install `utils` via npm: |
16441
6.61%320
9.22%85
2.41%