{"id":23186859,"url":"https://github.com/metastable-void/es-first-aid","last_synced_at":"2025-04-05T04:46:45.976Z","repository":{"id":41406499,"uuid":"355168870","full_name":"metastable-void/es-first-aid","owner":"metastable-void","description":"The Fundamental Utilities for ECMAScript","archived":false,"fork":false,"pushed_at":"2022-08-02T15:07:45.000Z","size":98,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-10T12:46:03.174Z","etag":null,"topics":["base64","crc32","ecmascript","promise","utf-8","uuid"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/es-first-aid","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/metastable-void.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-06T11:46:45.000Z","updated_at":"2022-07-01T12:50:33.000Z","dependencies_parsed_at":"2022-08-29T22:22:26.333Z","dependency_job_id":null,"html_url":"https://github.com/metastable-void/es-first-aid","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metastable-void%2Fes-first-aid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metastable-void%2Fes-first-aid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metastable-void%2Fes-first-aid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metastable-void%2Fes-first-aid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metastable-void","download_url":"https://codeload.github.com/metastable-void/es-first-aid/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289400,"owners_count":20914464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["base64","crc32","ecmascript","promise","utf-8","uuid"],"created_at":"2024-12-18T10:17:58.103Z","updated_at":"2025-04-05T04:46:45.942Z","avatar_url":"https://github.com/metastable-void.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# es-first-aid\nThe Fundamental Utilities for ECMAScript.\n\n- Missing utility functions for ECMAScript\n- Random numbers/bytes...\n- UUIDs\n- CRC-32\n- Most basic general utility classes for various applications\n- Base64 encode/decode\n- UTF-8 string encode/decode\n- Hex string encode/decode\n- ...\n\n## API\n\n```typescript\nglobalThis.firstAid;\n\n// where\ndeclare const firstAid: FirstAid;\n\ninterface Iterable\u003cT\u003e {\n    [Symbol.iterator](): Iterator\u003cT\u003e;\n}\n\ntype BufferSource = ArrayBuffer | ArrayBufferView;\n\ntype MaybePromise\u003cT\u003e = Promise\u003cT\u003e | T;\n\ninterface PromiseComposition\u003cT\u003e extends Promise\u003cIterable\u003cT\u003e\u003e {\n    promises: Promise\u003cT\u003e[];\n    [Symbol.iterator]: () =\u003e IterableIterator\u003cT\u003e;\n    results: () =\u003e Promise\u003cT[]\u003e;\n    rejections: () =\u003e Promise\u003cany[]\u003e;\n    fulfilled: \u003creturnType\u003e(callback: (result: T) =\u003e returnType) =\u003e PromiseComposition\u003creturnType\u003e;\n    rejected: \u003creturnType\u003e(callback: (reason: any) =\u003e returnType) =\u003e PromiseComposition\u003creturnType\u003e;\n}\n\ninterface SymbolObject {\n    symbol: symbol;\n}\n\ninterface FirstAid {\n    VERSION: string;\n\n    firstAid: FirstAid;\n\n    constructor: new () =\u003e FirstAid;\n\n    PromiseComposition: new \u003cT\u003e(... promises: MaybePromise\u003cT\u003e[]) =\u003e PromiseComposition\u003cT\u003e;\n\n    // TypedArray constructor. (This is abstract; you cannot instantiate this.)\n    TypedArray: Function;\n\n    // Returns true if the passed value is a TypedArray.\n    isTypedArray: (value: any) =\u003e boolean;\n\n    // -0.\n    MINUS_ZERO: number;\n\n    // Creates a new null-prototype object.\n    createNullPrototypeObject: () =\u003e {};\n\n    // Wraps an object in a read-only Proxy.\n    createReadOnlyProxy: \u003cT\u003e(obj: T) =\u003e T;\n\n    // Returns true if the function throws.\n    checkForError: (f: () =\u003e void) =\u003e boolean;\n\n    // Returns true if the passed object is a revoked Proxy.\n    // This function is no longer always-reliable due to changes made to ECMAScript specs.\n    isRevokedProxy: (value: any) =\u003e boolean;\n\n    // Returns true if the passed object has a valid [[Construct]] slot.\n    isConstructor: (value: any) =\u003e boolean;\n\n    // Converts a value into a 32-bit signed integer.\n    toInt32: (value: any) =\u003e number;\n\n    // Returns true if the passed value is a 32-bit signed integer.\n    isInt32: (value: any) =\u003e boolean;\n\n    // Tries to convert a value into an integer.\n    toInt: (value: any) =\u003e number;\n\n    // Returns true if the passed value is a valid safe integer in ECMAScript.\n    isInt: (value: any) =\u003e boolean;\n\n    // Returns true if the passed value is null.\n    isNull: (value: any) =\u003e boolean;\n\n    // Returns true if the passed value is an object. (This includes functions but not null.)\n    isObject: (value: any) =\u003e boolean;\n\n    // Returns true if the passed value is a valid property key (string or symbol).\n    isPropertyKey: (value: any) =\u003e boolean;\n\n    // Returns Unicode code points of the given string.\n    getCodePoints: (str: string) =\u003e Iterable\u003cnumber\u003e;\n\n    // Encodes a string into UTF-8 bytes.\n    encodeString: (str: string) =\u003e Uint8Array;\n\n    // Decodes a string from UTF-8 bytes.\n    decodeString: (utf8Bytes: BufferSource) =\u003e string;\n\n    // Converts a buffer or view into a Uint8Array.\n    toUint8Array: (buffer: BufferSource) =\u003e Uint8Array;\n\n    // Get a copied ArrayBuffer from BufferSource.\n    getCopyBuffer: (buffer: BufferSource) =\u003e ArrayBuffer;\n\n    // Encodes bytes into a hex string.\n    encodeHex: (buffer: BufferSource) =\u003e string;\n\n    // Decodes a hex string.\n    decodeHex: (hexString: string) =\u003e Uint8Array;\n\n    // Encodes bytes into Base-64 encoded string.\n    encodeBase64: (buffer: BufferSource) =\u003e string;\n\n    // Decodes a Base-64 encoded string.\n    decodeBase64: (base64String: string) =\u003e Uint8Array;\n\n    // Calculates a CRC-32 check sum of the given buffer. (Signed 32-bit integer)\n    crc32: (buffer: BufferSource) =\u003e number;\n\n    // Get the CRC-32 sum as a Uint8Array.\n    crc32Bytes: (buffer: BufferSource) =\u003e Uint8Array;\n\n    // Fills the given buffer with Math.random() values.\n    randomFillInsecure: (buffer: BufferSource) =\u003e Uint8Array;\n\n    // Fills the given buffer with secure random values.\n    // Currently, Node.JS, Web, and Deno is supported.\n    randomFill: (buffer: BufferSource) =\u003e Uint8Array;\n\n    // Returns a random number in [0, 1) range.\n    // Uses Math.random() if isInsecure is true.\n    random: (isInsecure?: boolean) =\u003e number;\n\n    // Returns a random number in (0, 1] range.\n    // Uses Math.random() if isInsecure is true.\n    randomNonZero: (isInsecure?: boolean) =\u003e number;\n\n    // Returns a standard normal random number.\n    // Uses Math.random() if isInsecure is true.\n    randomNormal: (isInsecure?: boolean) =\u003e number;\n\n    // Returns a standard exponential random number.\n    // Uses Math.random() if isInsecure is true.\n    randomExponential: (isInsecure?: boolean) =\u003e number;\n\n    // Returns a Xenakis random number.\n    // Uses Math.random() if isInsecure is true.\n    randomXenakis: (isInsecure?: boolean) =\u003e number;\n\n    // Returns true in the given probability.\n    // Uses Math.random() if isInsecure is true.\n    randomProb: (prob: number, isInsecure?: boolean) =\u003e boolean;\n\n    // Generates a version-4 UUID string from the given buffer.\n    getUuidFromBytes: (arr: BufferSource) =\u003e string;\n\n    // Generates a random version-4 UUID string.\n    // Uses Math.random() if isInsecure is true.\n    getRandomUuid: (isInsecure?: boolean) =\u003e string;\n\n    // Returns true if the given value is a valid UUID string.\n    validateUuid: (uuid: string) =\u003e boolean;\n\n    // Calls the given function in an asynchronous manner.\n    callAsync: \u003cargumentType, returnType\u003e(callback: (... argumentsList: argumentType[]) =\u003e MaybePromise\u003creturnType\u003e, thisArgument: any, ... argumentList: argumentType[]) =\u003e Promise\u003creturnType\u003e;\n\n    // Converts any value into a Promise.\n    toPromise: \u003cT\u003e(value: MaybePromise\u003cT\u003e) =\u003e Promise\u003cT\u003e;\n\n    // Returns a current Unix timestamp in milliseconds.\n    getTime: () =\u003e number;\n\n    // Encodes an object into JSON bytes.\n    encodeJson: (value: any) =\u003e Uint8Array;\n\n    // Decodes an object from JSON bytes.\n    decodeJson: (bytes: BufferSource) =\u003e any;\n\n    // Throws an error if assertion is false\n    assert: (assertion: boolean, message?: string) =\u003e void;\n\n    // Compare two values in a JSON-like manner\n    compareJson: (a: any, b: any) =\u003e boolean;\n\n    // Returns the passed object as a constructor.\n    IdentityConstructor: new \u003cT\u003e(obj: T) =\u003e T;\n\n    // Creates an object for a symbol.\n    SymbolObject: new (symbol: symbol | SymbolObject) =\u003e SymbolObject;\n}\n```\n\n## License\nCopyright \u0026copy; 2021 Menhera.org\n\nLicensed under the Apache 2.0 license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetastable-void%2Fes-first-aid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetastable-void%2Fes-first-aid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetastable-void%2Fes-first-aid/lists"}