diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index b7b6660..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,148 +0,0 @@ -name: ci -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - - test_node: - runs-on: ${{ matrix.os }} - strategy: - matrix: - node: [ '20', '22' ] - os: [ windows-latest, ubuntu-latest ] - name: Test with Node v${{ matrix.node }} on ${{ matrix.os }} - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - - uses: bahmutov/npm-install@v1 - - run: yarn build - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: yarn test:node - test_deno: - runs-on: ubuntu-latest - name: test with Deno - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: '22' - - name: Cache - uses: actions/cache@v3 - with: - path: ~/.cache/deno - key: deno-${{ runner.os }}-${{ hashFiles('deno-lock.json') }} - restore-keys: | - deno-${{ runner.os }}-${{ hashFiles('deno-lock.json') }} - deno-${{ runner.os }}- - deno- - - uses: denoland/setup-deno@v1 - with: - deno-version: v1.x - - run: deno --version - - uses: bahmutov/npm-install@v1 - - run: yarn build - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: yarn test:deno - check_if_version_upgraded: - name: Check if version upgrade - # We run this only if it's a push on the default branch or if it's a PR from a - # branch (meaning not a PR from a fork). It would be more straightforward to test if secrets.NPM_TOKEN is - # defined but GitHub Action don't allow it yet. - if: | - github.event_name == 'push' || - github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login - runs-on: ubuntu-latest - needs: - - test_node - - test_deno - outputs: - from_version: ${{ steps.step1.outputs.from_version }} - to_version: ${{ steps.step1.outputs.to_version }} - is_upgraded_version: ${{ steps.step1.outputs.is_upgraded_version }} - is_pre_release: ${{steps.step1.outputs.is_pre_release }} - steps: - - uses: garronej/ts-ci@v2.1.0 - id: step1 - with: - action_name: is_package_json_version_upgraded - branch: ${{ github.head_ref || github.ref }} - - publish: - runs-on: ubuntu-latest - needs: - - check_if_version_upgraded - # We create a release only if the version have been upgraded and we are on the main branch - # or if we are on a branch of the repo that has an PR open on main. - if: | - needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true' && - ( - github.event_name == 'push' || - needs.check_if_version_upgraded.outputs.is_pre_release == 'true' - ) - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ github.ref }} - - run: rm -r .github - - name: Remove tmp_branch if it exists - run: git push origin :tmp_branch || true - - run: git checkout -b tmp_branch - - uses: actions/setup-node@v3 - with: - registry-url: https://registry.npmjs.org/ - node-version: '22' - - uses: bahmutov/npm-install@v1 - - run: yarn build - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: | - npx -y -p denoify@1.4.8 enable_short_npm_import_path - npx -y -p denoify@1.6.13 remove_deno_dist_from_gitignore - env: - DRY_RUN: "0" - - run: | - if [ "$(npm show . version)" = "$VERSION" ]; then - echo "This version is already published" - exit 0 - fi - if [ "$NODE_AUTH_TOKEN" = "" ]; then - echo "Can't publish on NPM, You must first create a secret called NPM_TOKEN that contains your NPM auth token. https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets" - false - fi - EXTRA_ARGS="" - if [ "$IS_PRE_RELEASE" = "true" ]; then - EXTRA_ARGS="--tag next" - fi - npm publish $EXTRA_ARGS - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - VERSION: ${{ needs.check_if_version_upgraded.outputs.to_version }} - IS_PRE_RELEASE: ${{ needs.check_if_version_upgraded.outputs.is_pre_release }} - - run: | - git config --global user.name "actions" - git config --global user.email actions@github.com - git add -A - git commit -am "Adding deno distribution files and moving files from /dist to /" - git push origin tmp_branch - - uses: softprops/action-gh-release@v1 - with: - name: Release v${{ needs.check_if_version_upgraded.outputs.to_version }} - tag_name: v${{ needs.check_if_version_upgraded.outputs.to_version }} - target_commitish: tmp_branch - generate_release_notes: false - draft: false - prerelease: ${{ needs.check_if_version_upgraded.outputs.is_pre_release == 'true' }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Remove tmp_branch - run: git push origin :tmp_branch diff --git a/.gitignore b/.gitignore index e5ab84a..13be271 100644 --- a/.gitignore +++ b/.gitignore @@ -1,44 +1,2 @@ -# Logs -logs -*.log -npm-debug.log* - -# Runtime data -pids -*.pid -*.seed - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules -jspm_packages - -# Optional npm cache directory -.npm - -# Optional REPL history -.node_repl_history - -.vscode - -.DS_Store - -/dist -/deno_dist + +/node_modules diff --git a/Equals.d.ts b/Equals.d.ts new file mode 100644 index 0000000..920a4e6 --- /dev/null +++ b/Equals.d.ts @@ -0,0 +1,4 @@ +import type { Unite } from "./tools/Unite"; +import type { StrictEquals } from "./tools/StrictEquals"; +/** https://docs.tsafe.dev/main/equals */ +export type Equals = StrictEquals, Unite>; diff --git a/Equals.js b/Equals.js new file mode 100644 index 0000000..7a299e6 --- /dev/null +++ b/Equals.js @@ -0,0 +1,6 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// TODO: To export and document, this type can be used in place of equals if the types to compare have no `any` in them. +// (I think but some more testing is needed) +// export type LooseEquals = T extends U ? (U extends T ? true : false) : false; +//# sourceMappingURL=Equals.js.map \ No newline at end of file diff --git a/Equals.js.map b/Equals.js.map new file mode 100644 index 0000000..15e27a8 --- /dev/null +++ b/Equals.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Equals.js","sourceRoot":"","sources":["src/Equals.ts"],"names":[],"mappings":";;AAOA,wHAAwH;AACxH,4CAA4C;AAC5C,sFAAsF"} \ No newline at end of file diff --git a/Extends.d.ts b/Extends.d.ts new file mode 100644 index 0000000..e717d3c --- /dev/null +++ b/Extends.d.ts @@ -0,0 +1,7 @@ +import type { StrictEquals } from "./tools/StrictEquals"; +/** + * @see + * + * Usage example: assert>(); + **/ +export type Extends = StrictEquals extends true ? true : StrictEquals extends true ? false : StrictEquals extends true ? true : StrictEquals extends true ? true : StrictEquals extends true ? false : StrictEquals extends true ? false : A1 extends A2 ? true : false; diff --git a/Extends.js b/Extends.js new file mode 100644 index 0000000..c45c6c9 --- /dev/null +++ b/Extends.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=Extends.js.map \ No newline at end of file diff --git a/Extends.js.map b/Extends.js.map new file mode 100644 index 0000000..fde128f --- /dev/null +++ b/Extends.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Extends.js","sourceRoot":"","sources":["src/Extends.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/MethodNames.d.ts b/MethodNames.d.ts new file mode 100644 index 0000000..fb2595b --- /dev/null +++ b/MethodNames.d.ts @@ -0,0 +1,4 @@ +/** https://docs.tsafe.dev/methodnames */ +export type MethodNames = Exclude<{ + [Key in keyof Api]: Api[Key] extends ((...args: any[]) => unknown) | undefined ? Key : never; +}[keyof Api], null | undefined>; diff --git a/MethodNames.js b/MethodNames.js new file mode 100644 index 0000000..b4e9c05 --- /dev/null +++ b/MethodNames.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=MethodNames.js.map \ No newline at end of file diff --git a/MethodNames.js.map b/MethodNames.js.map new file mode 100644 index 0000000..e5d48a4 --- /dev/null +++ b/MethodNames.js.map @@ -0,0 +1 @@ +{"version":3,"file":"MethodNames.js","sourceRoot":"","sources":["src/MethodNames.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/Not.d.ts b/Not.d.ts new file mode 100644 index 0000000..c5bd642 --- /dev/null +++ b/Not.d.ts @@ -0,0 +1,2 @@ +/** https://docs.tsafe.dev/main/not */ +export type Not = B extends true ? false : true; diff --git a/Not.js b/Not.js new file mode 100644 index 0000000..7ec187a --- /dev/null +++ b/Not.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=Not.js.map \ No newline at end of file diff --git a/Not.js.map b/Not.js.map new file mode 100644 index 0000000..a253ef5 --- /dev/null +++ b/Not.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Not.js","sourceRoot":"","sources":["src/Not.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/Param0.d.ts b/Param0.d.ts new file mode 100644 index 0000000..d33232f --- /dev/null +++ b/Param0.d.ts @@ -0,0 +1,7 @@ +import type { Parameters } from "./Parameters"; +type NonUndefined = T extends undefined ? never : T; +/** Shorthand for Parameters[0] https://docs.tsafe.dev/param0 */ +export type Param0 unknown) | null | undefined | false | ""> = [ + Parameters +] extends [never] ? never : Parameters extends [] ? void : NonUndefined[0]>; +export {}; diff --git a/Param0.js b/Param0.js new file mode 100644 index 0000000..85e93f9 --- /dev/null +++ b/Param0.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=Param0.js.map \ No newline at end of file diff --git a/Param0.js.map b/Param0.js.map new file mode 100644 index 0000000..83b5382 --- /dev/null +++ b/Param0.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Param0.js","sourceRoot":"","sources":["src/Param0.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/Parameters.d.ts b/Parameters.d.ts new file mode 100644 index 0000000..dfc7e7c --- /dev/null +++ b/Parameters.d.ts @@ -0,0 +1,2 @@ +/** https://docs.tsafe.dev/parameters */ +export type Parameters unknown) | null | undefined | false | ""> = T extends (...args: infer P) => any ? P : never; diff --git a/Parameters.js b/Parameters.js new file mode 100644 index 0000000..63490dd --- /dev/null +++ b/Parameters.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=Parameters.js.map \ No newline at end of file diff --git a/Parameters.js.map b/Parameters.js.map new file mode 100644 index 0000000..45323fb --- /dev/null +++ b/Parameters.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Parameters.js","sourceRoot":"","sources":["src/Parameters.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/PickOptionals.d.ts b/PickOptionals.d.ts new file mode 100644 index 0000000..dac7923 --- /dev/null +++ b/PickOptionals.d.ts @@ -0,0 +1,10 @@ +type OptionalKeyof> = Exclude<{ + [Key in keyof T]: T extends Record ? never : Key; +}[keyof T], undefined>; +/** + * PickOptionals<{ p1: string; p2?: string; p3?: number; }> + * is the type + * { p2: string; p3: number; } + */ +export type PickOptionals> = Required>>; +export {}; diff --git a/PickOptionals.js b/PickOptionals.js new file mode 100644 index 0000000..9ec0b7c --- /dev/null +++ b/PickOptionals.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=PickOptionals.js.map \ No newline at end of file diff --git a/PickOptionals.js.map b/PickOptionals.js.map new file mode 100644 index 0000000..98d179e --- /dev/null +++ b/PickOptionals.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PickOptionals.js","sourceRoot":"","sources":["src/PickOptionals.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/PickRequired.d.ts b/PickRequired.d.ts new file mode 100644 index 0000000..72aaa23 --- /dev/null +++ b/PickRequired.d.ts @@ -0,0 +1,7 @@ +import { PickOptionals } from "./PickOptionals"; +/** + * PickRequired<{ p1: string; p2?: string; p3?: number; p4: string; }> + * is the type + * { p1: string; p4: number; } + */ +export type PickRequired> = Omit>; diff --git a/PickRequired.js b/PickRequired.js new file mode 100644 index 0000000..285609b --- /dev/null +++ b/PickRequired.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=PickRequired.js.map \ No newline at end of file diff --git a/PickRequired.js.map b/PickRequired.js.map new file mode 100644 index 0000000..97fbf94 --- /dev/null +++ b/PickRequired.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PickRequired.js","sourceRoot":"","sources":["src/PickRequired.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/Reflect.d.ts b/Reflect.d.ts new file mode 100644 index 0000000..fa64428 --- /dev/null +++ b/Reflect.d.ts @@ -0,0 +1,2 @@ +/** Always return null but pretends it returns an object of type T */ +export declare function Reflect(): T; diff --git a/Reflect.js b/Reflect.js new file mode 100644 index 0000000..bede7ff --- /dev/null +++ b/Reflect.js @@ -0,0 +1,8 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Reflect = Reflect; +/** Always return null but pretends it returns an object of type T */ +function Reflect() { + return null; +} +//# sourceMappingURL=Reflect.js.map \ No newline at end of file diff --git a/Reflect.js.map b/Reflect.js.map new file mode 100644 index 0000000..a17ae78 --- /dev/null +++ b/Reflect.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Reflect.js","sourceRoot":"","sources":["src/Reflect.ts"],"names":[],"mappings":";;AACA,0BAEC;AAHD,qEAAqE;AACrE,SAAgB,OAAO;IACnB,OAAO,IAAW,CAAC;AACvB,CAAC"} \ No newline at end of file diff --git a/ReturnType.d.ts b/ReturnType.d.ts new file mode 100644 index 0000000..0e00b32 --- /dev/null +++ b/ReturnType.d.ts @@ -0,0 +1,2 @@ +/** https://docs.tsafe.dev/returntype */ +export type ReturnType unknown) | undefined | null | false | ""> = T extends (...args: any[]) => infer R ? (R extends PromiseLike ? J : R) : never; diff --git a/ReturnType.js b/ReturnType.js new file mode 100644 index 0000000..0e33f6b --- /dev/null +++ b/ReturnType.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// ReturnType<(()=> Promise | number) | undefined> = (()=> Promise | number) | undefined extends (...args: any[]) => infer R ? +// = ( ()=> Promise | number extends (...args: any[]) => infer R ? ) | (undefined extends (...args: any[]) => infer R ? ) +// = ( Promise | number extends PromiseLike ? ) | never +// = Promise | number extends PromiseLike ? +// = ( Promise extends PromiseLike ?) | ( number extends PromiseLike ?) +// = string | number +//# sourceMappingURL=ReturnType.js.map \ No newline at end of file diff --git a/ReturnType.js.map b/ReturnType.js.map new file mode 100644 index 0000000..2fe98c4 --- /dev/null +++ b/ReturnType.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ReturnType.js","sourceRoot":"","sources":["src/ReturnType.ts"],"names":[],"mappings":";;AAIA,8IAA8I;AAC9I,yLAAyL;AACzL,4IAA4I;AAC5I,sHAAsH;AACtH,2JAA2J;AAC3J,0HAA0H"} \ No newline at end of file diff --git a/UnionToIntersection.d.ts b/UnionToIntersection.d.ts new file mode 100644 index 0000000..aee401b --- /dev/null +++ b/UnionToIntersection.d.ts @@ -0,0 +1,2 @@ +/** @see **/ +export type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; diff --git a/UnionToIntersection.js b/UnionToIntersection.js new file mode 100644 index 0000000..07a9bd0 --- /dev/null +++ b/UnionToIntersection.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=UnionToIntersection.js.map \ No newline at end of file diff --git a/UnionToIntersection.js.map b/UnionToIntersection.js.map new file mode 100644 index 0000000..f1edd41 --- /dev/null +++ b/UnionToIntersection.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UnionToIntersection.js","sourceRoot":"","sources":["src/UnionToIntersection.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/UnpackPromise.d.ts b/UnpackPromise.d.ts new file mode 100644 index 0000000..826dad4 --- /dev/null +++ b/UnpackPromise.d.ts @@ -0,0 +1,6 @@ +/** + * Use case: + * declare const pr: Promise; + * const x: UnpackPromise; <== x is string[] + */ +export type UnpackPromise | undefined | null | false | ""> = T extends PromiseLike ? U : never; diff --git a/UnpackPromise.js b/UnpackPromise.js new file mode 100644 index 0000000..4bbbe90 --- /dev/null +++ b/UnpackPromise.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=UnpackPromise.js.map \ No newline at end of file diff --git a/UnpackPromise.js.map b/UnpackPromise.js.map new file mode 100644 index 0000000..d2135b6 --- /dev/null +++ b/UnpackPromise.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UnpackPromise.js","sourceRoot":"","sources":["src/UnpackPromise.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/assert.d.ts b/assert.d.ts new file mode 100644 index 0000000..d88b0c2 --- /dev/null +++ b/assert.d.ts @@ -0,0 +1,10 @@ +export type { Equals } from "./Equals"; +/** https://docs.tsafe.dev/assert#error-thrown */ +export declare class AssertionError extends Error { + originalMessage?: string; + constructor(msg: string | undefined); +} +/** https://docs.tsafe.dev/assert */ +export declare function assert<_T extends true>(condition?: any, msg?: string | (() => string)): asserts condition; +/** https://docs.tsafe.dev/is */ +export declare function is(value: any): value is T; diff --git a/assert.js b/assert.js new file mode 100644 index 0000000..2e3c57b --- /dev/null +++ b/assert.js @@ -0,0 +1,98 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AssertionError = void 0; +exports.assert = assert; +exports.is = is; +var overwriteReadonlyProp_1 = require("./lab/overwriteReadonlyProp"); +/** https://docs.tsafe.dev/assert#error-thrown */ +var AssertionError = /** @class */ (function (_super) { + __extends(AssertionError, _super); + function AssertionError(msg) { + var _newTarget = this.constructor; + var _this = _super.call(this, "Wrong assertion encountered" + (!msg ? "" : ": \"".concat(msg, "\""))) || this; + _this.originalMessage = msg; + Object.setPrototypeOf(_this, _newTarget.prototype); + if (!_this.stack) { + return _this; + } + try { + (0, overwriteReadonlyProp_1.overwriteReadonlyProp)(_this, "stack", _this.stack + .split("\n") + .filter(function () { + var _a = []; + for (var _i = 0; _i < arguments.length; _i++) { + _a[_i] = arguments[_i]; + } + var _b = __read(_a, 2), i = _b[1]; + return i !== 1 && i !== 2; + }) + .join("\n")); + } + catch (_a) { } + return _this; + } + return AssertionError; +}(Error)); +exports.AssertionError = AssertionError; +var refOfIs = undefined; +/** https://docs.tsafe.dev/assert */ +function assert(condition, msg) { + if (arguments.length === 0) { + condition = true; + } + if (refOfIs !== undefined) { + refOfIs = undefined; + return; + } + if (!condition) { + throw new AssertionError(typeof msg === "function" ? msg() : msg); + } +} +var errorMessage = "Wrong usage of the `is` function refer to https://docs.tsafe.dev/is"; +/** https://docs.tsafe.dev/is */ +function is(value) { + var ref = {}; + if (refOfIs !== undefined) { + refOfIs = undefined; + throw new Error(errorMessage); + } + refOfIs = ref; + Promise.resolve().then(function () { + if (refOfIs === ref) { + throw new Error(errorMessage); + } + }); + return null; +} +//# sourceMappingURL=assert.js.map \ No newline at end of file diff --git a/assert.js.map b/assert.js.map new file mode 100644 index 0000000..71af5f1 --- /dev/null +++ b/assert.js.map @@ -0,0 +1 @@ +{"version":3,"file":"assert.js","sourceRoot":"","sources":["src/assert.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,wBAeC;AAKD,gBAiBC;AAvED,qEAAoE;AAGpE,iDAAiD;AACjD;IAAoC,kCAAK;IAGrC,wBAAY,GAAuB;;QAC/B,YAAA,MAAK,YAAC,6BAA6B,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAM,GAAG,OAAG,CAAC,CAAC,SAAC;QAElE,KAAI,CAAC,eAAe,GAAG,GAAG,CAAC;QAE3B,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,WAAW,SAAS,CAAC,CAAC;QAElD,IAAI,CAAC,KAAI,CAAC,KAAK,EAAE,CAAC;;QAElB,CAAC;QAED,IAAI,CAAC;YACD,IAAA,6CAAqB,EACjB,KAAI,EACJ,OAAO,EACP,KAAI,CAAC,KAAK;iBACL,KAAK,CAAC,IAAI,CAAC;iBACX,MAAM,CAAC;gBAAC,YAAQ;qBAAR,UAAQ,EAAR,qBAAQ,EAAR,IAAQ;oBAAR,uBAAQ;;gBAAR,IAAA,KAAA,aAAQ,EAAF,CAAC,QAAA,CAAC;gBAAK,OAAA,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;YAAlB,CAAkB,CAAC;iBACxC,IAAI,CAAC,IAAI,CAAC,CAClB,CAAC;QACN,CAAC;QAAC,WAAM,CAAC,CAAA,CAAC;;IACd,CAAC;IACL,qBAAC;AAAD,CAAC,AAzBD,CAAoC,KAAK,GAyBxC;AAzBY,wCAAc;AA2B3B,IAAI,OAAO,GAAsC,SAAS,CAAC;AAE3D,oCAAoC;AACpC,SAAgB,MAAM,CAClB,SAAe,EACf,GAA6B;IAE7B,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,SAAS,GAAG,IAAI,CAAC;IACrB,CAAC;IACD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,GAAG,SAAS,CAAC;QACpB,OAAO;IACX,CAAC;IAED,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,MAAM,IAAI,cAAc,CAAC,OAAO,GAAG,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACtE,CAAC;AACL,CAAC;AAED,IAAM,YAAY,GAAG,qEAAqE,CAAC;AAE3F,gCAAgC;AAChC,SAAgB,EAAE,CAAI,KAAU;IAC5B,IAAM,GAAG,GAAG,EAAE,CAAC;IAEf,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,GAAG,SAAS,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,GAAG,GAAG,CAAC;IAEd,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;QACnB,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;QAClC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,IAAW,CAAC;AACvB,CAAC"} \ No newline at end of file diff --git a/capitalize.d.ts b/capitalize.d.ts new file mode 100644 index 0000000..cbd5235 --- /dev/null +++ b/capitalize.d.ts @@ -0,0 +1,2 @@ +/** @see */ +export declare function capitalize(str: S): Capitalize; diff --git a/capitalize.js b/capitalize.js new file mode 100644 index 0000000..9c587b4 --- /dev/null +++ b/capitalize.js @@ -0,0 +1,8 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.capitalize = capitalize; +/** @see */ +function capitalize(str) { + return (str.charAt(0).toUpperCase() + str.slice(1)); +} +//# sourceMappingURL=capitalize.js.map \ No newline at end of file diff --git a/capitalize.js.map b/capitalize.js.map new file mode 100644 index 0000000..763c3d3 --- /dev/null +++ b/capitalize.js.map @@ -0,0 +1 @@ +{"version":3,"file":"capitalize.js","sourceRoot":"","sources":["src/capitalize.ts"],"names":[],"mappings":";;AACA,gCAEC;AAHD,+CAA+C;AAC/C,SAAgB,UAAU,CAAmB,GAAM;IAC/C,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAQ,CAAC;AAC/D,CAAC"} \ No newline at end of file diff --git a/deno_dist/Equals.ts b/deno_dist/Equals.ts new file mode 100644 index 0000000..3043a8c --- /dev/null +++ b/deno_dist/Equals.ts @@ -0,0 +1,10 @@ +import type { Unite } from "./tools/Unite.ts"; +import type { StrictEquals } from "./tools/StrictEquals.ts"; + +// Credit https://stackoverflow.com/a/53808212/3731798 +/** https://docs.tsafe.dev/main/equals */ +export type Equals = StrictEquals, Unite>; + +// TODO: To export and document, this type can be used in place of equals if the types to compare have no `any` in them. +// (I think but some more testing is needed) +// export type LooseEquals = T extends U ? (U extends T ? true : false) : false; diff --git a/deno_dist/Extends.ts b/deno_dist/Extends.ts new file mode 100644 index 0000000..fe9bf70 --- /dev/null +++ b/deno_dist/Extends.ts @@ -0,0 +1,23 @@ +import type { StrictEquals } from "./tools/StrictEquals.ts"; + +/** + * @see + * + * Usage example: assert>(); + **/ +export type Extends = + StrictEquals extends true + ? true + : StrictEquals extends true + ? false + : StrictEquals extends true + ? true + : StrictEquals extends true + ? true + : StrictEquals extends true + ? false + : StrictEquals extends true + ? false + : A1 extends A2 + ? true + : false; diff --git a/deno_dist/LICENSE b/deno_dist/LICENSE new file mode 100644 index 0000000..61f220f --- /dev/null +++ b/deno_dist/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 GitHub user u/garronej + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/deno_dist/MethodNames.ts b/deno_dist/MethodNames.ts new file mode 100644 index 0000000..8c17259 --- /dev/null +++ b/deno_dist/MethodNames.ts @@ -0,0 +1,7 @@ +/** https://docs.tsafe.dev/methodnames */ +export type MethodNames = Exclude< + { + [Key in keyof Api]: Api[Key] extends ((...args: any[]) => unknown) | undefined ? Key : never; + }[keyof Api], + null | undefined +>; diff --git a/deno_dist/Not.ts b/deno_dist/Not.ts new file mode 100644 index 0000000..c5bd642 --- /dev/null +++ b/deno_dist/Not.ts @@ -0,0 +1,2 @@ +/** https://docs.tsafe.dev/main/not */ +export type Not = B extends true ? false : true; diff --git a/deno_dist/Param0.ts b/deno_dist/Param0.ts new file mode 100644 index 0000000..4e278db --- /dev/null +++ b/deno_dist/Param0.ts @@ -0,0 +1,12 @@ +import type { Parameters } from "./Parameters.ts"; + +type NonUndefined = T extends undefined ? never : T; + +/** Shorthand for Parameters[0] https://docs.tsafe.dev/param0 */ +export type Param0 unknown) | null | undefined | false | ""> = [ + Parameters, +] extends [never] + ? never + : Parameters extends [] + ? void + : NonUndefined[0]>; diff --git a/deno_dist/Parameters.ts b/deno_dist/Parameters.ts new file mode 100644 index 0000000..89b97c5 --- /dev/null +++ b/deno_dist/Parameters.ts @@ -0,0 +1,3 @@ +/** https://docs.tsafe.dev/parameters */ +export type Parameters unknown) | null | undefined | false | ""> = + T extends (...args: infer P) => any ? P : never; diff --git a/deno_dist/PickOptionals.ts b/deno_dist/PickOptionals.ts new file mode 100644 index 0000000..048bd95 --- /dev/null +++ b/deno_dist/PickOptionals.ts @@ -0,0 +1,13 @@ +type OptionalKeyof> = Exclude< + { + [Key in keyof T]: T extends Record ? never : Key; + }[keyof T], + undefined +>; + +/** + * PickOptionals<{ p1: string; p2?: string; p3?: number; }> + * is the type + * { p2: string; p3: number; } + */ +export type PickOptionals> = Required>>; diff --git a/deno_dist/PickRequired.ts b/deno_dist/PickRequired.ts new file mode 100644 index 0000000..2a37d0a --- /dev/null +++ b/deno_dist/PickRequired.ts @@ -0,0 +1,8 @@ +import { PickOptionals } from "./PickOptionals.ts"; + +/** + * PickRequired<{ p1: string; p2?: string; p3?: number; p4: string; }> + * is the type + * { p1: string; p4: number; } + */ +export type PickRequired> = Omit>; diff --git a/deno_dist/README.md b/deno_dist/README.md new file mode 100644 index 0000000..9bb845b --- /dev/null +++ b/deno_dist/README.md @@ -0,0 +1,104 @@ +

+ +

+

+ A collection of utilities to take your TypeScript development up a notch +
+
+ + + + + + + + + + + + +
+ + + + You can cherry-pick what you import +

+

+ Documentation +

+ +

+
+
+ Make sure two types are identical +
+
+ +
+ +
+ Playground +

+

+
+ A assertion function that typescript understands +
+
+ +

+

+
+
+ Make sure your zod schema exactly matches a given type: +
+ +
+ Playground +

+

+
+
+ Make sure you never forget a case in a switch +
+
+ +
+ Playground +

+

+
+
+ Make TypeScript believe whatever you say without having to write const obj2 = obj as Bar. +
+ The more powerfully is to be able to tell TypeScript that obj ist not of type Bar: +
+
+ +

+ +## Motivations + +Powerful TypeScript features like [assertion functions](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions) or [user-defined type guards](https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards) are only useful if paired with utility functions. + +TypeScript, however, only exports type helpers \(e.g. `Record`, `ReturnType`, etc.\). + +This module provides _«the missing builtins»_ such as [the assert function](https://docs.tsafe.dev/assert) and other utilities that cannot be just type helpers. + +[**Documentation website**](https://docs.tsafe.dev) + +## Installation + +`tsafe` is both an [NPM](https://www.npmjs.com/package/tsafe) and a [Deno](https://deno.land/x/tsafe) module. +(Achieved with [denoify](https://github.com/garronej/denoify)) + +## Import in deno: + +```typescript +import { assert, type Equals, ... } from "https://deno.land/x/tsafe/mod.ts"; +``` + +## Install elsewhere: + +```bash +$ npm install --save tsafe +``` diff --git a/deno_dist/Reflect.ts b/deno_dist/Reflect.ts new file mode 100644 index 0000000..6d004ec --- /dev/null +++ b/deno_dist/Reflect.ts @@ -0,0 +1,4 @@ +/** Always return null but pretends it returns an object of type T */ +export function Reflect(): T { + return null as any; +} diff --git a/deno_dist/ReturnType.ts b/deno_dist/ReturnType.ts new file mode 100644 index 0000000..4361993 --- /dev/null +++ b/deno_dist/ReturnType.ts @@ -0,0 +1,10 @@ +/** https://docs.tsafe.dev/returntype */ +export type ReturnType unknown) | undefined | null | false | ""> = + T extends (...args: any[]) => infer R ? (R extends PromiseLike ? J : R) : never; + +// ReturnType<(()=> Promise | number) | undefined> = (()=> Promise | number) | undefined extends (...args: any[]) => infer R ? +// = ( ()=> Promise | number extends (...args: any[]) => infer R ? ) | (undefined extends (...args: any[]) => infer R ? ) +// = ( Promise | number extends PromiseLike ? ) | never +// = Promise | number extends PromiseLike ? +// = ( Promise extends PromiseLike ?) | ( number extends PromiseLike ?) +// = string | number diff --git a/deno_dist/UnionToIntersection.ts b/deno_dist/UnionToIntersection.ts new file mode 100644 index 0000000..8d7fde7 --- /dev/null +++ b/deno_dist/UnionToIntersection.ts @@ -0,0 +1,6 @@ +/** @see **/ +export type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ( + k: infer I, +) => void + ? I + : never; diff --git a/deno_dist/UnpackPromise.ts b/deno_dist/UnpackPromise.ts new file mode 100644 index 0000000..3d2ae2c --- /dev/null +++ b/deno_dist/UnpackPromise.ts @@ -0,0 +1,7 @@ +/** + * Use case: + * declare const pr: Promise; + * const x: UnpackPromise; <== x is string[] + */ +export type UnpackPromise | undefined | null | false | ""> = + T extends PromiseLike ? U : never; diff --git a/deno_dist/assert.ts b/deno_dist/assert.ts new file mode 100644 index 0000000..4da6a4b --- /dev/null +++ b/deno_dist/assert.ts @@ -0,0 +1,72 @@ +import { overwriteReadonlyProp } from "./lab/overwriteReadonlyProp.ts"; +export type { Equals } from "./Equals.ts"; + +/** https://docs.tsafe.dev/assert#error-thrown */ +export class AssertionError extends Error { + originalMessage?: string; + + constructor(msg: string | undefined) { + super(`Wrong assertion encountered` + (!msg ? "" : `: "${msg}"`)); + + this.originalMessage = msg; + + Object.setPrototypeOf(this, new.target.prototype); + + if (!this.stack) { + return; + } + + try { + overwriteReadonlyProp( + this, + "stack", + this.stack + .split("\n") + .filter((...[, i]) => i !== 1 && i !== 2) + .join("\n"), + ); + } catch {} + } +} + +let refOfIs: undefined | Record = undefined; + +/** https://docs.tsafe.dev/assert */ +export function assert<_T extends true>( + condition?: any, + msg?: string | (() => string), +): asserts condition { + if (arguments.length === 0) { + condition = true; + } + if (refOfIs !== undefined) { + refOfIs = undefined; + return; + } + + if (!condition) { + throw new AssertionError(typeof msg === "function" ? msg() : msg); + } +} + +const errorMessage = "Wrong usage of the `is` function refer to https://docs.tsafe.dev/is"; + +/** https://docs.tsafe.dev/is */ +export function is(value: any): value is T { + const ref = {}; + + if (refOfIs !== undefined) { + refOfIs = undefined; + throw new Error(errorMessage); + } + + refOfIs = ref; + + Promise.resolve().then(() => { + if (refOfIs === ref) { + throw new Error(errorMessage); + } + }); + + return null as any; +} diff --git a/deno_dist/capitalize.ts b/deno_dist/capitalize.ts new file mode 100644 index 0000000..699a84e --- /dev/null +++ b/deno_dist/capitalize.ts @@ -0,0 +1,4 @@ +/** @see */ +export function capitalize(str: S): Capitalize { + return (str.charAt(0).toUpperCase() + str.slice(1)) as any; +} diff --git a/deno_dist/exclude.ts b/deno_dist/exclude.ts new file mode 100644 index 0000000..5e98576 --- /dev/null +++ b/deno_dist/exclude.ts @@ -0,0 +1,20 @@ +/** + * https://docs.tsafe.dev/exclude + * + * Return a function to use as Array.prototype.filter argument + * to exclude one or many primitive value element from the array. + * Ex: ([ "a", "b", "c" ] as const).filter(exclude("a")) return ("b" | "c")[] + * Ex: ([ "a", "b", "c", "d"] as const).filter(exclude(["a", "b"]) gives ("c" | "d")[] + */ +export function exclude( + target: readonly T[] | T, +) { + const test: (element: any) => boolean = + target instanceof Object + ? element => target.indexOf(element) < 0 + : element => element !== target; + + return function (element: U): element is Exclude { + return test(element); + }; +} diff --git a/deno_dist/flip.ts b/deno_dist/flip.ts new file mode 100644 index 0000000..7efda41 --- /dev/null +++ b/deno_dist/flip.ts @@ -0,0 +1,18 @@ +type KeyOfType, U> = NonNullable< + { + [Key in keyof T]: T[Key] extends U | undefined ? Key : never; + }[keyof T] +>; + +/** + * Flip the value of a boolean without having to reference it twice + * after running flip(x.y, "z") x.y.z !== x.y.z, + * https://docs.tsafe.dev/flip + */ +export function flip>(object: T, prop: KeyOfType) { + if (object[prop] === undefined) { + return; + } + + return (object[prop] = !object[prop] as any); +} diff --git a/deno_dist/id.ts b/deno_dist/id.ts new file mode 100644 index 0000000..9d202e3 --- /dev/null +++ b/deno_dist/id.ts @@ -0,0 +1,37 @@ +/** https://docs.tsafe.dev/id */ +export const id = (x: T) => x; + +/** + * Ensure that a that a specific type that we are declaring extends a more generic type + * + * Use case example 1: + * + * type MyObject = { + * p1: string; + * p2: string; + * a: string; + * b: string; + * }; + * + * We want to define a type that consist in an union of + * all the property name that are letters: + * + * type AlphabeticalKeys = Id; + * + * Here AlphabeticalKeys is "a" | "b" but it's better than + * simply writing it explicitly as we get autocompletion + * and we can't include a property name that does not exist on MyObject. + * + * Use case example 2: + * + * We want to declare object type that only take string or number + * as key value: + * + * export type MyObject = Id, { + * p1: string; + * p2: number; + * }>; + * + * If later on someone adds "p3": string[] he will get a type error. + * */ +export type Id = Specific; diff --git a/deno_dist/index.ts b/deno_dist/index.ts new file mode 100644 index 0000000..aa2a977 --- /dev/null +++ b/deno_dist/index.ts @@ -0,0 +1,26 @@ +export * from "./assert.ts"; +export * from "./exclude.ts"; +export * from "./flip.ts"; +export * from "./id.ts"; +export * from "./isPromiseLike.ts"; +export type { MethodNames } from "./MethodNames.ts"; +export * from "./objectKeys.ts"; +export type { Parameters } from "./Parameters.ts"; +export type { Param0 } from "./Param0.ts"; +export type { PickOptionals } from "./PickOptionals.ts"; +export type { PickRequired } from "./PickRequired.ts"; +export type { ReturnType } from "./ReturnType.ts"; +export * from "./typeGuard.ts"; +export type { UnpackPromise } from "./UnpackPromise.ts"; +export * from "./isAmong.ts"; +export type { Equals } from "./Equals.ts"; +export type { Extends } from "./Extends.ts"; +export type { Not } from "./Not.ts"; +export type { UnionToIntersection } from "./UnionToIntersection.ts"; +export * from "./objectEntries.ts"; +export * from "./objectFromEntries.ts"; +export * from "./noUndefined.ts"; +export * from "./Reflect.ts"; +export * from "./capitalize.ts"; +export * from "./uncapitalize.ts"; +export * from "./symToStr.ts"; diff --git a/deno_dist/is.ts b/deno_dist/is.ts new file mode 100644 index 0000000..38ba3d6 --- /dev/null +++ b/deno_dist/is.ts @@ -0,0 +1,9 @@ +import { is } from "./assert.ts"; + +/** + * @deprecated: Prefer importing using `import { assert, is } from "tsafe/assert"` + * or `import { assert, is } from "tsafe"` + * + * https://docs.tsafe.dev/is + * */ +export { is }; diff --git a/deno_dist/isAmong.ts b/deno_dist/isAmong.ts new file mode 100644 index 0000000..145c039 --- /dev/null +++ b/deno_dist/isAmong.ts @@ -0,0 +1,12 @@ +/** https://docs.tsafe.dev/isamong */ +export function isAmong( + names: readonly Name[], + value: unknown, +): value is Name { + for (const name of names) { + if (name === value) { + return true; + } + } + return false; +} diff --git a/deno_dist/isPromiseLike.ts b/deno_dist/isPromiseLike.ts new file mode 100644 index 0000000..856d9f1 --- /dev/null +++ b/deno_dist/isPromiseLike.ts @@ -0,0 +1,3 @@ +export function isPromiseLike(o: any): o is PromiseLike { + return typeof o === "object" && o !== null && "then" in o && typeof o.then === "function"; +} diff --git a/deno_dist/lab/PromiseOrNot.ts b/deno_dist/lab/PromiseOrNot.ts new file mode 100644 index 0000000..5ad9139 --- /dev/null +++ b/deno_dist/lab/PromiseOrNot.ts @@ -0,0 +1 @@ +export type PromiseOrNot = PromiseLike | T; diff --git a/deno_dist/lab/UnpackTypeGuard.ts b/deno_dist/lab/UnpackTypeGuard.ts new file mode 100644 index 0000000..7322b1e --- /dev/null +++ b/deno_dist/lab/UnpackTypeGuard.ts @@ -0,0 +1,3 @@ +export type UnpackTypeGuard o is unknown> = T extends (o: any) => o is infer U + ? U + : never; diff --git a/deno_dist/lab/defineAccessors.ts b/deno_dist/lab/defineAccessors.ts new file mode 100644 index 0000000..7fc7aa7 --- /dev/null +++ b/deno_dist/lab/defineAccessors.ts @@ -0,0 +1,31 @@ +export const defineAccessors = , K extends keyof T>( + obj: T, + propertyName: K, + propertyDescriptor: { + get?: () => T[K]; + set?: (value: T[K]) => void; + }, +): void => { + const { get, set } = propertyDescriptor; + + Object.defineProperty(obj, propertyName, { + ...(Object.getOwnPropertyDescriptor(obj, propertyName) || { + "enumerable": true, + "configurable": true, + }), + ...(get !== undefined + ? { + "get": function () { + return get.call(this); + }, + } + : {}), + ...(set !== undefined + ? { + "set": function (value: T[K]) { + set.call(this, value); + }, + } + : {}), + }); +}; diff --git a/deno_dist/lab/index.ts b/deno_dist/lab/index.ts new file mode 100644 index 0000000..f44eb08 --- /dev/null +++ b/deno_dist/lab/index.ts @@ -0,0 +1,5 @@ +export * from "./defineAccessors.ts"; +export * from "./overwriteReadonlyProp.ts"; +export * from "./PromiseOrNot.ts"; +export * from "./UnpackTypeGuard.ts"; +export * from "./withDefaults.ts"; diff --git a/deno_dist/lab/overwriteReadonlyProp.ts b/deno_dist/lab/overwriteReadonlyProp.ts new file mode 100644 index 0000000..e7b1495 --- /dev/null +++ b/deno_dist/lab/overwriteReadonlyProp.ts @@ -0,0 +1,46 @@ +/** + * Assign a value to a property even if the object is freezed or if the property is not writable + * Throw if the assignation fail ( for example if the property is non configurable write: false ) + * */ +export const overwriteReadonlyProp = ( + obj: T, + propertyName: K, + value: T[K], +): T[K] => { + try { + obj[propertyName] = value; + } catch {} + + if (obj[propertyName] === value) { + return value; + } + + let errorDefineProperty: Error | undefined = undefined; + + const propertyDescriptor: PropertyDescriptor = Object.getOwnPropertyDescriptor( + obj, + propertyName, + ) || { + "enumerable": true, + "configurable": true, + }; + + if (!!propertyDescriptor.get) { + throw new Error(`Probably a wrong ides to overwrite ${String(propertyName)} getter`); + } + + try { + Object.defineProperty(obj, propertyName, { + ...propertyDescriptor, + value, + }); + } catch (error) { + errorDefineProperty = error as Error; + } + + if (obj[propertyName] !== value) { + throw errorDefineProperty || new Error("Can't assign"); + } + + return value; +}; diff --git a/deno_dist/lab/withDefaults.ts b/deno_dist/lab/withDefaults.ts new file mode 100644 index 0000000..a789940 --- /dev/null +++ b/deno_dist/lab/withDefaults.ts @@ -0,0 +1,31 @@ +import "../tools/Object.fromEntries.ts"; +/** + * Like Function.prototype.bind() but for a function that + * receives their parameters wrapped in an object. + * See documentation for more details: + * https://docs.tsafe.dev/withdefaults + */ +export function withDefaults, DefaultKey extends keyof Params, R>( + f: (params: Params) => R, + defaultParams: keyof Params extends never + ? Record + : { [Key in DefaultKey]: Params[Key] }, +): ( + params: { [Key in keyof Omit]: Params[Key] } & { + defaultsOverwrite?: { [Key in DefaultKey]?: [Params[Key]] }; + }, +) => R { + return params => { + const { defaultsOverwrite = {}, ...actualParams } = params; + + return f({ + ...defaultParams, + ...actualParams, + ...Object.fromEntries( + Object.entries(defaultsOverwrite) + .filter(([, value]) => value !== undefined) + .map(([key, value]) => [key, (value as any)[0]]), + ), + } as any); + }; +} diff --git a/deno_dist/mod.ts b/deno_dist/mod.ts new file mode 100644 index 0000000..da5ee32 --- /dev/null +++ b/deno_dist/mod.ts @@ -0,0 +1 @@ +export * from "./index.ts"; \ No newline at end of file diff --git a/deno_dist/noUndefined.ts b/deno_dist/noUndefined.ts new file mode 100644 index 0000000..26dbe43 --- /dev/null +++ b/deno_dist/noUndefined.ts @@ -0,0 +1,21 @@ +/** + * Removes the enumerable properties whose values are + * undefined. + * + * Example: + * noUndefined({ "foo": undefined, "bar": 3 }) returns + * a new object { "bar": 3 } + */ +export function noUndefined(obj: T): T { + const out: typeof obj = {} as any; + + for (const key in obj) { + if (obj[key] === undefined) { + continue; + } + + out[key] = obj[key]; + } + + return out; +} diff --git a/deno_dist/objectEntries.ts b/deno_dist/objectEntries.ts new file mode 100644 index 0000000..024a1cb --- /dev/null +++ b/deno_dist/objectEntries.ts @@ -0,0 +1,12 @@ +/** https://docs.tsafe.dev/objectentries */ +export function objectEntries>( + o: O, +): Exclude<{ [Key in keyof O]: [Key, O[Key]] }[keyof O], undefined>[] { + return Object.entries(o) as any; +} + +/** Return type of objectEntries https://docs.tsafe.dev/objectentries */ +export type ObjectEntries> = Exclude< + { [Key in keyof O]: [Key, O[Key]] }[keyof O], + undefined +>[]; diff --git a/deno_dist/objectFromEntries.ts b/deno_dist/objectFromEntries.ts new file mode 100644 index 0000000..a41d042 --- /dev/null +++ b/deno_dist/objectFromEntries.ts @@ -0,0 +1,11 @@ +/** https://docs.tsafe.dev/objectFromEntries */ +export function objectFromEntries( + entries: readonly Entry[], +): { [Key in Entry[0]]: Extract[1] } { + return Object.fromEntries(entries) as any; +} + +/** Return type of objectFromEntries https://docs.tsafe.dev/objectFromEntries */ +export type ObjectFromEntries = { + [Key in Entry[0]]: Extract[1]; +}; diff --git a/deno_dist/objectKeys.ts b/deno_dist/objectKeys.ts new file mode 100644 index 0000000..0370131 --- /dev/null +++ b/deno_dist/objectKeys.ts @@ -0,0 +1,4 @@ +/** https://docs.tsafe.dev/objectKeys */ +export function objectKeys>(o: T): (keyof T)[] { + return Object.keys(o) as any; +} diff --git a/deno_dist/symToStr.ts b/deno_dist/symToStr.ts new file mode 100644 index 0000000..46219fe --- /dev/null +++ b/deno_dist/symToStr.ts @@ -0,0 +1,5 @@ +/** @see */ +export function symToStr>(wrap: T): Exclude { + // @ts-expect-error: We know better + return Object.keys(wrap)[0]; +} diff --git a/deno_dist/tools/Object.fromEntries.ts b/deno_dist/tools/Object.fromEntries.ts new file mode 100644 index 0000000..f29f19e --- /dev/null +++ b/deno_dist/tools/Object.fromEntries.ts @@ -0,0 +1,21 @@ +if (!(Object as any).fromEntries) { + Object.defineProperty(Object, "fromEntries", { + "value": function (entries: any) { + if (!entries || !entries[Symbol.iterator]) { + throw new Error("Object.fromEntries() requires a single iterable argument"); + } + + const o: any = {}; + + Object.keys(entries).forEach(key => { + const [k, v] = entries[key]; + + o[k] = v; + }); + + return o; + }, + }); +} + +export {}; diff --git a/deno_dist/tools/StrictEquals.ts b/deno_dist/tools/StrictEquals.ts new file mode 100644 index 0000000..73a5f76 --- /dev/null +++ b/deno_dist/tools/StrictEquals.ts @@ -0,0 +1,2 @@ +export type StrictEquals = + (() => A extends A2 ? true : false) extends () => A extends A1 ? true : false ? true : false; diff --git a/deno_dist/tools/Unite.ts b/deno_dist/tools/Unite.ts new file mode 100644 index 0000000..fc3014e --- /dev/null +++ b/deno_dist/tools/Unite.ts @@ -0,0 +1 @@ +export type Unite = T extends Record ? { [Key in keyof T]: T[Key] } : T; diff --git a/deno_dist/tools/index.ts b/deno_dist/tools/index.ts new file mode 100644 index 0000000..7e0312d --- /dev/null +++ b/deno_dist/tools/index.ts @@ -0,0 +1,4 @@ +export * from "./Object.fromEntries.ts"; +export * from "./StrictEquals.ts"; +export * from "./toUpperCase.ts"; +export * from "./Unite.ts"; diff --git a/deno_dist/tools/toUpperCase.ts b/deno_dist/tools/toUpperCase.ts new file mode 100644 index 0000000..a4d5672 --- /dev/null +++ b/deno_dist/tools/toUpperCase.ts @@ -0,0 +1,3 @@ +export function toUpperCase(str: string): string { + return str.toUpperCase(); +} diff --git a/deno_dist/typeGuard.ts b/deno_dist/typeGuard.ts new file mode 100644 index 0000000..9fcc4ff --- /dev/null +++ b/deno_dist/typeGuard.ts @@ -0,0 +1,4 @@ +/** https://docs.tsafe.dev/typeguard */ +export function typeGuard(value: any, isMatched: boolean): value is T { + return isMatched; +} diff --git a/deno_dist/uncapitalize.ts b/deno_dist/uncapitalize.ts new file mode 100644 index 0000000..ca3cf88 --- /dev/null +++ b/deno_dist/uncapitalize.ts @@ -0,0 +1,4 @@ +/** @see */ +export function uncapitalize(str: S): Uncapitalize { + return (str.charAt(0).toLowerCase() + str.slice(1)) as any; +} diff --git a/esm/Equals.d.ts b/esm/Equals.d.ts new file mode 100644 index 0000000..920a4e6 --- /dev/null +++ b/esm/Equals.d.ts @@ -0,0 +1,4 @@ +import type { Unite } from "./tools/Unite"; +import type { StrictEquals } from "./tools/StrictEquals"; +/** https://docs.tsafe.dev/main/equals */ +export type Equals = StrictEquals, Unite>; diff --git a/esm/Equals.mjs b/esm/Equals.mjs new file mode 100644 index 0000000..1493924 --- /dev/null +++ b/esm/Equals.mjs @@ -0,0 +1,2 @@ + +//# sourceMappingURL=Equals.mjs.map diff --git a/esm/Equals.mjs.map b/esm/Equals.mjs.map new file mode 100644 index 0000000..076e0f4 --- /dev/null +++ b/esm/Equals.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"Equals.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""} \ No newline at end of file diff --git a/esm/Extends.d.ts b/esm/Extends.d.ts new file mode 100644 index 0000000..e717d3c --- /dev/null +++ b/esm/Extends.d.ts @@ -0,0 +1,7 @@ +import type { StrictEquals } from "./tools/StrictEquals"; +/** + * @see + * + * Usage example: assert>(); + **/ +export type Extends = StrictEquals extends true ? true : StrictEquals extends true ? false : StrictEquals extends true ? true : StrictEquals extends true ? true : StrictEquals extends true ? false : StrictEquals extends true ? false : A1 extends A2 ? true : false; diff --git a/esm/Extends.mjs b/esm/Extends.mjs new file mode 100644 index 0000000..9253e05 --- /dev/null +++ b/esm/Extends.mjs @@ -0,0 +1,2 @@ + +//# sourceMappingURL=Extends.mjs.map diff --git a/esm/Extends.mjs.map b/esm/Extends.mjs.map new file mode 100644 index 0000000..30e5b73 --- /dev/null +++ b/esm/Extends.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"Extends.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""} \ No newline at end of file diff --git a/esm/MethodNames.d.ts b/esm/MethodNames.d.ts new file mode 100644 index 0000000..fb2595b --- /dev/null +++ b/esm/MethodNames.d.ts @@ -0,0 +1,4 @@ +/** https://docs.tsafe.dev/methodnames */ +export type MethodNames = Exclude<{ + [Key in keyof Api]: Api[Key] extends ((...args: any[]) => unknown) | undefined ? Key : never; +}[keyof Api], null | undefined>; diff --git a/esm/MethodNames.mjs b/esm/MethodNames.mjs new file mode 100644 index 0000000..5313e5f --- /dev/null +++ b/esm/MethodNames.mjs @@ -0,0 +1,2 @@ + +//# sourceMappingURL=MethodNames.mjs.map diff --git a/esm/MethodNames.mjs.map b/esm/MethodNames.mjs.map new file mode 100644 index 0000000..4836192 --- /dev/null +++ b/esm/MethodNames.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"MethodNames.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""} \ No newline at end of file diff --git a/esm/Not.d.ts b/esm/Not.d.ts new file mode 100644 index 0000000..c5bd642 --- /dev/null +++ b/esm/Not.d.ts @@ -0,0 +1,2 @@ +/** https://docs.tsafe.dev/main/not */ +export type Not = B extends true ? false : true; diff --git a/esm/Not.mjs b/esm/Not.mjs new file mode 100644 index 0000000..135ba2c --- /dev/null +++ b/esm/Not.mjs @@ -0,0 +1,2 @@ + +//# sourceMappingURL=Not.mjs.map diff --git a/esm/Not.mjs.map b/esm/Not.mjs.map new file mode 100644 index 0000000..2064203 --- /dev/null +++ b/esm/Not.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"Not.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""} \ No newline at end of file diff --git a/esm/Param0.d.ts b/esm/Param0.d.ts new file mode 100644 index 0000000..d33232f --- /dev/null +++ b/esm/Param0.d.ts @@ -0,0 +1,7 @@ +import type { Parameters } from "./Parameters"; +type NonUndefined = T extends undefined ? never : T; +/** Shorthand for Parameters[0] https://docs.tsafe.dev/param0 */ +export type Param0 unknown) | null | undefined | false | ""> = [ + Parameters +] extends [never] ? never : Parameters extends [] ? void : NonUndefined[0]>; +export {}; diff --git a/esm/Param0.mjs b/esm/Param0.mjs new file mode 100644 index 0000000..11b24a8 --- /dev/null +++ b/esm/Param0.mjs @@ -0,0 +1,2 @@ + +//# sourceMappingURL=Param0.mjs.map diff --git a/esm/Param0.mjs.map b/esm/Param0.mjs.map new file mode 100644 index 0000000..ae729c9 --- /dev/null +++ b/esm/Param0.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"Param0.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""} \ No newline at end of file diff --git a/esm/Parameters.d.ts b/esm/Parameters.d.ts new file mode 100644 index 0000000..dfc7e7c --- /dev/null +++ b/esm/Parameters.d.ts @@ -0,0 +1,2 @@ +/** https://docs.tsafe.dev/parameters */ +export type Parameters unknown) | null | undefined | false | ""> = T extends (...args: infer P) => any ? P : never; diff --git a/esm/Parameters.mjs b/esm/Parameters.mjs new file mode 100644 index 0000000..d161505 --- /dev/null +++ b/esm/Parameters.mjs @@ -0,0 +1,2 @@ + +//# sourceMappingURL=Parameters.mjs.map diff --git a/esm/Parameters.mjs.map b/esm/Parameters.mjs.map new file mode 100644 index 0000000..e4f336b --- /dev/null +++ b/esm/Parameters.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"Parameters.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""} \ No newline at end of file diff --git a/esm/PickOptionals.d.ts b/esm/PickOptionals.d.ts new file mode 100644 index 0000000..dac7923 --- /dev/null +++ b/esm/PickOptionals.d.ts @@ -0,0 +1,10 @@ +type OptionalKeyof> = Exclude<{ + [Key in keyof T]: T extends Record ? never : Key; +}[keyof T], undefined>; +/** + * PickOptionals<{ p1: string; p2?: string; p3?: number; }> + * is the type + * { p2: string; p3: number; } + */ +export type PickOptionals> = Required>>; +export {}; diff --git a/esm/PickOptionals.mjs b/esm/PickOptionals.mjs new file mode 100644 index 0000000..606a5a4 --- /dev/null +++ b/esm/PickOptionals.mjs @@ -0,0 +1,2 @@ + +//# sourceMappingURL=PickOptionals.mjs.map diff --git a/esm/PickOptionals.mjs.map b/esm/PickOptionals.mjs.map new file mode 100644 index 0000000..e658831 --- /dev/null +++ b/esm/PickOptionals.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"PickOptionals.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""} \ No newline at end of file diff --git a/esm/PickRequired.d.ts b/esm/PickRequired.d.ts new file mode 100644 index 0000000..72aaa23 --- /dev/null +++ b/esm/PickRequired.d.ts @@ -0,0 +1,7 @@ +import { PickOptionals } from "./PickOptionals"; +/** + * PickRequired<{ p1: string; p2?: string; p3?: number; p4: string; }> + * is the type + * { p1: string; p4: number; } + */ +export type PickRequired> = Omit>; diff --git a/esm/PickRequired.mjs b/esm/PickRequired.mjs new file mode 100644 index 0000000..d8792fe --- /dev/null +++ b/esm/PickRequired.mjs @@ -0,0 +1,2 @@ + +//# sourceMappingURL=PickRequired.mjs.map diff --git a/esm/PickRequired.mjs.map b/esm/PickRequired.mjs.map new file mode 100644 index 0000000..c554751 --- /dev/null +++ b/esm/PickRequired.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"PickRequired.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""} \ No newline at end of file diff --git a/esm/Reflect.d.ts b/esm/Reflect.d.ts new file mode 100644 index 0000000..fa64428 --- /dev/null +++ b/esm/Reflect.d.ts @@ -0,0 +1,2 @@ +/** Always return null but pretends it returns an object of type T */ +export declare function Reflect(): T; diff --git a/esm/Reflect.mjs b/esm/Reflect.mjs new file mode 100644 index 0000000..00aa418 --- /dev/null +++ b/esm/Reflect.mjs @@ -0,0 +1,7 @@ +/** Always return null but pretends it returns an object of type T */ +function Reflect() { + return null; +} + +export { Reflect }; +//# sourceMappingURL=Reflect.mjs.map diff --git a/esm/Reflect.mjs.map b/esm/Reflect.mjs.map new file mode 100644 index 0000000..a51b105 --- /dev/null +++ b/esm/Reflect.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"Reflect.mjs","sources":["../dist/src/Reflect.ts"],"sourcesContent":["/** Always return null but pretends it returns an object of type T */\nexport function Reflect(): T {\n return null as any;\n}\n"],"names":[],"mappings":"AAAA;SACgB,OAAO,GAAA;AACnB,IAAA,OAAO,IAAW,CAAC;AACvB;;;;"} \ No newline at end of file diff --git a/esm/ReturnType.d.ts b/esm/ReturnType.d.ts new file mode 100644 index 0000000..0e00b32 --- /dev/null +++ b/esm/ReturnType.d.ts @@ -0,0 +1,2 @@ +/** https://docs.tsafe.dev/returntype */ +export type ReturnType unknown) | undefined | null | false | ""> = T extends (...args: any[]) => infer R ? (R extends PromiseLike ? J : R) : never; diff --git a/esm/ReturnType.mjs b/esm/ReturnType.mjs new file mode 100644 index 0000000..f10fb00 --- /dev/null +++ b/esm/ReturnType.mjs @@ -0,0 +1,2 @@ + +//# sourceMappingURL=ReturnType.mjs.map diff --git a/esm/ReturnType.mjs.map b/esm/ReturnType.mjs.map new file mode 100644 index 0000000..2121984 --- /dev/null +++ b/esm/ReturnType.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"ReturnType.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""} \ No newline at end of file diff --git a/esm/UnionToIntersection.d.ts b/esm/UnionToIntersection.d.ts new file mode 100644 index 0000000..aee401b --- /dev/null +++ b/esm/UnionToIntersection.d.ts @@ -0,0 +1,2 @@ +/** @see **/ +export type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; diff --git a/esm/UnionToIntersection.mjs b/esm/UnionToIntersection.mjs new file mode 100644 index 0000000..10b0439 --- /dev/null +++ b/esm/UnionToIntersection.mjs @@ -0,0 +1,2 @@ + +//# sourceMappingURL=UnionToIntersection.mjs.map diff --git a/esm/UnionToIntersection.mjs.map b/esm/UnionToIntersection.mjs.map new file mode 100644 index 0000000..2fa5c74 --- /dev/null +++ b/esm/UnionToIntersection.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"UnionToIntersection.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""} \ No newline at end of file diff --git a/esm/UnpackPromise.d.ts b/esm/UnpackPromise.d.ts new file mode 100644 index 0000000..826dad4 --- /dev/null +++ b/esm/UnpackPromise.d.ts @@ -0,0 +1,6 @@ +/** + * Use case: + * declare const pr: Promise; + * const x: UnpackPromise; <== x is string[] + */ +export type UnpackPromise | undefined | null | false | ""> = T extends PromiseLike ? U : never; diff --git a/esm/UnpackPromise.mjs b/esm/UnpackPromise.mjs new file mode 100644 index 0000000..a5b12a9 --- /dev/null +++ b/esm/UnpackPromise.mjs @@ -0,0 +1,2 @@ + +//# sourceMappingURL=UnpackPromise.mjs.map diff --git a/esm/UnpackPromise.mjs.map b/esm/UnpackPromise.mjs.map new file mode 100644 index 0000000..3d25685 --- /dev/null +++ b/esm/UnpackPromise.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"UnpackPromise.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""} \ No newline at end of file diff --git a/esm/assert.d.ts b/esm/assert.d.ts new file mode 100644 index 0000000..d88b0c2 --- /dev/null +++ b/esm/assert.d.ts @@ -0,0 +1,10 @@ +export type { Equals } from "./Equals"; +/** https://docs.tsafe.dev/assert#error-thrown */ +export declare class AssertionError extends Error { + originalMessage?: string; + constructor(msg: string | undefined); +} +/** https://docs.tsafe.dev/assert */ +export declare function assert<_T extends true>(condition?: any, msg?: string | (() => string)): asserts condition; +/** https://docs.tsafe.dev/is */ +export declare function is(value: any): value is T; diff --git a/esm/assert.mjs b/esm/assert.mjs new file mode 100644 index 0000000..06c2e2e --- /dev/null +++ b/esm/assert.mjs @@ -0,0 +1,53 @@ +import { overwriteReadonlyProp } from './lab/overwriteReadonlyProp.mjs'; + +/** https://docs.tsafe.dev/assert#error-thrown */ +class AssertionError extends Error { + constructor(msg) { + super(`Wrong assertion encountered` + (!msg ? "" : `: "${msg}"`)); + this.originalMessage = msg; + Object.setPrototypeOf(this, new.target.prototype); + if (!this.stack) { + return; + } + try { + overwriteReadonlyProp(this, "stack", this.stack + .split("\n") + .filter((...[, i]) => i !== 1 && i !== 2) + .join("\n")); + } + catch { } + } +} +let refOfIs = undefined; +/** https://docs.tsafe.dev/assert */ +function assert(condition, msg) { + if (arguments.length === 0) { + condition = true; + } + if (refOfIs !== undefined) { + refOfIs = undefined; + return; + } + if (!condition) { + throw new AssertionError(typeof msg === "function" ? msg() : msg); + } +} +const errorMessage = "Wrong usage of the `is` function refer to https://docs.tsafe.dev/is"; +/** https://docs.tsafe.dev/is */ +function is(value) { + const ref = {}; + if (refOfIs !== undefined) { + refOfIs = undefined; + throw new Error(errorMessage); + } + refOfIs = ref; + Promise.resolve().then(() => { + if (refOfIs === ref) { + throw new Error(errorMessage); + } + }); + return null; +} + +export { AssertionError, assert, is }; +//# sourceMappingURL=assert.mjs.map diff --git a/esm/assert.mjs.map b/esm/assert.mjs.map new file mode 100644 index 0000000..b632c47 --- /dev/null +++ b/esm/assert.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"assert.mjs","sources":["../dist/src/assert.ts"],"sourcesContent":["import { overwriteReadonlyProp } from \"./lab/overwriteReadonlyProp\";\nexport type { Equals } from \"./Equals\";\n\n/** https://docs.tsafe.dev/assert#error-thrown */\nexport class AssertionError extends Error {\n originalMessage?: string;\n\n constructor(msg: string | undefined) {\n super(`Wrong assertion encountered` + (!msg ? \"\" : `: \"${msg}\"`));\n\n this.originalMessage = msg;\n\n Object.setPrototypeOf(this, new.target.prototype);\n\n if (!this.stack) {\n return;\n }\n\n try {\n overwriteReadonlyProp(\n this,\n \"stack\",\n this.stack\n .split(\"\\n\")\n .filter((...[, i]) => i !== 1 && i !== 2)\n .join(\"\\n\"),\n );\n } catch {}\n }\n}\n\nlet refOfIs: undefined | Record = undefined;\n\n/** https://docs.tsafe.dev/assert */\nexport function assert<_T extends true>(\n condition?: any,\n msg?: string | (() => string),\n): asserts condition {\n if (arguments.length === 0) {\n condition = true;\n }\n if (refOfIs !== undefined) {\n refOfIs = undefined;\n return;\n }\n\n if (!condition) {\n throw new AssertionError(typeof msg === \"function\" ? msg() : msg);\n }\n}\n\nconst errorMessage = \"Wrong usage of the `is` function refer to https://docs.tsafe.dev/is\";\n\n/** https://docs.tsafe.dev/is */\nexport function is(value: any): value is T {\n const ref = {};\n\n if (refOfIs !== undefined) {\n refOfIs = undefined;\n throw new Error(errorMessage);\n }\n\n refOfIs = ref;\n\n Promise.resolve().then(() => {\n if (refOfIs === ref) {\n throw new Error(errorMessage);\n }\n });\n\n return null as any;\n}\n"],"names":[],"mappings":";;AAGA;AACM,MAAO,cAAe,SAAQ,KAAK,CAAA;AAGrC,IAAA,WAAA,CAAY,GAAuB,EAAA;AAC/B,QAAA,KAAK,CAAC,CAA6B,2BAAA,CAAA,IAAI,CAAC,GAAG,GAAG,EAAE,GAAG,CAAA,GAAA,EAAM,GAAG,CAAG,CAAA,CAAA,CAAC,CAAC,CAAC;AAElE,QAAA,IAAI,CAAC,eAAe,GAAG,GAAG,CAAC;QAE3B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAElD,QAAA,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACb,OAAO;SACV;AAED,QAAA,IAAI;AACA,YAAA,qBAAqB,CACjB,IAAI,EACJ,OAAO,EACP,IAAI,CAAC,KAAK;iBACL,KAAK,CAAC,IAAI,CAAC;AACX,iBAAA,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACxC,iBAAA,IAAI,CAAC,IAAI,CAAC,CAClB,CAAC;SACL;QAAC,MAAM,GAAE;KACb;AACJ,CAAA;AAED,IAAI,OAAO,GAAsC,SAAS,CAAC;AAE3D;AACgB,SAAA,MAAM,CAClB,SAAe,EACf,GAA6B,EAAA;AAE7B,IAAA,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,SAAS,GAAG,IAAI,CAAC;KACpB;AACD,IAAA,IAAI,OAAO,KAAK,SAAS,EAAE;QACvB,OAAO,GAAG,SAAS,CAAC;QACpB,OAAO;KACV;IAED,IAAI,CAAC,SAAS,EAAE;AACZ,QAAA,MAAM,IAAI,cAAc,CAAC,OAAO,GAAG,KAAK,UAAU,GAAG,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;KACrE;AACL,CAAC;AAED,MAAM,YAAY,GAAG,qEAAqE,CAAC;AAE3F;AACM,SAAU,EAAE,CAAI,KAAU,EAAA;IAC5B,MAAM,GAAG,GAAG,EAAE,CAAC;AAEf,IAAA,IAAI,OAAO,KAAK,SAAS,EAAE;QACvB,OAAO,GAAG,SAAS,CAAC;AACpB,QAAA,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;KACjC;IAED,OAAO,GAAG,GAAG,CAAC;AAEd,IAAA,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,MAAK;AACxB,QAAA,IAAI,OAAO,KAAK,GAAG,EAAE;AACjB,YAAA,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;SACjC;AACL,KAAC,CAAC,CAAC;AAEH,IAAA,OAAO,IAAW,CAAC;AACvB;;;;"} \ No newline at end of file diff --git a/esm/capitalize.d.ts b/esm/capitalize.d.ts new file mode 100644 index 0000000..cbd5235 --- /dev/null +++ b/esm/capitalize.d.ts @@ -0,0 +1,2 @@ +/** @see */ +export declare function capitalize(str: S): Capitalize; diff --git a/esm/capitalize.mjs b/esm/capitalize.mjs new file mode 100644 index 0000000..74a3e0f --- /dev/null +++ b/esm/capitalize.mjs @@ -0,0 +1,7 @@ +/** @see */ +function capitalize(str) { + return (str.charAt(0).toUpperCase() + str.slice(1)); +} + +export { capitalize }; +//# sourceMappingURL=capitalize.mjs.map diff --git a/esm/capitalize.mjs.map b/esm/capitalize.mjs.map new file mode 100644 index 0000000..c5c01b6 --- /dev/null +++ b/esm/capitalize.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"capitalize.mjs","sources":["../dist/src/capitalize.ts"],"sourcesContent":["/** @see */\nexport function capitalize(str: S): Capitalize {\n return (str.charAt(0).toUpperCase() + str.slice(1)) as any;\n}\n"],"names":[],"mappings":"AAAA;AACM,SAAU,UAAU,CAAmB,GAAM,EAAA;AAC/C,IAAA,QAAQ,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAS;AAC/D;;;;"} \ No newline at end of file diff --git a/esm/exclude.d.ts b/esm/exclude.d.ts new file mode 100644 index 0000000..e457148 --- /dev/null +++ b/esm/exclude.d.ts @@ -0,0 +1,9 @@ +/** + * https://docs.tsafe.dev/exclude + * + * Return a function to use as Array.prototype.filter argument + * to exclude one or many primitive value element from the array. + * Ex: ([ "a", "b", "c" ] as const).filter(exclude("a")) return ("b" | "c")[] + * Ex: ([ "a", "b", "c", "d"] as const).filter(exclude(["a", "b"]) gives ("c" | "d")[] + */ +export declare function exclude(target: readonly T[] | T): (element: U) => element is Exclude; diff --git a/esm/exclude.mjs b/esm/exclude.mjs new file mode 100644 index 0000000..caab983 --- /dev/null +++ b/esm/exclude.mjs @@ -0,0 +1,19 @@ +/** + * https://docs.tsafe.dev/exclude + * + * Return a function to use as Array.prototype.filter argument + * to exclude one or many primitive value element from the array. + * Ex: ([ "a", "b", "c" ] as const).filter(exclude("a")) return ("b" | "c")[] + * Ex: ([ "a", "b", "c", "d"] as const).filter(exclude(["a", "b"]) gives ("c" | "d")[] + */ +function exclude(target) { + const test = target instanceof Object + ? element => target.indexOf(element) < 0 + : element => element !== target; + return function (element) { + return test(element); + }; +} + +export { exclude }; +//# sourceMappingURL=exclude.mjs.map diff --git a/esm/exclude.mjs.map b/esm/exclude.mjs.map new file mode 100644 index 0000000..4031a58 --- /dev/null +++ b/esm/exclude.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"exclude.mjs","sources":["../dist/src/exclude.ts"],"sourcesContent":["/**\n * https://docs.tsafe.dev/exclude\n *\n * Return a function to use as Array.prototype.filter argument\n * to exclude one or many primitive value element from the array.\n * Ex: ([ \"a\", \"b\", \"c\" ] as const).filter(exclude(\"a\")) return (\"b\" | \"c\")[]\n * Ex: ([ \"a\", \"b\", \"c\", \"d\"] as const).filter(exclude([\"a\", \"b\"]) gives (\"c\" | \"d\")[]\n */\nexport function exclude(\n target: readonly T[] | T,\n) {\n const test: (element: any) => boolean =\n target instanceof Object\n ? element => target.indexOf(element) < 0\n : element => element !== target;\n\n return function (element: U): element is Exclude {\n return test(element);\n };\n}\n"],"names":[],"mappings":"AAAA;;;;;;;AAOG;AACG,SAAU,OAAO,CACnB,MAAwB,EAAA;AAExB,IAAA,MAAM,IAAI,GACN,MAAM,YAAY,MAAM;AACpB,UAAE,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;UACtC,OAAO,IAAI,OAAO,KAAK,MAAM,CAAC;AAExC,IAAA,OAAO,UAAa,OAAU,EAAA;AAC1B,QAAA,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;AACzB,KAAC,CAAC;AACN;;;;"} \ No newline at end of file diff --git a/esm/flip.d.ts b/esm/flip.d.ts new file mode 100644 index 0000000..54c63f2 --- /dev/null +++ b/esm/flip.d.ts @@ -0,0 +1,10 @@ +type KeyOfType, U> = NonNullable<{ + [Key in keyof T]: T[Key] extends U | undefined ? Key : never; +}[keyof T]>; +/** + * Flip the value of a boolean without having to reference it twice + * after running flip(x.y, "z") x.y.z !== x.y.z, + * https://docs.tsafe.dev/flip + */ +export declare function flip>(object: T, prop: KeyOfType): any; +export {}; diff --git a/esm/flip.mjs b/esm/flip.mjs new file mode 100644 index 0000000..3ca9b73 --- /dev/null +++ b/esm/flip.mjs @@ -0,0 +1,14 @@ +/** + * Flip the value of a boolean without having to reference it twice + * after running flip(x.y, "z") x.y.z !== x.y.z, + * https://docs.tsafe.dev/flip + */ +function flip(object, prop) { + if (object[prop] === undefined) { + return; + } + return (object[prop] = !object[prop]); +} + +export { flip }; +//# sourceMappingURL=flip.mjs.map diff --git a/esm/flip.mjs.map b/esm/flip.mjs.map new file mode 100644 index 0000000..20cb7b3 --- /dev/null +++ b/esm/flip.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"flip.mjs","sources":["../dist/src/flip.ts"],"sourcesContent":["type KeyOfType, U> = NonNullable<\n {\n [Key in keyof T]: T[Key] extends U | undefined ? Key : never;\n }[keyof T]\n>;\n\n/**\n * Flip the value of a boolean without having to reference it twice\n * after running flip(x.y, \"z\") x.y.z !== x.y.z,\n * https://docs.tsafe.dev/flip\n */\nexport function flip>(object: T, prop: KeyOfType) {\n if (object[prop] === undefined) {\n return;\n }\n\n return (object[prop] = !object[prop] as any);\n}\n"],"names":[],"mappings":"AAMA;;;;AAIG;AACa,SAAA,IAAI,CAAgC,MAAS,EAAE,IAA2B,EAAA;AACtF,IAAA,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE;QAC5B,OAAO;KACV;AAED,IAAA,QAAQ,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAQ,EAAE;AACjD;;;;"} \ No newline at end of file diff --git a/esm/id.d.ts b/esm/id.d.ts new file mode 100644 index 0000000..e3e6d46 --- /dev/null +++ b/esm/id.d.ts @@ -0,0 +1,36 @@ +/** https://docs.tsafe.dev/id */ +export declare const id: (x: T) => T; +/** + * Ensure that a that a specific type that we are declaring extends a more generic type + * + * Use case example 1: + * + * type MyObject = { + * p1: string; + * p2: string; + * a: string; + * b: string; + * }; + * + * We want to define a type that consist in an union of + * all the property name that are letters: + * + * type AlphabeticalKeys = Id; + * + * Here AlphabeticalKeys is "a" | "b" but it's better than + * simply writing it explicitly as we get autocompletion + * and we can't include a property name that does not exist on MyObject. + * + * Use case example 2: + * + * We want to declare object type that only take string or number + * as key value: + * + * export type MyObject = Id, { + * p1: string; + * p2: number; + * }>; + * + * If later on someone adds "p3": string[] he will get a type error. + * */ +export type Id = Specific; diff --git a/esm/id.mjs b/esm/id.mjs new file mode 100644 index 0000000..968e96e --- /dev/null +++ b/esm/id.mjs @@ -0,0 +1,5 @@ +/** https://docs.tsafe.dev/id */ +const id = (x) => x; + +export { id }; +//# sourceMappingURL=id.mjs.map diff --git a/esm/id.mjs.map b/esm/id.mjs.map new file mode 100644 index 0000000..af2a47a --- /dev/null +++ b/esm/id.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"id.mjs","sources":["../dist/src/id.ts"],"sourcesContent":["/** https://docs.tsafe.dev/id */\nexport const id = (x: T) => x;\n\n/**\n * Ensure that a that a specific type that we are declaring extends a more generic type\n *\n * Use case example 1:\n *\n * type MyObject = {\n * p1: string;\n * p2: string;\n * a: string;\n * b: string;\n * };\n *\n * We want to define a type that consist in an union of\n * all the property name that are letters:\n *\n * type AlphabeticalKeys = Id;\n *\n * Here AlphabeticalKeys is \"a\" | \"b\" but it's better than\n * simply writing it explicitly as we get autocompletion\n * and we can't include a property name that does not exist on MyObject.\n *\n * Use case example 2:\n *\n * We want to declare object type that only take string or number\n * as key value:\n *\n * export type MyObject = Id, {\n * p1: string;\n * p2: number;\n * }>;\n *\n * If later on someone adds \"p3\": string[] he will get a type error.\n * */\nexport type Id = Specific;\n"],"names":[],"mappings":"AAAA;AACa,MAAA,EAAE,GAAG,CAAI,CAAI,KAAK;;;;"} \ No newline at end of file diff --git a/esm/index.d.ts b/esm/index.d.ts new file mode 100644 index 0000000..051554b --- /dev/null +++ b/esm/index.d.ts @@ -0,0 +1,26 @@ +export * from "./assert"; +export * from "./exclude"; +export * from "./flip"; +export * from "./id"; +export * from "./isPromiseLike"; +export type { MethodNames } from "./MethodNames"; +export * from "./objectKeys"; +export type { Parameters } from "./Parameters"; +export type { Param0 } from "./Param0"; +export type { PickOptionals } from "./PickOptionals"; +export type { PickRequired } from "./PickRequired"; +export type { ReturnType } from "./ReturnType"; +export * from "./typeGuard"; +export type { UnpackPromise } from "./UnpackPromise"; +export * from "./isAmong"; +export type { Equals } from "./Equals"; +export type { Extends } from "./Extends"; +export type { Not } from "./Not"; +export type { UnionToIntersection } from "./UnionToIntersection"; +export * from "./objectEntries"; +export * from "./objectFromEntries"; +export * from "./noUndefined"; +export * from "./Reflect"; +export * from "./capitalize"; +export * from "./uncapitalize"; +export * from "./symToStr"; diff --git a/esm/index.mjs b/esm/index.mjs new file mode 100644 index 0000000..bae7a45 --- /dev/null +++ b/esm/index.mjs @@ -0,0 +1,16 @@ +export { AssertionError, assert, is } from './assert.mjs'; +export { exclude } from './exclude.mjs'; +export { flip } from './flip.mjs'; +export { id } from './id.mjs'; +export { isPromiseLike } from './isPromiseLike.mjs'; +export { objectKeys } from './objectKeys.mjs'; +export { typeGuard } from './typeGuard.mjs'; +export { isAmong } from './isAmong.mjs'; +export { objectEntries } from './objectEntries.mjs'; +export { objectFromEntries } from './objectFromEntries.mjs'; +export { noUndefined } from './noUndefined.mjs'; +export { Reflect } from './Reflect.mjs'; +export { capitalize } from './capitalize.mjs'; +export { uncapitalize } from './uncapitalize.mjs'; +export { symToStr } from './symToStr.mjs'; +//# sourceMappingURL=index.mjs.map diff --git a/esm/index.mjs.map b/esm/index.mjs.map new file mode 100644 index 0000000..83a6634 --- /dev/null +++ b/esm/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/esm/is.d.ts b/esm/is.d.ts new file mode 100644 index 0000000..faa2f6f --- /dev/null +++ b/esm/is.d.ts @@ -0,0 +1,8 @@ +import { is } from "./assert"; +/** + * @deprecated: Prefer importing using `import { assert, is } from "tsafe/assert"` + * or `import { assert, is } from "tsafe"` + * + * https://docs.tsafe.dev/is + * */ +export { is }; diff --git a/esm/is.mjs b/esm/is.mjs new file mode 100644 index 0000000..63a641c --- /dev/null +++ b/esm/is.mjs @@ -0,0 +1,2 @@ +export { is } from './assert.mjs'; +//# sourceMappingURL=is.mjs.map diff --git a/esm/is.mjs.map b/esm/is.mjs.map new file mode 100644 index 0000000..9b6c5f9 --- /dev/null +++ b/esm/is.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"is.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""} \ No newline at end of file diff --git a/esm/isAmong.d.ts b/esm/isAmong.d.ts new file mode 100644 index 0000000..9e7618a --- /dev/null +++ b/esm/isAmong.d.ts @@ -0,0 +1,2 @@ +/** https://docs.tsafe.dev/isamong */ +export declare function isAmong(names: readonly Name[], value: unknown): value is Name; diff --git a/esm/isAmong.mjs b/esm/isAmong.mjs new file mode 100644 index 0000000..ef61951 --- /dev/null +++ b/esm/isAmong.mjs @@ -0,0 +1,12 @@ +/** https://docs.tsafe.dev/isamong */ +function isAmong(names, value) { + for (const name of names) { + if (name === value) { + return true; + } + } + return false; +} + +export { isAmong }; +//# sourceMappingURL=isAmong.mjs.map diff --git a/esm/isAmong.mjs.map b/esm/isAmong.mjs.map new file mode 100644 index 0000000..2e62d95 --- /dev/null +++ b/esm/isAmong.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"isAmong.mjs","sources":["../dist/src/isAmong.ts"],"sourcesContent":["/** https://docs.tsafe.dev/isamong */\nexport function isAmong(\n names: readonly Name[],\n value: unknown,\n): value is Name {\n for (const name of names) {\n if (name === value) {\n return true;\n }\n }\n return false;\n}\n"],"names":[],"mappings":"AAAA;AACgB,SAAA,OAAO,CACnB,KAAsB,EACtB,KAAc,EAAA;AAEd,IAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;AACtB,QAAA,IAAI,IAAI,KAAK,KAAK,EAAE;AAChB,YAAA,OAAO,IAAI,CAAC;SACf;KACJ;AACD,IAAA,OAAO,KAAK,CAAC;AACjB;;;;"} \ No newline at end of file diff --git a/esm/isPromiseLike.d.ts b/esm/isPromiseLike.d.ts new file mode 100644 index 0000000..e881cb9 --- /dev/null +++ b/esm/isPromiseLike.d.ts @@ -0,0 +1 @@ +export declare function isPromiseLike(o: any): o is PromiseLike; diff --git a/esm/isPromiseLike.mjs b/esm/isPromiseLike.mjs new file mode 100644 index 0000000..824491e --- /dev/null +++ b/esm/isPromiseLike.mjs @@ -0,0 +1,6 @@ +function isPromiseLike(o) { + return typeof o === "object" && o !== null && "then" in o && typeof o.then === "function"; +} + +export { isPromiseLike }; +//# sourceMappingURL=isPromiseLike.mjs.map diff --git a/esm/isPromiseLike.mjs.map b/esm/isPromiseLike.mjs.map new file mode 100644 index 0000000..a5ca356 --- /dev/null +++ b/esm/isPromiseLike.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"isPromiseLike.mjs","sources":["../dist/src/isPromiseLike.ts"],"sourcesContent":["export function isPromiseLike(o: any): o is PromiseLike {\n return typeof o === \"object\" && o !== null && \"then\" in o && typeof o.then === \"function\";\n}\n"],"names":[],"mappings":"AAAM,SAAU,aAAa,CAAW,CAAM,EAAA;AAC1C,IAAA,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,MAAM,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC;AAC9F;;;;"} \ No newline at end of file diff --git a/esm/lab/PromiseOrNot.d.ts b/esm/lab/PromiseOrNot.d.ts new file mode 100644 index 0000000..5ad9139 --- /dev/null +++ b/esm/lab/PromiseOrNot.d.ts @@ -0,0 +1 @@ +export type PromiseOrNot = PromiseLike | T; diff --git a/esm/lab/PromiseOrNot.mjs b/esm/lab/PromiseOrNot.mjs new file mode 100644 index 0000000..2e1ed78 --- /dev/null +++ b/esm/lab/PromiseOrNot.mjs @@ -0,0 +1,2 @@ + +//# sourceMappingURL=PromiseOrNot.mjs.map diff --git a/esm/lab/PromiseOrNot.mjs.map b/esm/lab/PromiseOrNot.mjs.map new file mode 100644 index 0000000..e8b2a28 --- /dev/null +++ b/esm/lab/PromiseOrNot.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"PromiseOrNot.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""} \ No newline at end of file diff --git a/esm/lab/UnpackTypeGuard.d.ts b/esm/lab/UnpackTypeGuard.d.ts new file mode 100644 index 0000000..af4fc37 --- /dev/null +++ b/esm/lab/UnpackTypeGuard.d.ts @@ -0,0 +1 @@ +export type UnpackTypeGuard o is unknown> = T extends (o: any) => o is infer U ? U : never; diff --git a/esm/lab/UnpackTypeGuard.mjs b/esm/lab/UnpackTypeGuard.mjs new file mode 100644 index 0000000..0b93ee1 --- /dev/null +++ b/esm/lab/UnpackTypeGuard.mjs @@ -0,0 +1,2 @@ + +//# sourceMappingURL=UnpackTypeGuard.mjs.map diff --git a/esm/lab/UnpackTypeGuard.mjs.map b/esm/lab/UnpackTypeGuard.mjs.map new file mode 100644 index 0000000..b91bff6 --- /dev/null +++ b/esm/lab/UnpackTypeGuard.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"UnpackTypeGuard.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""} \ No newline at end of file diff --git a/esm/lab/defineAccessors.d.ts b/esm/lab/defineAccessors.d.ts new file mode 100644 index 0000000..7153521 --- /dev/null +++ b/esm/lab/defineAccessors.d.ts @@ -0,0 +1,4 @@ +export declare const defineAccessors: , K extends keyof T>(obj: T, propertyName: K, propertyDescriptor: { + get?: () => T[K]; + set?: (value: T[K]) => void; +}) => void; diff --git a/esm/lab/defineAccessors.mjs b/esm/lab/defineAccessors.mjs new file mode 100644 index 0000000..bdf9add --- /dev/null +++ b/esm/lab/defineAccessors.mjs @@ -0,0 +1,26 @@ +const defineAccessors = (obj, propertyName, propertyDescriptor) => { + const { get, set } = propertyDescriptor; + Object.defineProperty(obj, propertyName, { + ...(Object.getOwnPropertyDescriptor(obj, propertyName) || { + "enumerable": true, + "configurable": true, + }), + ...(get !== undefined + ? { + "get": function () { + return get.call(this); + }, + } + : {}), + ...(set !== undefined + ? { + "set": function (value) { + set.call(this, value); + }, + } + : {}), + }); +}; + +export { defineAccessors }; +//# sourceMappingURL=defineAccessors.mjs.map diff --git a/esm/lab/defineAccessors.mjs.map b/esm/lab/defineAccessors.mjs.map new file mode 100644 index 0000000..3c6a66a --- /dev/null +++ b/esm/lab/defineAccessors.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"defineAccessors.mjs","sources":["../../dist/src/lab/defineAccessors.ts"],"sourcesContent":["export const defineAccessors = , K extends keyof T>(\n obj: T,\n propertyName: K,\n propertyDescriptor: {\n get?: () => T[K];\n set?: (value: T[K]) => void;\n },\n): void => {\n const { get, set } = propertyDescriptor;\n\n Object.defineProperty(obj, propertyName, {\n ...(Object.getOwnPropertyDescriptor(obj, propertyName) || {\n \"enumerable\": true,\n \"configurable\": true,\n }),\n ...(get !== undefined\n ? {\n \"get\": function () {\n return get.call(this);\n },\n }\n : {}),\n ...(set !== undefined\n ? {\n \"set\": function (value: T[K]) {\n set.call(this, value);\n },\n }\n : {}),\n });\n};\n"],"names":[],"mappings":"AAAa,MAAA,eAAe,GAAG,CAC3B,GAAM,EACN,YAAe,EACf,kBAGC,KACK;AACN,IAAA,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,kBAAkB,CAAC;AAExC,IAAA,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,YAAY,EAAE;QACrC,IAAI,MAAM,CAAC,wBAAwB,CAAC,GAAG,EAAE,YAAY,CAAC,IAAI;AACtD,YAAA,YAAY,EAAE,IAAI;AAClB,YAAA,cAAc,EAAE,IAAI;SACvB,CAAC;QACF,IAAI,GAAG,KAAK,SAAS;AACjB,cAAE;AACI,gBAAA,KAAK,EAAE,YAAA;AACH,oBAAA,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBACzB;AACJ,aAAA;cACD,EAAE,CAAC;QACT,IAAI,GAAG,KAAK,SAAS;AACjB,cAAE;gBACI,KAAK,EAAE,UAAU,KAAW,EAAA;AACxB,oBAAA,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;iBACzB;AACJ,aAAA;cACD,EAAE,CAAC;AACZ,KAAA,CAAC,CAAC;AACP;;;;"} \ No newline at end of file diff --git a/esm/lab/index.d.ts b/esm/lab/index.d.ts new file mode 100644 index 0000000..1817599 --- /dev/null +++ b/esm/lab/index.d.ts @@ -0,0 +1,5 @@ +export * from "./defineAccessors"; +export * from "./overwriteReadonlyProp"; +export * from "./PromiseOrNot"; +export * from "./UnpackTypeGuard"; +export * from "./withDefaults"; diff --git a/esm/lab/index.mjs b/esm/lab/index.mjs new file mode 100644 index 0000000..e8f74e7 --- /dev/null +++ b/esm/lab/index.mjs @@ -0,0 +1,4 @@ +export { defineAccessors } from './defineAccessors.mjs'; +export { overwriteReadonlyProp } from './overwriteReadonlyProp.mjs'; +export { withDefaults } from './withDefaults.mjs'; +//# sourceMappingURL=index.mjs.map diff --git a/esm/lab/index.mjs.map b/esm/lab/index.mjs.map new file mode 100644 index 0000000..0988881 --- /dev/null +++ b/esm/lab/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"} \ No newline at end of file diff --git a/esm/lab/overwriteReadonlyProp.d.ts b/esm/lab/overwriteReadonlyProp.d.ts new file mode 100644 index 0000000..225c2c2 --- /dev/null +++ b/esm/lab/overwriteReadonlyProp.d.ts @@ -0,0 +1,7 @@ +/** + * Assign a value to a property even if the object is freezed or if the property is not writable + * Throw if the assignation fail ( for example if the property is non configurable write: false ) + * */ +export declare const overwriteReadonlyProp: (obj: T, propertyName: K, value: T[K]) => T[K]; diff --git a/esm/lab/overwriteReadonlyProp.mjs b/esm/lab/overwriteReadonlyProp.mjs new file mode 100644 index 0000000..2008c08 --- /dev/null +++ b/esm/lab/overwriteReadonlyProp.mjs @@ -0,0 +1,37 @@ +/** + * Assign a value to a property even if the object is freezed or if the property is not writable + * Throw if the assignation fail ( for example if the property is non configurable write: false ) + * */ +const overwriteReadonlyProp = (obj, propertyName, value) => { + try { + obj[propertyName] = value; + } + catch { } + if (obj[propertyName] === value) { + return value; + } + let errorDefineProperty = undefined; + const propertyDescriptor = Object.getOwnPropertyDescriptor(obj, propertyName) || { + "enumerable": true, + "configurable": true, + }; + if (!!propertyDescriptor.get) { + throw new Error(`Probably a wrong ides to overwrite ${String(propertyName)} getter`); + } + try { + Object.defineProperty(obj, propertyName, { + ...propertyDescriptor, + value, + }); + } + catch (error) { + errorDefineProperty = error; + } + if (obj[propertyName] !== value) { + throw errorDefineProperty || new Error("Can't assign"); + } + return value; +}; + +export { overwriteReadonlyProp }; +//# sourceMappingURL=overwriteReadonlyProp.mjs.map diff --git a/esm/lab/overwriteReadonlyProp.mjs.map b/esm/lab/overwriteReadonlyProp.mjs.map new file mode 100644 index 0000000..7cea470 --- /dev/null +++ b/esm/lab/overwriteReadonlyProp.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"overwriteReadonlyProp.mjs","sources":["../../dist/src/lab/overwriteReadonlyProp.ts"],"sourcesContent":["/**\n * Assign a value to a property even if the object is freezed or if the property is not writable\n * Throw if the assignation fail ( for example if the property is non configurable write: false )\n * */\nexport const overwriteReadonlyProp = (\n obj: T,\n propertyName: K,\n value: T[K],\n): T[K] => {\n try {\n obj[propertyName] = value;\n } catch {}\n\n if (obj[propertyName] === value) {\n return value;\n }\n\n let errorDefineProperty: Error | undefined = undefined;\n\n const propertyDescriptor: PropertyDescriptor = Object.getOwnPropertyDescriptor(\n obj,\n propertyName,\n ) || {\n \"enumerable\": true,\n \"configurable\": true,\n };\n\n if (!!propertyDescriptor.get) {\n throw new Error(`Probably a wrong ides to overwrite ${String(propertyName)} getter`);\n }\n\n try {\n Object.defineProperty(obj, propertyName, {\n ...propertyDescriptor,\n value,\n });\n } catch (error) {\n errorDefineProperty = error as Error;\n }\n\n if (obj[propertyName] !== value) {\n throw errorDefineProperty || new Error(\"Can't assign\");\n }\n\n return value;\n};\n"],"names":[],"mappings":"AAAA;;;AAGK;AACQ,MAAA,qBAAqB,GAAG,CACjC,GAAM,EACN,YAAe,EACf,KAAW,KACL;AACN,IAAA,IAAI;AACA,QAAA,GAAG,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC;KAC7B;IAAC,MAAM,GAAE;AAEV,IAAA,IAAI,GAAG,CAAC,YAAY,CAAC,KAAK,KAAK,EAAE;AAC7B,QAAA,OAAO,KAAK,CAAC;KAChB;IAED,IAAI,mBAAmB,GAAsB,SAAS,CAAC;IAEvD,MAAM,kBAAkB,GAAuB,MAAM,CAAC,wBAAwB,CAC1E,GAAG,EACH,YAAY,CACf,IAAI;AACD,QAAA,YAAY,EAAE,IAAI;AAClB,QAAA,cAAc,EAAE,IAAI;KACvB,CAAC;AAEF,IAAA,IAAI,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,CAAsC,mCAAA,EAAA,MAAM,CAAC,YAAY,CAAC,CAAS,OAAA,CAAA,CAAC,CAAC;KACxF;AAED,IAAA,IAAI;AACA,QAAA,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,YAAY,EAAE;AACrC,YAAA,GAAG,kBAAkB;YACrB,KAAK;AACR,SAAA,CAAC,CAAC;KACN;IAAC,OAAO,KAAK,EAAE;QACZ,mBAAmB,GAAG,KAAc,CAAC;KACxC;AAED,IAAA,IAAI,GAAG,CAAC,YAAY,CAAC,KAAK,KAAK,EAAE;AAC7B,QAAA,MAAM,mBAAmB,IAAI,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;KAC1D;AAED,IAAA,OAAO,KAAK,CAAC;AACjB;;;;"} \ No newline at end of file diff --git a/esm/lab/withDefaults.d.ts b/esm/lab/withDefaults.d.ts new file mode 100644 index 0000000..e6ec041 --- /dev/null +++ b/esm/lab/withDefaults.d.ts @@ -0,0 +1,16 @@ +import "../tools/Object.fromEntries"; +/** + * Like Function.prototype.bind() but for a function that + * receives their parameters wrapped in an object. + * See documentation for more details: + * https://docs.tsafe.dev/withdefaults + */ +export declare function withDefaults, DefaultKey extends keyof Params, R>(f: (params: Params) => R, defaultParams: keyof Params extends never ? Record : { + [Key in DefaultKey]: Params[Key]; +}): (params: { + [Key in keyof Omit]: Params[Key]; +} & { + defaultsOverwrite?: { + [Key in DefaultKey]?: [Params[Key]]; + }; +}) => R; diff --git a/esm/lab/withDefaults.mjs b/esm/lab/withDefaults.mjs new file mode 100644 index 0000000..d92ffd7 --- /dev/null +++ b/esm/lab/withDefaults.mjs @@ -0,0 +1,23 @@ +import '../tools/Object.fromEntries.mjs'; + +/** + * Like Function.prototype.bind() but for a function that + * receives their parameters wrapped in an object. + * See documentation for more details: + * https://docs.tsafe.dev/withdefaults + */ +function withDefaults(f, defaultParams) { + return params => { + const { defaultsOverwrite = {}, ...actualParams } = params; + return f({ + ...defaultParams, + ...actualParams, + ...Object.fromEntries(Object.entries(defaultsOverwrite) + .filter(([, value]) => value !== undefined) + .map(([key, value]) => [key, value[0]])), + }); + }; +} + +export { withDefaults }; +//# sourceMappingURL=withDefaults.mjs.map diff --git a/esm/lab/withDefaults.mjs.map b/esm/lab/withDefaults.mjs.map new file mode 100644 index 0000000..a75f5e5 --- /dev/null +++ b/esm/lab/withDefaults.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"withDefaults.mjs","sources":["../../dist/src/lab/withDefaults.ts"],"sourcesContent":["import \"../tools/Object.fromEntries\";\n/**\n * Like Function.prototype.bind() but for a function that\n * receives their parameters wrapped in an object.\n * See documentation for more details:\n * https://docs.tsafe.dev/withdefaults\n */\nexport function withDefaults, DefaultKey extends keyof Params, R>(\n f: (params: Params) => R,\n defaultParams: keyof Params extends never\n ? Record\n : { [Key in DefaultKey]: Params[Key] },\n): (\n params: { [Key in keyof Omit]: Params[Key] } & {\n defaultsOverwrite?: { [Key in DefaultKey]?: [Params[Key]] };\n },\n) => R {\n return params => {\n const { defaultsOverwrite = {}, ...actualParams } = params;\n\n return f({\n ...defaultParams,\n ...actualParams,\n ...Object.fromEntries(\n Object.entries(defaultsOverwrite)\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => [key, (value as any)[0]]),\n ),\n } as any);\n };\n}\n"],"names":[],"mappings":";;AACA;;;;;AAKG;AACa,SAAA,YAAY,CACxB,CAAwB,EACxB,aAE0C,EAAA;IAM1C,OAAO,MAAM,IAAG;QACZ,MAAM,EAAE,iBAAiB,GAAG,EAAE,EAAE,GAAG,YAAY,EAAE,GAAG,MAAM,CAAC;AAE3D,QAAA,OAAO,CAAC,CAAC;AACL,YAAA,GAAG,aAAa;AAChB,YAAA,GAAG,YAAY;YACf,GAAG,MAAM,CAAC,WAAW,CACjB,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC;AAC5B,iBAAA,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,KAAK,KAAK,SAAS,CAAC;AAC1C,iBAAA,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,EAAG,KAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CACvD;AACG,SAAA,CAAC,CAAC;AACd,KAAC,CAAC;AACN;;;;"} \ No newline at end of file diff --git a/esm/noUndefined.d.ts b/esm/noUndefined.d.ts new file mode 100644 index 0000000..51e3bbc --- /dev/null +++ b/esm/noUndefined.d.ts @@ -0,0 +1,9 @@ +/** + * Removes the enumerable properties whose values are + * undefined. + * + * Example: + * noUndefined({ "foo": undefined, "bar": 3 }) returns + * a new object { "bar": 3 } + */ +export declare function noUndefined(obj: T): T; diff --git a/esm/noUndefined.mjs b/esm/noUndefined.mjs new file mode 100644 index 0000000..452a2de --- /dev/null +++ b/esm/noUndefined.mjs @@ -0,0 +1,21 @@ +/** + * Removes the enumerable properties whose values are + * undefined. + * + * Example: + * noUndefined({ "foo": undefined, "bar": 3 }) returns + * a new object { "bar": 3 } + */ +function noUndefined(obj) { + const out = {}; + for (const key in obj) { + if (obj[key] === undefined) { + continue; + } + out[key] = obj[key]; + } + return out; +} + +export { noUndefined }; +//# sourceMappingURL=noUndefined.mjs.map diff --git a/esm/noUndefined.mjs.map b/esm/noUndefined.mjs.map new file mode 100644 index 0000000..7548d96 --- /dev/null +++ b/esm/noUndefined.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"noUndefined.mjs","sources":["../dist/src/noUndefined.ts"],"sourcesContent":["/**\n * Removes the enumerable properties whose values are\n * undefined.\n *\n * Example:\n * noUndefined({ \"foo\": undefined, \"bar\": 3 }) returns\n * a new object { \"bar\": 3 }\n */\nexport function noUndefined(obj: T): T {\n const out: typeof obj = {} as any;\n\n for (const key in obj) {\n if (obj[key] === undefined) {\n continue;\n }\n\n out[key] = obj[key];\n }\n\n return out;\n}\n"],"names":[],"mappings":"AAAA;;;;;;;AAOG;AACG,SAAU,WAAW,CAAmB,GAAM,EAAA;IAChD,MAAM,GAAG,GAAe,EAAS,CAAC;AAElC,IAAA,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE;AACnB,QAAA,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE;YACxB,SAAS;SACZ;QAED,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;KACvB;AAED,IAAA,OAAO,GAAG,CAAC;AACf;;;;"} \ No newline at end of file diff --git a/esm/objectEntries.d.ts b/esm/objectEntries.d.ts new file mode 100644 index 0000000..723eabc --- /dev/null +++ b/esm/objectEntries.d.ts @@ -0,0 +1,8 @@ +/** https://docs.tsafe.dev/objectentries */ +export declare function objectEntries>(o: O): Exclude<{ + [Key in keyof O]: [Key, O[Key]]; +}[keyof O], undefined>[]; +/** Return type of objectEntries https://docs.tsafe.dev/objectentries */ +export type ObjectEntries> = Exclude<{ + [Key in keyof O]: [Key, O[Key]]; +}[keyof O], undefined>[]; diff --git a/esm/objectEntries.mjs b/esm/objectEntries.mjs new file mode 100644 index 0000000..ef090a7 --- /dev/null +++ b/esm/objectEntries.mjs @@ -0,0 +1,7 @@ +/** https://docs.tsafe.dev/objectentries */ +function objectEntries(o) { + return Object.entries(o); +} + +export { objectEntries }; +//# sourceMappingURL=objectEntries.mjs.map diff --git a/esm/objectEntries.mjs.map b/esm/objectEntries.mjs.map new file mode 100644 index 0000000..c0974bf --- /dev/null +++ b/esm/objectEntries.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"objectEntries.mjs","sources":["../dist/src/objectEntries.ts"],"sourcesContent":["/** https://docs.tsafe.dev/objectentries */\nexport function objectEntries>(\n o: O,\n): Exclude<{ [Key in keyof O]: [Key, O[Key]] }[keyof O], undefined>[] {\n return Object.entries(o) as any;\n}\n\n/** Return type of objectEntries https://docs.tsafe.dev/objectentries */\nexport type ObjectEntries> = Exclude<\n { [Key in keyof O]: [Key, O[Key]] }[keyof O],\n undefined\n>[];\n"],"names":[],"mappings":"AAAA;AACM,SAAU,aAAa,CACzB,CAAI,EAAA;AAEJ,IAAA,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAQ,CAAC;AACpC;;;;"} \ No newline at end of file diff --git a/esm/objectFromEntries.d.ts b/esm/objectFromEntries.d.ts new file mode 100644 index 0000000..09e62db --- /dev/null +++ b/esm/objectFromEntries.d.ts @@ -0,0 +1,8 @@ +/** https://docs.tsafe.dev/objectFromEntries */ +export declare function objectFromEntries(entries: readonly Entry[]): { + [Key in Entry[0]]: Extract[1]; +}; +/** Return type of objectFromEntries https://docs.tsafe.dev/objectFromEntries */ +export type ObjectFromEntries = { + [Key in Entry[0]]: Extract[1]; +}; diff --git a/esm/objectFromEntries.mjs b/esm/objectFromEntries.mjs new file mode 100644 index 0000000..a6292eb --- /dev/null +++ b/esm/objectFromEntries.mjs @@ -0,0 +1,7 @@ +/** https://docs.tsafe.dev/objectFromEntries */ +function objectFromEntries(entries) { + return Object.fromEntries(entries); +} + +export { objectFromEntries }; +//# sourceMappingURL=objectFromEntries.mjs.map diff --git a/esm/objectFromEntries.mjs.map b/esm/objectFromEntries.mjs.map new file mode 100644 index 0000000..5639622 --- /dev/null +++ b/esm/objectFromEntries.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"objectFromEntries.mjs","sources":["../dist/src/objectFromEntries.ts"],"sourcesContent":["/** https://docs.tsafe.dev/objectFromEntries */\nexport function objectFromEntries(\n entries: readonly Entry[],\n): { [Key in Entry[0]]: Extract[1] } {\n return Object.fromEntries(entries) as any;\n}\n\n/** Return type of objectFromEntries https://docs.tsafe.dev/objectFromEntries */\nexport type ObjectFromEntries = {\n [Key in Entry[0]]: Extract[1];\n};\n"],"names":[],"mappings":"AAAA;AACM,SAAU,iBAAiB,CAC7B,OAAyB,EAAA;AAEzB,IAAA,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAQ,CAAC;AAC9C;;;;"} \ No newline at end of file diff --git a/esm/objectKeys.d.ts b/esm/objectKeys.d.ts new file mode 100644 index 0000000..103b048 --- /dev/null +++ b/esm/objectKeys.d.ts @@ -0,0 +1,2 @@ +/** https://docs.tsafe.dev/objectKeys */ +export declare function objectKeys>(o: T): (keyof T)[]; diff --git a/esm/objectKeys.mjs b/esm/objectKeys.mjs new file mode 100644 index 0000000..5b792bc --- /dev/null +++ b/esm/objectKeys.mjs @@ -0,0 +1,7 @@ +/** https://docs.tsafe.dev/objectKeys */ +function objectKeys(o) { + return Object.keys(o); +} + +export { objectKeys }; +//# sourceMappingURL=objectKeys.mjs.map diff --git a/esm/objectKeys.mjs.map b/esm/objectKeys.mjs.map new file mode 100644 index 0000000..a6cf3d4 --- /dev/null +++ b/esm/objectKeys.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"objectKeys.mjs","sources":["../dist/src/objectKeys.ts"],"sourcesContent":["/** https://docs.tsafe.dev/objectKeys */\nexport function objectKeys>(o: T): (keyof T)[] {\n return Object.keys(o) as any;\n}\n"],"names":[],"mappings":"AAAA;AACM,SAAU,UAAU,CAAoC,CAAI,EAAA;AAC9D,IAAA,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAQ,CAAC;AACjC;;;;"} \ No newline at end of file diff --git a/esm/symToStr.d.ts b/esm/symToStr.d.ts new file mode 100644 index 0000000..2857462 --- /dev/null +++ b/esm/symToStr.d.ts @@ -0,0 +1,2 @@ +/** @see */ +export declare function symToStr>(wrap: T): Exclude; diff --git a/esm/symToStr.mjs b/esm/symToStr.mjs new file mode 100644 index 0000000..c9ea2cd --- /dev/null +++ b/esm/symToStr.mjs @@ -0,0 +1,8 @@ +/** @see */ +function symToStr(wrap) { + // @ts-expect-error: We know better + return Object.keys(wrap)[0]; +} + +export { symToStr }; +//# sourceMappingURL=symToStr.mjs.map diff --git a/esm/symToStr.mjs.map b/esm/symToStr.mjs.map new file mode 100644 index 0000000..164653a --- /dev/null +++ b/esm/symToStr.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"symToStr.mjs","sources":["../dist/src/symToStr.ts"],"sourcesContent":["/** @see */\nexport function symToStr>(wrap: T): Exclude {\n // @ts-expect-error: We know better\n return Object.keys(wrap)[0];\n}\n"],"names":[],"mappings":"AAAA;AACM,SAAU,QAAQ,CAAoC,IAAO,EAAA;;IAE/D,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAChC;;;;"} \ No newline at end of file diff --git a/esm/tools/Object.fromEntries.d.ts b/esm/tools/Object.fromEntries.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/esm/tools/Object.fromEntries.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/esm/tools/Object.fromEntries.mjs b/esm/tools/Object.fromEntries.mjs new file mode 100644 index 0000000..07af0c6 --- /dev/null +++ b/esm/tools/Object.fromEntries.mjs @@ -0,0 +1,16 @@ +if (!Object.fromEntries) { + Object.defineProperty(Object, "fromEntries", { + "value": function (entries) { + if (!entries || !entries[Symbol.iterator]) { + throw new Error("Object.fromEntries() requires a single iterable argument"); + } + const o = {}; + Object.keys(entries).forEach(key => { + const [k, v] = entries[key]; + o[k] = v; + }); + return o; + }, + }); +} +//# sourceMappingURL=Object.fromEntries.mjs.map diff --git a/esm/tools/Object.fromEntries.mjs.map b/esm/tools/Object.fromEntries.mjs.map new file mode 100644 index 0000000..799f02f --- /dev/null +++ b/esm/tools/Object.fromEntries.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"Object.fromEntries.mjs","sources":["../../dist/src/tools/Object.fromEntries.ts"],"sourcesContent":["if (!(Object as any).fromEntries) {\n Object.defineProperty(Object, \"fromEntries\", {\n \"value\": function (entries: any) {\n if (!entries || !entries[Symbol.iterator]) {\n throw new Error(\"Object.fromEntries() requires a single iterable argument\");\n }\n\n const o: any = {};\n\n Object.keys(entries).forEach(key => {\n const [k, v] = entries[key];\n\n o[k] = v;\n });\n\n return o;\n },\n });\n}\n\nexport {};\n"],"names":[],"mappings":"AAAA,IAAI,CAAE,MAAc,CAAC,WAAW,EAAE;AAC9B,IAAA,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE;QACzC,OAAO,EAAE,UAAU,OAAY,EAAA;YAC3B,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;AACvC,gBAAA,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;aAC/E;YAED,MAAM,CAAC,GAAQ,EAAE,CAAC;YAElB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG,IAAG;gBAC/B,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;AAE5B,gBAAA,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACb,aAAC,CAAC,CAAC;AAEH,YAAA,OAAO,CAAC,CAAC;SACZ;AACJ,KAAA,CAAC,CAAC;AACP"} \ No newline at end of file diff --git a/esm/tools/StrictEquals.d.ts b/esm/tools/StrictEquals.d.ts new file mode 100644 index 0000000..0871a91 --- /dev/null +++ b/esm/tools/StrictEquals.d.ts @@ -0,0 +1 @@ +export type StrictEquals = (() => A extends A2 ? true : false) extends () => A extends A1 ? true : false ? true : false; diff --git a/esm/tools/StrictEquals.mjs b/esm/tools/StrictEquals.mjs new file mode 100644 index 0000000..d92b995 --- /dev/null +++ b/esm/tools/StrictEquals.mjs @@ -0,0 +1,2 @@ + +//# sourceMappingURL=StrictEquals.mjs.map diff --git a/esm/tools/StrictEquals.mjs.map b/esm/tools/StrictEquals.mjs.map new file mode 100644 index 0000000..4bdd52c --- /dev/null +++ b/esm/tools/StrictEquals.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"StrictEquals.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""} \ No newline at end of file diff --git a/esm/tools/Unite.d.ts b/esm/tools/Unite.d.ts new file mode 100644 index 0000000..a75c362 --- /dev/null +++ b/esm/tools/Unite.d.ts @@ -0,0 +1,3 @@ +export type Unite = T extends Record ? { + [Key in keyof T]: T[Key]; +} : T; diff --git a/esm/tools/Unite.mjs b/esm/tools/Unite.mjs new file mode 100644 index 0000000..f5e6362 --- /dev/null +++ b/esm/tools/Unite.mjs @@ -0,0 +1,2 @@ + +//# sourceMappingURL=Unite.mjs.map diff --git a/esm/tools/Unite.mjs.map b/esm/tools/Unite.mjs.map new file mode 100644 index 0000000..1980d31 --- /dev/null +++ b/esm/tools/Unite.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"Unite.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""} \ No newline at end of file diff --git a/esm/tools/index.d.ts b/esm/tools/index.d.ts new file mode 100644 index 0000000..4d0de7c --- /dev/null +++ b/esm/tools/index.d.ts @@ -0,0 +1,4 @@ +export * from "./Object.fromEntries"; +export * from "./StrictEquals"; +export * from "./toUpperCase"; +export * from "./Unite"; diff --git a/esm/tools/index.mjs b/esm/tools/index.mjs new file mode 100644 index 0000000..feeba9a --- /dev/null +++ b/esm/tools/index.mjs @@ -0,0 +1,3 @@ +import './Object.fromEntries.mjs'; +export { toUpperCase } from './toUpperCase.mjs'; +//# sourceMappingURL=index.mjs.map diff --git a/esm/tools/index.mjs.map b/esm/tools/index.mjs.map new file mode 100644 index 0000000..3642066 --- /dev/null +++ b/esm/tools/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"} \ No newline at end of file diff --git a/esm/tools/toUpperCase.d.ts b/esm/tools/toUpperCase.d.ts new file mode 100644 index 0000000..c2dd61b --- /dev/null +++ b/esm/tools/toUpperCase.d.ts @@ -0,0 +1 @@ +export declare function toUpperCase(str: string): string; diff --git a/esm/tools/toUpperCase.mjs b/esm/tools/toUpperCase.mjs new file mode 100644 index 0000000..96cae39 --- /dev/null +++ b/esm/tools/toUpperCase.mjs @@ -0,0 +1,6 @@ +function toUpperCase(str) { + return str.toUpperCase(); +} + +export { toUpperCase }; +//# sourceMappingURL=toUpperCase.mjs.map diff --git a/esm/tools/toUpperCase.mjs.map b/esm/tools/toUpperCase.mjs.map new file mode 100644 index 0000000..64ba7e1 --- /dev/null +++ b/esm/tools/toUpperCase.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"toUpperCase.mjs","sources":["../../dist/src/tools/toUpperCase.ts"],"sourcesContent":["export function toUpperCase(str: string): string {\n return str.toUpperCase();\n}\n"],"names":[],"mappings":"AAAM,SAAU,WAAW,CAAC,GAAW,EAAA;AACnC,IAAA,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC;AAC7B;;;;"} \ No newline at end of file diff --git a/esm/typeGuard.d.ts b/esm/typeGuard.d.ts new file mode 100644 index 0000000..a3e86f8 --- /dev/null +++ b/esm/typeGuard.d.ts @@ -0,0 +1,2 @@ +/** https://docs.tsafe.dev/typeguard */ +export declare function typeGuard(value: any, isMatched: boolean): value is T; diff --git a/esm/typeGuard.mjs b/esm/typeGuard.mjs new file mode 100644 index 0000000..000c07e --- /dev/null +++ b/esm/typeGuard.mjs @@ -0,0 +1,7 @@ +/** https://docs.tsafe.dev/typeguard */ +function typeGuard(value, isMatched) { + return isMatched; +} + +export { typeGuard }; +//# sourceMappingURL=typeGuard.mjs.map diff --git a/esm/typeGuard.mjs.map b/esm/typeGuard.mjs.map new file mode 100644 index 0000000..f1b98e7 --- /dev/null +++ b/esm/typeGuard.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"typeGuard.mjs","sources":["../dist/src/typeGuard.ts"],"sourcesContent":["/** https://docs.tsafe.dev/typeguard */\nexport function typeGuard(value: any, isMatched: boolean): value is T {\n return isMatched;\n}\n"],"names":[],"mappings":"AAAA;AACgB,SAAA,SAAS,CAAI,KAAU,EAAE,SAAkB,EAAA;AACvD,IAAA,OAAO,SAAS,CAAC;AACrB;;;;"} \ No newline at end of file diff --git a/esm/uncapitalize.d.ts b/esm/uncapitalize.d.ts new file mode 100644 index 0000000..1496b91 --- /dev/null +++ b/esm/uncapitalize.d.ts @@ -0,0 +1,2 @@ +/** @see */ +export declare function uncapitalize(str: S): Uncapitalize; diff --git a/esm/uncapitalize.mjs b/esm/uncapitalize.mjs new file mode 100644 index 0000000..19816b7 --- /dev/null +++ b/esm/uncapitalize.mjs @@ -0,0 +1,7 @@ +/** @see */ +function uncapitalize(str) { + return (str.charAt(0).toLowerCase() + str.slice(1)); +} + +export { uncapitalize }; +//# sourceMappingURL=uncapitalize.mjs.map diff --git a/esm/uncapitalize.mjs.map b/esm/uncapitalize.mjs.map new file mode 100644 index 0000000..2e676a1 --- /dev/null +++ b/esm/uncapitalize.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"uncapitalize.mjs","sources":["../dist/src/uncapitalize.ts"],"sourcesContent":["/** @see */\nexport function uncapitalize(str: S): Uncapitalize {\n return (str.charAt(0).toLowerCase() + str.slice(1)) as any;\n}\n"],"names":[],"mappings":"AAAA;AACM,SAAU,YAAY,CAAmB,GAAM,EAAA;AACjD,IAAA,QAAQ,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAS;AAC/D;;;;"} \ No newline at end of file diff --git a/exclude.d.ts b/exclude.d.ts new file mode 100644 index 0000000..e457148 --- /dev/null +++ b/exclude.d.ts @@ -0,0 +1,9 @@ +/** + * https://docs.tsafe.dev/exclude + * + * Return a function to use as Array.prototype.filter argument + * to exclude one or many primitive value element from the array. + * Ex: ([ "a", "b", "c" ] as const).filter(exclude("a")) return ("b" | "c")[] + * Ex: ([ "a", "b", "c", "d"] as const).filter(exclude(["a", "b"]) gives ("c" | "d")[] + */ +export declare function exclude(target: readonly T[] | T): (element: U) => element is Exclude; diff --git a/exclude.js b/exclude.js new file mode 100644 index 0000000..4aa94cd --- /dev/null +++ b/exclude.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.exclude = exclude; +/** + * https://docs.tsafe.dev/exclude + * + * Return a function to use as Array.prototype.filter argument + * to exclude one or many primitive value element from the array. + * Ex: ([ "a", "b", "c" ] as const).filter(exclude("a")) return ("b" | "c")[] + * Ex: ([ "a", "b", "c", "d"] as const).filter(exclude(["a", "b"]) gives ("c" | "d")[] + */ +function exclude(target) { + var test = target instanceof Object + ? function (element) { return target.indexOf(element) < 0; } + : function (element) { return element !== target; }; + return function (element) { + return test(element); + }; +} +//# sourceMappingURL=exclude.js.map \ No newline at end of file diff --git a/exclude.js.map b/exclude.js.map new file mode 100644 index 0000000..44749c7 --- /dev/null +++ b/exclude.js.map @@ -0,0 +1 @@ +{"version":3,"file":"exclude.js","sourceRoot":"","sources":["src/exclude.ts"],"names":[],"mappings":";;AAQA,0BAWC;AAnBD;;;;;;;GAOG;AACH,SAAgB,OAAO,CACnB,MAAwB;IAExB,IAAM,IAAI,GACN,MAAM,YAAY,MAAM;QACpB,CAAC,CAAC,UAAA,OAAO,IAAI,OAAA,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAA3B,CAA2B;QACxC,CAAC,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,KAAK,MAAM,EAAlB,CAAkB,CAAC;IAExC,OAAO,UAAa,OAAU;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC,CAAC;AACN,CAAC"} \ No newline at end of file diff --git a/flip.d.ts b/flip.d.ts new file mode 100644 index 0000000..54c63f2 --- /dev/null +++ b/flip.d.ts @@ -0,0 +1,10 @@ +type KeyOfType, U> = NonNullable<{ + [Key in keyof T]: T[Key] extends U | undefined ? Key : never; +}[keyof T]>; +/** + * Flip the value of a boolean without having to reference it twice + * after running flip(x.y, "z") x.y.z !== x.y.z, + * https://docs.tsafe.dev/flip + */ +export declare function flip>(object: T, prop: KeyOfType): any; +export {}; diff --git a/flip.js b/flip.js new file mode 100644 index 0000000..5590606 --- /dev/null +++ b/flip.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.flip = flip; +/** + * Flip the value of a boolean without having to reference it twice + * after running flip(x.y, "z") x.y.z !== x.y.z, + * https://docs.tsafe.dev/flip + */ +function flip(object, prop) { + if (object[prop] === undefined) { + return; + } + return (object[prop] = !object[prop]); +} +//# sourceMappingURL=flip.js.map \ No newline at end of file diff --git a/flip.js.map b/flip.js.map new file mode 100644 index 0000000..2871047 --- /dev/null +++ b/flip.js.map @@ -0,0 +1 @@ +{"version":3,"file":"flip.js","sourceRoot":"","sources":["src/flip.ts"],"names":[],"mappings":";;AAWA,oBAMC;AAXD;;;;GAIG;AACH,SAAgB,IAAI,CAAgC,MAAS,EAAE,IAA2B;IACtF,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO;IACX,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAQ,CAAC,CAAC;AACjD,CAAC"} \ No newline at end of file diff --git a/id.d.ts b/id.d.ts new file mode 100644 index 0000000..e3e6d46 --- /dev/null +++ b/id.d.ts @@ -0,0 +1,36 @@ +/** https://docs.tsafe.dev/id */ +export declare const id: (x: T) => T; +/** + * Ensure that a that a specific type that we are declaring extends a more generic type + * + * Use case example 1: + * + * type MyObject = { + * p1: string; + * p2: string; + * a: string; + * b: string; + * }; + * + * We want to define a type that consist in an union of + * all the property name that are letters: + * + * type AlphabeticalKeys = Id; + * + * Here AlphabeticalKeys is "a" | "b" but it's better than + * simply writing it explicitly as we get autocompletion + * and we can't include a property name that does not exist on MyObject. + * + * Use case example 2: + * + * We want to declare object type that only take string or number + * as key value: + * + * export type MyObject = Id, { + * p1: string; + * p2: number; + * }>; + * + * If later on someone adds "p3": string[] he will get a type error. + * */ +export type Id = Specific; diff --git a/id.js b/id.js new file mode 100644 index 0000000..e4c2976 --- /dev/null +++ b/id.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.id = void 0; +/** https://docs.tsafe.dev/id */ +var id = function (x) { return x; }; +exports.id = id; +//# sourceMappingURL=id.js.map \ No newline at end of file diff --git a/id.js.map b/id.js.map new file mode 100644 index 0000000..f7f4697 --- /dev/null +++ b/id.js.map @@ -0,0 +1 @@ +{"version":3,"file":"id.js","sourceRoot":"","sources":["src/id.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAC1B,IAAM,EAAE,GAAG,UAAI,CAAI,IAAK,OAAA,CAAC,EAAD,CAAC,CAAC;AAApB,QAAA,EAAE,MAAkB"} \ No newline at end of file diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..051554b --- /dev/null +++ b/index.d.ts @@ -0,0 +1,26 @@ +export * from "./assert"; +export * from "./exclude"; +export * from "./flip"; +export * from "./id"; +export * from "./isPromiseLike"; +export type { MethodNames } from "./MethodNames"; +export * from "./objectKeys"; +export type { Parameters } from "./Parameters"; +export type { Param0 } from "./Param0"; +export type { PickOptionals } from "./PickOptionals"; +export type { PickRequired } from "./PickRequired"; +export type { ReturnType } from "./ReturnType"; +export * from "./typeGuard"; +export type { UnpackPromise } from "./UnpackPromise"; +export * from "./isAmong"; +export type { Equals } from "./Equals"; +export type { Extends } from "./Extends"; +export type { Not } from "./Not"; +export type { UnionToIntersection } from "./UnionToIntersection"; +export * from "./objectEntries"; +export * from "./objectFromEntries"; +export * from "./noUndefined"; +export * from "./Reflect"; +export * from "./capitalize"; +export * from "./uncapitalize"; +export * from "./symToStr"; diff --git a/index.js b/index.js new file mode 100644 index 0000000..5c0a2ba --- /dev/null +++ b/index.js @@ -0,0 +1,32 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./assert"), exports); +__exportStar(require("./exclude"), exports); +__exportStar(require("./flip"), exports); +__exportStar(require("./id"), exports); +__exportStar(require("./isPromiseLike"), exports); +__exportStar(require("./objectKeys"), exports); +__exportStar(require("./typeGuard"), exports); +__exportStar(require("./isAmong"), exports); +__exportStar(require("./objectEntries"), exports); +__exportStar(require("./objectFromEntries"), exports); +__exportStar(require("./noUndefined"), exports); +__exportStar(require("./Reflect"), exports); +__exportStar(require("./capitalize"), exports); +__exportStar(require("./uncapitalize"), exports); +__exportStar(require("./symToStr"), exports); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..a9b79ea --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,yCAAuB;AACvB,uCAAqB;AACrB,kDAAgC;AAEhC,+CAA6B;AAM7B,8CAA4B;AAE5B,4CAA0B;AAK1B,kDAAgC;AAChC,sDAAoC;AACpC,gDAA8B;AAC9B,4CAA0B;AAC1B,+CAA6B;AAC7B,iDAA+B;AAC/B,6CAA2B"} \ No newline at end of file diff --git a/is.d.ts b/is.d.ts new file mode 100644 index 0000000..faa2f6f --- /dev/null +++ b/is.d.ts @@ -0,0 +1,8 @@ +import { is } from "./assert"; +/** + * @deprecated: Prefer importing using `import { assert, is } from "tsafe/assert"` + * or `import { assert, is } from "tsafe"` + * + * https://docs.tsafe.dev/is + * */ +export { is }; diff --git a/is.js b/is.js new file mode 100644 index 0000000..a82e5c1 --- /dev/null +++ b/is.js @@ -0,0 +1,6 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.is = void 0; +var assert_1 = require("./assert"); +Object.defineProperty(exports, "is", { enumerable: true, get: function () { return assert_1.is; } }); +//# sourceMappingURL=is.js.map \ No newline at end of file diff --git a/is.js.map b/is.js.map new file mode 100644 index 0000000..73fe3ef --- /dev/null +++ b/is.js.map @@ -0,0 +1 @@ +{"version":3,"file":"is.js","sourceRoot":"","sources":["src/is.ts"],"names":[],"mappings":";;;AAAA,mCAA8B;AAQrB,mFARA,WAAE,OAQA"} \ No newline at end of file diff --git a/isAmong.d.ts b/isAmong.d.ts new file mode 100644 index 0000000..9e7618a --- /dev/null +++ b/isAmong.d.ts @@ -0,0 +1,2 @@ +/** https://docs.tsafe.dev/isamong */ +export declare function isAmong(names: readonly Name[], value: unknown): value is Name; diff --git a/isAmong.js b/isAmong.js new file mode 100644 index 0000000..b1384fd --- /dev/null +++ b/isAmong.js @@ -0,0 +1,35 @@ +"use strict"; +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isAmong = isAmong; +/** https://docs.tsafe.dev/isamong */ +function isAmong(names, value) { + var e_1, _a; + try { + for (var names_1 = __values(names), names_1_1 = names_1.next(); !names_1_1.done; names_1_1 = names_1.next()) { + var name_1 = names_1_1.value; + if (name_1 === value) { + return true; + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (names_1_1 && !names_1_1.done && (_a = names_1.return)) _a.call(names_1); + } + finally { if (e_1) throw e_1.error; } + } + return false; +} +//# sourceMappingURL=isAmong.js.map \ No newline at end of file diff --git a/isAmong.js.map b/isAmong.js.map new file mode 100644 index 0000000..49f3bba --- /dev/null +++ b/isAmong.js.map @@ -0,0 +1 @@ +{"version":3,"file":"isAmong.js","sourceRoot":"","sources":["src/isAmong.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,0BAUC;AAXD,qCAAqC;AACrC,SAAgB,OAAO,CACnB,KAAsB,EACtB,KAAc;;;QAEd,KAAmB,IAAA,UAAA,SAAA,KAAK,CAAA,4BAAA,+CAAE,CAAC;YAAtB,IAAM,MAAI,kBAAA;YACX,IAAI,MAAI,KAAK,KAAK,EAAE,CAAC;gBACjB,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;;;;;;;;;IACD,OAAO,KAAK,CAAC;AACjB,CAAC"} \ No newline at end of file diff --git a/isPromiseLike.d.ts b/isPromiseLike.d.ts new file mode 100644 index 0000000..e881cb9 --- /dev/null +++ b/isPromiseLike.d.ts @@ -0,0 +1 @@ +export declare function isPromiseLike(o: any): o is PromiseLike; diff --git a/isPromiseLike.js b/isPromiseLike.js new file mode 100644 index 0000000..eb3276f --- /dev/null +++ b/isPromiseLike.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isPromiseLike = isPromiseLike; +function isPromiseLike(o) { + return typeof o === "object" && o !== null && "then" in o && typeof o.then === "function"; +} +//# sourceMappingURL=isPromiseLike.js.map \ No newline at end of file diff --git a/isPromiseLike.js.map b/isPromiseLike.js.map new file mode 100644 index 0000000..4daa470 --- /dev/null +++ b/isPromiseLike.js.map @@ -0,0 +1 @@ +{"version":3,"file":"isPromiseLike.js","sourceRoot":"","sources":["src/isPromiseLike.ts"],"names":[],"mappings":";;AAAA,sCAEC;AAFD,SAAgB,aAAa,CAAW,CAAM;IAC1C,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,MAAM,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC;AAC9F,CAAC"} \ No newline at end of file diff --git a/lab/PromiseOrNot.d.ts b/lab/PromiseOrNot.d.ts new file mode 100644 index 0000000..5ad9139 --- /dev/null +++ b/lab/PromiseOrNot.d.ts @@ -0,0 +1 @@ +export type PromiseOrNot = PromiseLike | T; diff --git a/lab/PromiseOrNot.js b/lab/PromiseOrNot.js new file mode 100644 index 0000000..206c5b9 --- /dev/null +++ b/lab/PromiseOrNot.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=PromiseOrNot.js.map \ No newline at end of file diff --git a/lab/PromiseOrNot.js.map b/lab/PromiseOrNot.js.map new file mode 100644 index 0000000..e203d42 --- /dev/null +++ b/lab/PromiseOrNot.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PromiseOrNot.js","sourceRoot":"","sources":["../src/lab/PromiseOrNot.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lab/UnpackTypeGuard.d.ts b/lab/UnpackTypeGuard.d.ts new file mode 100644 index 0000000..af4fc37 --- /dev/null +++ b/lab/UnpackTypeGuard.d.ts @@ -0,0 +1 @@ +export type UnpackTypeGuard o is unknown> = T extends (o: any) => o is infer U ? U : never; diff --git a/lab/UnpackTypeGuard.js b/lab/UnpackTypeGuard.js new file mode 100644 index 0000000..69164c2 --- /dev/null +++ b/lab/UnpackTypeGuard.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=UnpackTypeGuard.js.map \ No newline at end of file diff --git a/lab/UnpackTypeGuard.js.map b/lab/UnpackTypeGuard.js.map new file mode 100644 index 0000000..b9600b9 --- /dev/null +++ b/lab/UnpackTypeGuard.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UnpackTypeGuard.js","sourceRoot":"","sources":["../src/lab/UnpackTypeGuard.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lab/defineAccessors.d.ts b/lab/defineAccessors.d.ts new file mode 100644 index 0000000..7153521 --- /dev/null +++ b/lab/defineAccessors.d.ts @@ -0,0 +1,4 @@ +export declare const defineAccessors: , K extends keyof T>(obj: T, propertyName: K, propertyDescriptor: { + get?: () => T[K]; + set?: (value: T[K]) => void; +}) => void; diff --git a/lab/defineAccessors.js b/lab/defineAccessors.js new file mode 100644 index 0000000..10a67d8 --- /dev/null +++ b/lab/defineAccessors.js @@ -0,0 +1,35 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.defineAccessors = void 0; +var defineAccessors = function (obj, propertyName, propertyDescriptor) { + var get = propertyDescriptor.get, set = propertyDescriptor.set; + Object.defineProperty(obj, propertyName, __assign(__assign(__assign({}, (Object.getOwnPropertyDescriptor(obj, propertyName) || { + "enumerable": true, + "configurable": true, + })), (get !== undefined + ? { + "get": function () { + return get.call(this); + }, + } + : {})), (set !== undefined + ? { + "set": function (value) { + set.call(this, value); + }, + } + : {}))); +}; +exports.defineAccessors = defineAccessors; +//# sourceMappingURL=defineAccessors.js.map \ No newline at end of file diff --git a/lab/defineAccessors.js.map b/lab/defineAccessors.js.map new file mode 100644 index 0000000..7875dd4 --- /dev/null +++ b/lab/defineAccessors.js.map @@ -0,0 +1 @@ +{"version":3,"file":"defineAccessors.js","sourceRoot":"","sources":["../src/lab/defineAccessors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAO,IAAM,eAAe,GAAG,UAC3B,GAAM,EACN,YAAe,EACf,kBAGC;IAEO,IAAA,GAAG,GAAU,kBAAkB,IAA5B,EAAE,GAAG,GAAK,kBAAkB,IAAvB,CAAwB;IAExC,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,YAAY,iCAChC,CAAC,MAAM,CAAC,wBAAwB,CAAC,GAAG,EAAE,YAAY,CAAC,IAAI;QACtD,YAAY,EAAE,IAAI;QAClB,cAAc,EAAE,IAAI;KACvB,CAAC,GACC,CAAC,GAAG,KAAK,SAAS;QACjB,CAAC,CAAC;YACI,KAAK,EAAE;gBACH,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;SACJ;QACH,CAAC,CAAC,EAAE,CAAC,GACN,CAAC,GAAG,KAAK,SAAS;QACjB,CAAC,CAAC;YACI,KAAK,EAAE,UAAU,KAAW;gBACxB,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC1B,CAAC;SACJ;QACH,CAAC,CAAC,EAAE,CAAC,EACX,CAAC;AACP,CAAC,CAAC;AA9BW,QAAA,eAAe,mBA8B1B"} \ No newline at end of file diff --git a/lab/index.d.ts b/lab/index.d.ts new file mode 100644 index 0000000..1817599 --- /dev/null +++ b/lab/index.d.ts @@ -0,0 +1,5 @@ +export * from "./defineAccessors"; +export * from "./overwriteReadonlyProp"; +export * from "./PromiseOrNot"; +export * from "./UnpackTypeGuard"; +export * from "./withDefaults"; diff --git a/lab/index.js b/lab/index.js new file mode 100644 index 0000000..5daa01b --- /dev/null +++ b/lab/index.js @@ -0,0 +1,22 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./defineAccessors"), exports); +__exportStar(require("./overwriteReadonlyProp"), exports); +__exportStar(require("./PromiseOrNot"), exports); +__exportStar(require("./UnpackTypeGuard"), exports); +__exportStar(require("./withDefaults"), exports); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lab/index.js.map b/lab/index.js.map new file mode 100644 index 0000000..5037606 --- /dev/null +++ b/lab/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/lab/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,0DAAwC;AACxC,iDAA+B;AAC/B,oDAAkC;AAClC,iDAA+B"} \ No newline at end of file diff --git a/lab/overwriteReadonlyProp.d.ts b/lab/overwriteReadonlyProp.d.ts new file mode 100644 index 0000000..225c2c2 --- /dev/null +++ b/lab/overwriteReadonlyProp.d.ts @@ -0,0 +1,7 @@ +/** + * Assign a value to a property even if the object is freezed or if the property is not writable + * Throw if the assignation fail ( for example if the property is non configurable write: false ) + * */ +export declare const overwriteReadonlyProp: (obj: T, propertyName: K, value: T[K]) => T[K]; diff --git a/lab/overwriteReadonlyProp.js b/lab/overwriteReadonlyProp.js new file mode 100644 index 0000000..22d5ab8 --- /dev/null +++ b/lab/overwriteReadonlyProp.js @@ -0,0 +1,47 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.overwriteReadonlyProp = void 0; +/** + * Assign a value to a property even if the object is freezed or if the property is not writable + * Throw if the assignation fail ( for example if the property is non configurable write: false ) + * */ +var overwriteReadonlyProp = function (obj, propertyName, value) { + try { + obj[propertyName] = value; + } + catch (_a) { } + if (obj[propertyName] === value) { + return value; + } + var errorDefineProperty = undefined; + var propertyDescriptor = Object.getOwnPropertyDescriptor(obj, propertyName) || { + "enumerable": true, + "configurable": true, + }; + if (!!propertyDescriptor.get) { + throw new Error("Probably a wrong ides to overwrite ".concat(String(propertyName), " getter")); + } + try { + Object.defineProperty(obj, propertyName, __assign(__assign({}, propertyDescriptor), { value: value })); + } + catch (error) { + errorDefineProperty = error; + } + if (obj[propertyName] !== value) { + throw errorDefineProperty || new Error("Can't assign"); + } + return value; +}; +exports.overwriteReadonlyProp = overwriteReadonlyProp; +//# sourceMappingURL=overwriteReadonlyProp.js.map \ No newline at end of file diff --git a/lab/overwriteReadonlyProp.js.map b/lab/overwriteReadonlyProp.js.map new file mode 100644 index 0000000..5c938f1 --- /dev/null +++ b/lab/overwriteReadonlyProp.js.map @@ -0,0 +1 @@ +{"version":3,"file":"overwriteReadonlyProp.js","sourceRoot":"","sources":["../src/lab/overwriteReadonlyProp.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;KAGK;AACE,IAAM,qBAAqB,GAAG,UACjC,GAAM,EACN,YAAe,EACf,KAAW;IAEX,IAAI,CAAC;QACD,GAAG,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC;IAC9B,CAAC;IAAC,WAAM,CAAC,CAAA,CAAC;IAEV,IAAI,GAAG,CAAC,YAAY,CAAC,KAAK,KAAK,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,IAAI,mBAAmB,GAAsB,SAAS,CAAC;IAEvD,IAAM,kBAAkB,GAAuB,MAAM,CAAC,wBAAwB,CAC1E,GAAG,EACH,YAAY,CACf,IAAI;QACD,YAAY,EAAE,IAAI;QAClB,cAAc,EAAE,IAAI;KACvB,CAAC;IAEF,IAAI,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,6CAAsC,MAAM,CAAC,YAAY,CAAC,YAAS,CAAC,CAAC;IACzF,CAAC;IAED,IAAI,CAAC;QACD,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,YAAY,wBAChC,kBAAkB,KACrB,KAAK,OAAA,IACP,CAAC;IACP,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,mBAAmB,GAAG,KAAc,CAAC;IACzC,CAAC;IAED,IAAI,GAAG,CAAC,YAAY,CAAC,KAAK,KAAK,EAAE,CAAC;QAC9B,MAAM,mBAAmB,IAAI,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAzCW,QAAA,qBAAqB,yBAyChC"} \ No newline at end of file diff --git a/lab/withDefaults.d.ts b/lab/withDefaults.d.ts new file mode 100644 index 0000000..e6ec041 --- /dev/null +++ b/lab/withDefaults.d.ts @@ -0,0 +1,16 @@ +import "../tools/Object.fromEntries"; +/** + * Like Function.prototype.bind() but for a function that + * receives their parameters wrapped in an object. + * See documentation for more details: + * https://docs.tsafe.dev/withdefaults + */ +export declare function withDefaults, DefaultKey extends keyof Params, R>(f: (params: Params) => R, defaultParams: keyof Params extends never ? Record : { + [Key in DefaultKey]: Params[Key]; +}): (params: { + [Key in keyof Omit]: Params[Key]; +} & { + defaultsOverwrite?: { + [Key in DefaultKey]?: [Params[Key]]; + }; +}) => R; diff --git a/lab/withDefaults.js b/lab/withDefaults.js new file mode 100644 index 0000000..eebe0eb --- /dev/null +++ b/lab/withDefaults.js @@ -0,0 +1,63 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __rest = (this && this.__rest) || function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.withDefaults = withDefaults; +require("../tools/Object.fromEntries"); +/** + * Like Function.prototype.bind() but for a function that + * receives their parameters wrapped in an object. + * See documentation for more details: + * https://docs.tsafe.dev/withdefaults + */ +function withDefaults(f, defaultParams) { + return function (params) { + var _a = params.defaultsOverwrite, defaultsOverwrite = _a === void 0 ? {} : _a, actualParams = __rest(params, ["defaultsOverwrite"]); + return f(__assign(__assign(__assign({}, defaultParams), actualParams), Object.fromEntries(Object.entries(defaultsOverwrite) + .filter(function (_a) { + var _b = __read(_a, 2), value = _b[1]; + return value !== undefined; + }) + .map(function (_a) { + var _b = __read(_a, 2), key = _b[0], value = _b[1]; + return [key, value[0]]; + })))); + }; +} +//# sourceMappingURL=withDefaults.js.map \ No newline at end of file diff --git a/lab/withDefaults.js.map b/lab/withDefaults.js.map new file mode 100644 index 0000000..188c7d2 --- /dev/null +++ b/lab/withDefaults.js.map @@ -0,0 +1 @@ +{"version":3,"file":"withDefaults.js","sourceRoot":"","sources":["../src/lab/withDefaults.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,oCAuBC;AA9BD,uCAAqC;AACrC;;;;;GAKG;AACH,SAAgB,YAAY,CACxB,CAAwB,EACxB,aAE0C;IAM1C,OAAO,UAAA,MAAM;QACD,IAAA,KAA4C,MAAM,kBAA5B,EAAtB,iBAAiB,mBAAG,EAAE,KAAA,EAAK,YAAY,UAAK,MAAM,EAApD,qBAA2C,CAAF,CAAY;QAE3D,OAAO,CAAC,CAAC,+BACF,aAAa,GACb,YAAY,GACZ,MAAM,CAAC,WAAW,CACjB,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC;aAC5B,MAAM,CAAC,UAAC,EAAS;gBAAT,KAAA,aAAS,EAAN,KAAK,QAAA;YAAM,OAAA,KAAK,KAAK,SAAS;QAAnB,CAAmB,CAAC;aAC1C,GAAG,CAAC,UAAC,EAAY;gBAAZ,KAAA,aAAY,EAAX,GAAG,QAAA,EAAE,KAAK,QAAA;YAAM,OAAA,CAAC,GAAG,EAAG,KAAa,CAAC,CAAC,CAAC,CAAC;QAAxB,CAAwB,CAAC,CACvD,CACG,CAAC,CAAC;IACd,CAAC,CAAC;AACN,CAAC"} \ No newline at end of file diff --git a/noUndefined.d.ts b/noUndefined.d.ts new file mode 100644 index 0000000..51e3bbc --- /dev/null +++ b/noUndefined.d.ts @@ -0,0 +1,9 @@ +/** + * Removes the enumerable properties whose values are + * undefined. + * + * Example: + * noUndefined({ "foo": undefined, "bar": 3 }) returns + * a new object { "bar": 3 } + */ +export declare function noUndefined(obj: T): T; diff --git a/noUndefined.js b/noUndefined.js new file mode 100644 index 0000000..9c41c39 --- /dev/null +++ b/noUndefined.js @@ -0,0 +1,22 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.noUndefined = noUndefined; +/** + * Removes the enumerable properties whose values are + * undefined. + * + * Example: + * noUndefined({ "foo": undefined, "bar": 3 }) returns + * a new object { "bar": 3 } + */ +function noUndefined(obj) { + var out = {}; + for (var key in obj) { + if (obj[key] === undefined) { + continue; + } + out[key] = obj[key]; + } + return out; +} +//# sourceMappingURL=noUndefined.js.map \ No newline at end of file diff --git a/noUndefined.js.map b/noUndefined.js.map new file mode 100644 index 0000000..fecb70d --- /dev/null +++ b/noUndefined.js.map @@ -0,0 +1 @@ +{"version":3,"file":"noUndefined.js","sourceRoot":"","sources":["src/noUndefined.ts"],"names":[],"mappings":";;AAQA,kCAYC;AApBD;;;;;;;GAOG;AACH,SAAgB,WAAW,CAAmB,GAAM;IAChD,IAAM,GAAG,GAAe,EAAS,CAAC;IAElC,KAAK,IAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACpB,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;YACzB,SAAS;QACb,CAAC;QAED,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC"} \ No newline at end of file diff --git a/objectEntries.d.ts b/objectEntries.d.ts new file mode 100644 index 0000000..723eabc --- /dev/null +++ b/objectEntries.d.ts @@ -0,0 +1,8 @@ +/** https://docs.tsafe.dev/objectentries */ +export declare function objectEntries>(o: O): Exclude<{ + [Key in keyof O]: [Key, O[Key]]; +}[keyof O], undefined>[]; +/** Return type of objectEntries https://docs.tsafe.dev/objectentries */ +export type ObjectEntries> = Exclude<{ + [Key in keyof O]: [Key, O[Key]]; +}[keyof O], undefined>[]; diff --git a/objectEntries.js b/objectEntries.js new file mode 100644 index 0000000..278481e --- /dev/null +++ b/objectEntries.js @@ -0,0 +1,8 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.objectEntries = objectEntries; +/** https://docs.tsafe.dev/objectentries */ +function objectEntries(o) { + return Object.entries(o); +} +//# sourceMappingURL=objectEntries.js.map \ No newline at end of file diff --git a/objectEntries.js.map b/objectEntries.js.map new file mode 100644 index 0000000..2c97bed --- /dev/null +++ b/objectEntries.js.map @@ -0,0 +1 @@ +{"version":3,"file":"objectEntries.js","sourceRoot":"","sources":["src/objectEntries.ts"],"names":[],"mappings":";;AACA,sCAIC;AALD,2CAA2C;AAC3C,SAAgB,aAAa,CACzB,CAAI;IAEJ,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAQ,CAAC;AACpC,CAAC"} \ No newline at end of file diff --git a/objectFromEntries.d.ts b/objectFromEntries.d.ts new file mode 100644 index 0000000..09e62db --- /dev/null +++ b/objectFromEntries.d.ts @@ -0,0 +1,8 @@ +/** https://docs.tsafe.dev/objectFromEntries */ +export declare function objectFromEntries(entries: readonly Entry[]): { + [Key in Entry[0]]: Extract[1]; +}; +/** Return type of objectFromEntries https://docs.tsafe.dev/objectFromEntries */ +export type ObjectFromEntries = { + [Key in Entry[0]]: Extract[1]; +}; diff --git a/objectFromEntries.js b/objectFromEntries.js new file mode 100644 index 0000000..bf3653f --- /dev/null +++ b/objectFromEntries.js @@ -0,0 +1,8 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.objectFromEntries = objectFromEntries; +/** https://docs.tsafe.dev/objectFromEntries */ +function objectFromEntries(entries) { + return Object.fromEntries(entries); +} +//# sourceMappingURL=objectFromEntries.js.map \ No newline at end of file diff --git a/objectFromEntries.js.map b/objectFromEntries.js.map new file mode 100644 index 0000000..ab3ce60 --- /dev/null +++ b/objectFromEntries.js.map @@ -0,0 +1 @@ +{"version":3,"file":"objectFromEntries.js","sourceRoot":"","sources":["src/objectFromEntries.ts"],"names":[],"mappings":";;AACA,8CAIC;AALD,+CAA+C;AAC/C,SAAgB,iBAAiB,CAC7B,OAAyB;IAEzB,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAQ,CAAC;AAC9C,CAAC"} \ No newline at end of file diff --git a/objectKeys.d.ts b/objectKeys.d.ts new file mode 100644 index 0000000..103b048 --- /dev/null +++ b/objectKeys.d.ts @@ -0,0 +1,2 @@ +/** https://docs.tsafe.dev/objectKeys */ +export declare function objectKeys>(o: T): (keyof T)[]; diff --git a/objectKeys.js b/objectKeys.js new file mode 100644 index 0000000..850220a --- /dev/null +++ b/objectKeys.js @@ -0,0 +1,8 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.objectKeys = objectKeys; +/** https://docs.tsafe.dev/objectKeys */ +function objectKeys(o) { + return Object.keys(o); +} +//# sourceMappingURL=objectKeys.js.map \ No newline at end of file diff --git a/objectKeys.js.map b/objectKeys.js.map new file mode 100644 index 0000000..65d3fd9 --- /dev/null +++ b/objectKeys.js.map @@ -0,0 +1 @@ +{"version":3,"file":"objectKeys.js","sourceRoot":"","sources":["src/objectKeys.ts"],"names":[],"mappings":";;AACA,gCAEC;AAHD,wCAAwC;AACxC,SAAgB,UAAU,CAAoC,CAAI;IAC9D,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAQ,CAAC;AACjC,CAAC"} \ No newline at end of file diff --git a/package.json b/package.json index 999d7b0..0e5d520 100755 --- a/package.json +++ b/package.json @@ -6,18 +6,6 @@ "type": "git", "url": "git://github.com/garronej/tsafe.git" }, - "scripts": { - "build": "yarn build:cjs && yarn build:esm && yarn build:deno", - "build:cjs": "tsc", - "build:esm": "rm -rf dist/esm && npx rollup -c", - "build:deno": "denoify", - "test": "yarn test:node && yarn test:deno", - "test:deno": "deno run --reload --unstable --no-check deno_dist/mod.ts", - "test:node": "ts-node test/index.ts", - "_format": "prettier '**/*.{ts,tsx,json,md,js}'", - "format": "npm run _format -- --write", - "format:check": "npm run _format -- --list-different" - }, "lint-staged": { "*.{ts,tsx,json,md}": [ "prettier --write" @@ -30,35 +18,305 @@ }, "author": "u/garronej", "license": "MIT", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "module": "dist/esm/index.mjs", + "main": "index.js", + "types": "index.d.ts", + "module": "esm/index.mjs", "exports": { ".": { - "require": "./dist/index.js", - "import": "./dist/esm/index.mjs", - "types": "./dist/index.d.ts" + "require": "./index.js", + "import": "./esm/index.mjs", + "types": "./index.d.ts" }, "./*": { - "require": "./dist/*.js", - "import": "./dist/esm/*.mjs", - "types": "./dist/*.d.ts" + "require": "./*.js", + "import": "./esm/*.mjs", + "types": "./*.d.ts" }, "./lab": { - "require": "./dist/lab/index.js", - "import": "./dist/esm/lab/index.mjs", - "types": "./dist/lab/index.d.ts" + "require": "./lab/index.js", + "import": "./esm/lab/index.mjs", + "types": "./lab/index.d.ts" }, "./tools": { - "require": "./dist/tools/index.js", - "import": "./dist/esm/tools/index.mjs", - "types": "./dist/tools/index.d.ts" + "require": "./tools/index.js", + "import": "./esm/tools/index.mjs", + "types": "./tools/index.d.ts" } }, "files": [ - "src/", - "dist/", - "!dist/tsconfig.tsbuildinfo" + "src/Equals.ts", + "src/Extends.ts", + "src/MethodNames.ts", + "src/Not.ts", + "src/Param0.ts", + "src/Parameters.ts", + "src/PickOptionals.ts", + "src/PickRequired.ts", + "src/Reflect.ts", + "src/ReturnType.ts", + "src/UnionToIntersection.ts", + "src/UnpackPromise.ts", + "src/assert.ts", + "src/capitalize.ts", + "src/exclude.ts", + "src/flip.ts", + "src/id.ts", + "src/index.ts", + "src/is.ts", + "src/isAmong.ts", + "src/isPromiseLike.ts", + "src/lab/PromiseOrNot.ts", + "src/lab/UnpackTypeGuard.ts", + "src/lab/defineAccessors.ts", + "src/lab/index.ts", + "src/lab/overwriteReadonlyProp.ts", + "src/lab/withDefaults.ts", + "src/noUndefined.ts", + "src/objectEntries.ts", + "src/objectFromEntries.ts", + "src/objectKeys.ts", + "src/symToStr.ts", + "src/tools/Object.fromEntries.ts", + "src/tools/StrictEquals.ts", + "src/tools/Unite.ts", + "src/tools/index.ts", + "src/tools/toUpperCase.ts", + "src/typeGuard.ts", + "src/uncapitalize.ts", + "Equals.d.ts", + "Equals.js", + "Equals.js.map", + "Extends.d.ts", + "Extends.js", + "Extends.js.map", + "MethodNames.d.ts", + "MethodNames.js", + "MethodNames.js.map", + "Not.d.ts", + "Not.js", + "Not.js.map", + "Param0.d.ts", + "Param0.js", + "Param0.js.map", + "Parameters.d.ts", + "Parameters.js", + "Parameters.js.map", + "PickOptionals.d.ts", + "PickOptionals.js", + "PickOptionals.js.map", + "PickRequired.d.ts", + "PickRequired.js", + "PickRequired.js.map", + "Reflect.d.ts", + "Reflect.js", + "Reflect.js.map", + "ReturnType.d.ts", + "ReturnType.js", + "ReturnType.js.map", + "UnionToIntersection.d.ts", + "UnionToIntersection.js", + "UnionToIntersection.js.map", + "UnpackPromise.d.ts", + "UnpackPromise.js", + "UnpackPromise.js.map", + "assert.d.ts", + "assert.js", + "assert.js.map", + "capitalize.d.ts", + "capitalize.js", + "capitalize.js.map", + "esm/Equals.d.ts", + "esm/Equals.mjs", + "esm/Equals.mjs.map", + "esm/Extends.d.ts", + "esm/Extends.mjs", + "esm/Extends.mjs.map", + "esm/MethodNames.d.ts", + "esm/MethodNames.mjs", + "esm/MethodNames.mjs.map", + "esm/Not.d.ts", + "esm/Not.mjs", + "esm/Not.mjs.map", + "esm/Param0.d.ts", + "esm/Param0.mjs", + "esm/Param0.mjs.map", + "esm/Parameters.d.ts", + "esm/Parameters.mjs", + "esm/Parameters.mjs.map", + "esm/PickOptionals.d.ts", + "esm/PickOptionals.mjs", + "esm/PickOptionals.mjs.map", + "esm/PickRequired.d.ts", + "esm/PickRequired.mjs", + "esm/PickRequired.mjs.map", + "esm/Reflect.d.ts", + "esm/Reflect.mjs", + "esm/Reflect.mjs.map", + "esm/ReturnType.d.ts", + "esm/ReturnType.mjs", + "esm/ReturnType.mjs.map", + "esm/UnionToIntersection.d.ts", + "esm/UnionToIntersection.mjs", + "esm/UnionToIntersection.mjs.map", + "esm/UnpackPromise.d.ts", + "esm/UnpackPromise.mjs", + "esm/UnpackPromise.mjs.map", + "esm/assert.d.ts", + "esm/assert.mjs", + "esm/assert.mjs.map", + "esm/capitalize.d.ts", + "esm/capitalize.mjs", + "esm/capitalize.mjs.map", + "esm/exclude.d.ts", + "esm/exclude.mjs", + "esm/exclude.mjs.map", + "esm/flip.d.ts", + "esm/flip.mjs", + "esm/flip.mjs.map", + "esm/id.d.ts", + "esm/id.mjs", + "esm/id.mjs.map", + "esm/index.d.ts", + "esm/index.mjs", + "esm/index.mjs.map", + "esm/is.d.ts", + "esm/is.mjs", + "esm/is.mjs.map", + "esm/isAmong.d.ts", + "esm/isAmong.mjs", + "esm/isAmong.mjs.map", + "esm/isPromiseLike.d.ts", + "esm/isPromiseLike.mjs", + "esm/isPromiseLike.mjs.map", + "esm/lab/PromiseOrNot.d.ts", + "esm/lab/PromiseOrNot.mjs", + "esm/lab/PromiseOrNot.mjs.map", + "esm/lab/UnpackTypeGuard.d.ts", + "esm/lab/UnpackTypeGuard.mjs", + "esm/lab/UnpackTypeGuard.mjs.map", + "esm/lab/defineAccessors.d.ts", + "esm/lab/defineAccessors.mjs", + "esm/lab/defineAccessors.mjs.map", + "esm/lab/index.d.ts", + "esm/lab/index.mjs", + "esm/lab/index.mjs.map", + "esm/lab/overwriteReadonlyProp.d.ts", + "esm/lab/overwriteReadonlyProp.mjs", + "esm/lab/overwriteReadonlyProp.mjs.map", + "esm/lab/withDefaults.d.ts", + "esm/lab/withDefaults.mjs", + "esm/lab/withDefaults.mjs.map", + "esm/noUndefined.d.ts", + "esm/noUndefined.mjs", + "esm/noUndefined.mjs.map", + "esm/objectEntries.d.ts", + "esm/objectEntries.mjs", + "esm/objectEntries.mjs.map", + "esm/objectFromEntries.d.ts", + "esm/objectFromEntries.mjs", + "esm/objectFromEntries.mjs.map", + "esm/objectKeys.d.ts", + "esm/objectKeys.mjs", + "esm/objectKeys.mjs.map", + "esm/symToStr.d.ts", + "esm/symToStr.mjs", + "esm/symToStr.mjs.map", + "esm/tools/Object.fromEntries.d.ts", + "esm/tools/Object.fromEntries.mjs", + "esm/tools/Object.fromEntries.mjs.map", + "esm/tools/StrictEquals.d.ts", + "esm/tools/StrictEquals.mjs", + "esm/tools/StrictEquals.mjs.map", + "esm/tools/Unite.d.ts", + "esm/tools/Unite.mjs", + "esm/tools/Unite.mjs.map", + "esm/tools/index.d.ts", + "esm/tools/index.mjs", + "esm/tools/index.mjs.map", + "esm/tools/toUpperCase.d.ts", + "esm/tools/toUpperCase.mjs", + "esm/tools/toUpperCase.mjs.map", + "esm/typeGuard.d.ts", + "esm/typeGuard.mjs", + "esm/typeGuard.mjs.map", + "esm/uncapitalize.d.ts", + "esm/uncapitalize.mjs", + "esm/uncapitalize.mjs.map", + "exclude.d.ts", + "exclude.js", + "exclude.js.map", + "flip.d.ts", + "flip.js", + "flip.js.map", + "id.d.ts", + "id.js", + "id.js.map", + "index.d.ts", + "index.js", + "index.js.map", + "is.d.ts", + "is.js", + "is.js.map", + "isAmong.d.ts", + "isAmong.js", + "isAmong.js.map", + "isPromiseLike.d.ts", + "isPromiseLike.js", + "isPromiseLike.js.map", + "lab/PromiseOrNot.d.ts", + "lab/PromiseOrNot.js", + "lab/PromiseOrNot.js.map", + "lab/UnpackTypeGuard.d.ts", + "lab/UnpackTypeGuard.js", + "lab/UnpackTypeGuard.js.map", + "lab/defineAccessors.d.ts", + "lab/defineAccessors.js", + "lab/defineAccessors.js.map", + "lab/index.d.ts", + "lab/index.js", + "lab/index.js.map", + "lab/overwriteReadonlyProp.d.ts", + "lab/overwriteReadonlyProp.js", + "lab/overwriteReadonlyProp.js.map", + "lab/withDefaults.d.ts", + "lab/withDefaults.js", + "lab/withDefaults.js.map", + "noUndefined.d.ts", + "noUndefined.js", + "noUndefined.js.map", + "objectEntries.d.ts", + "objectEntries.js", + "objectEntries.js.map", + "objectFromEntries.d.ts", + "objectFromEntries.js", + "objectFromEntries.js.map", + "objectKeys.d.ts", + "objectKeys.js", + "objectKeys.js.map", + "symToStr.d.ts", + "symToStr.js", + "symToStr.js.map", + "tools/Object.fromEntries.d.ts", + "tools/Object.fromEntries.js", + "tools/Object.fromEntries.js.map", + "tools/StrictEquals.d.ts", + "tools/StrictEquals.js", + "tools/StrictEquals.js.map", + "tools/Unite.d.ts", + "tools/Unite.js", + "tools/Unite.js.map", + "tools/index.d.ts", + "tools/index.js", + "tools/index.js.map", + "tools/toUpperCase.d.ts", + "tools/toUpperCase.js", + "tools/toUpperCase.js.map", + "typeGuard.d.ts", + "typeGuard.js", + "typeGuard.js.map", + "uncapitalize.d.ts", + "uncapitalize.js", + "uncapitalize.js.map" ], "keywords": [], "homepage": "https://github.com/garronej/tsafe", diff --git a/symToStr.d.ts b/symToStr.d.ts new file mode 100644 index 0000000..2857462 --- /dev/null +++ b/symToStr.d.ts @@ -0,0 +1,2 @@ +/** @see */ +export declare function symToStr>(wrap: T): Exclude; diff --git a/symToStr.js b/symToStr.js new file mode 100644 index 0000000..7461ad6 --- /dev/null +++ b/symToStr.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.symToStr = symToStr; +/** @see */ +function symToStr(wrap) { + // @ts-expect-error: We know better + return Object.keys(wrap)[0]; +} +//# sourceMappingURL=symToStr.js.map \ No newline at end of file diff --git a/symToStr.js.map b/symToStr.js.map new file mode 100644 index 0000000..5596853 --- /dev/null +++ b/symToStr.js.map @@ -0,0 +1 @@ +{"version":3,"file":"symToStr.js","sourceRoot":"","sources":["src/symToStr.ts"],"names":[],"mappings":";;AACA,4BAGC;AAJD,kDAAkD;AAClD,SAAgB,QAAQ,CAAoC,IAAO;IAC/D,mCAAmC;IACnC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAChC,CAAC"} \ No newline at end of file diff --git a/tools/Object.fromEntries.d.ts b/tools/Object.fromEntries.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/tools/Object.fromEntries.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/tools/Object.fromEntries.js b/tools/Object.fromEntries.js new file mode 100644 index 0000000..cecd087 --- /dev/null +++ b/tools/Object.fromEntries.js @@ -0,0 +1,34 @@ +"use strict"; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +if (!Object.fromEntries) { + Object.defineProperty(Object, "fromEntries", { + "value": function (entries) { + if (!entries || !entries[Symbol.iterator]) { + throw new Error("Object.fromEntries() requires a single iterable argument"); + } + var o = {}; + Object.keys(entries).forEach(function (key) { + var _a = __read(entries[key], 2), k = _a[0], v = _a[1]; + o[k] = v; + }); + return o; + }, + }); +} +//# sourceMappingURL=Object.fromEntries.js.map \ No newline at end of file diff --git a/tools/Object.fromEntries.js.map b/tools/Object.fromEntries.js.map new file mode 100644 index 0000000..e92f193 --- /dev/null +++ b/tools/Object.fromEntries.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Object.fromEntries.js","sourceRoot":"","sources":["../src/tools/Object.fromEntries.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAI,CAAE,MAAc,CAAC,WAAW,EAAE,CAAC;IAC/B,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE;QACzC,OAAO,EAAE,UAAU,OAAY;YAC3B,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACxC,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;YAChF,CAAC;YAED,IAAM,CAAC,GAAQ,EAAE,CAAC;YAElB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG;gBACtB,IAAA,KAAA,OAAS,OAAO,CAAC,GAAG,CAAC,IAAA,EAApB,CAAC,QAAA,EAAE,CAAC,QAAgB,CAAC;gBAE5B,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACb,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,CAAC;QACb,CAAC;KACJ,CAAC,CAAC;AACP,CAAC"} \ No newline at end of file diff --git a/tools/StrictEquals.d.ts b/tools/StrictEquals.d.ts new file mode 100644 index 0000000..0871a91 --- /dev/null +++ b/tools/StrictEquals.d.ts @@ -0,0 +1 @@ +export type StrictEquals = (() => A extends A2 ? true : false) extends () => A extends A1 ? true : false ? true : false; diff --git a/tools/StrictEquals.js b/tools/StrictEquals.js new file mode 100644 index 0000000..1fb6ccc --- /dev/null +++ b/tools/StrictEquals.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=StrictEquals.js.map \ No newline at end of file diff --git a/tools/StrictEquals.js.map b/tools/StrictEquals.js.map new file mode 100644 index 0000000..842deab --- /dev/null +++ b/tools/StrictEquals.js.map @@ -0,0 +1 @@ +{"version":3,"file":"StrictEquals.js","sourceRoot":"","sources":["../src/tools/StrictEquals.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tools/Unite.d.ts b/tools/Unite.d.ts new file mode 100644 index 0000000..a75c362 --- /dev/null +++ b/tools/Unite.d.ts @@ -0,0 +1,3 @@ +export type Unite = T extends Record ? { + [Key in keyof T]: T[Key]; +} : T; diff --git a/tools/Unite.js b/tools/Unite.js new file mode 100644 index 0000000..85f5b5d --- /dev/null +++ b/tools/Unite.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=Unite.js.map \ No newline at end of file diff --git a/tools/Unite.js.map b/tools/Unite.js.map new file mode 100644 index 0000000..13e4c6f --- /dev/null +++ b/tools/Unite.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Unite.js","sourceRoot":"","sources":["../src/tools/Unite.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/tools/index.d.ts b/tools/index.d.ts new file mode 100644 index 0000000..4d0de7c --- /dev/null +++ b/tools/index.d.ts @@ -0,0 +1,4 @@ +export * from "./Object.fromEntries"; +export * from "./StrictEquals"; +export * from "./toUpperCase"; +export * from "./Unite"; diff --git a/tools/index.js b/tools/index.js new file mode 100644 index 0000000..0051b91 --- /dev/null +++ b/tools/index.js @@ -0,0 +1,21 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./Object.fromEntries"), exports); +__exportStar(require("./StrictEquals"), exports); +__exportStar(require("./toUpperCase"), exports); +__exportStar(require("./Unite"), exports); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/tools/index.js.map b/tools/index.js.map new file mode 100644 index 0000000..be99440 --- /dev/null +++ b/tools/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/tools/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,iDAA+B;AAC/B,gDAA8B;AAC9B,0CAAwB"} \ No newline at end of file diff --git a/tools/toUpperCase.d.ts b/tools/toUpperCase.d.ts new file mode 100644 index 0000000..c2dd61b --- /dev/null +++ b/tools/toUpperCase.d.ts @@ -0,0 +1 @@ +export declare function toUpperCase(str: string): string; diff --git a/tools/toUpperCase.js b/tools/toUpperCase.js new file mode 100644 index 0000000..9e4d94e --- /dev/null +++ b/tools/toUpperCase.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.toUpperCase = toUpperCase; +function toUpperCase(str) { + return str.toUpperCase(); +} +//# sourceMappingURL=toUpperCase.js.map \ No newline at end of file diff --git a/tools/toUpperCase.js.map b/tools/toUpperCase.js.map new file mode 100644 index 0000000..e57d689 --- /dev/null +++ b/tools/toUpperCase.js.map @@ -0,0 +1 @@ +{"version":3,"file":"toUpperCase.js","sourceRoot":"","sources":["../src/tools/toUpperCase.ts"],"names":[],"mappings":";;AAAA,kCAEC;AAFD,SAAgB,WAAW,CAAC,GAAW;IACnC,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC;AAC7B,CAAC"} \ No newline at end of file diff --git a/tsconfig.tsbuildinfo b/tsconfig.tsbuildinfo new file mode 100644 index 0000000..25fafa4 --- /dev/null +++ b/tsconfig.tsbuildinfo @@ -0,0 +1 @@ +{"fileNames":["../node_modules/typescript/lib/lib.es5.d.ts","../node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/typescript/lib/lib.es2017.d.ts","../node_modules/typescript/lib/lib.es2018.d.ts","../node_modules/typescript/lib/lib.es2019.d.ts","../node_modules/typescript/lib/lib.es2020.d.ts","../node_modules/typescript/lib/lib.dom.d.ts","../node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/typescript/lib/lib.es2016.intl.d.ts","../node_modules/typescript/lib/lib.es2017.date.d.ts","../node_modules/typescript/lib/lib.es2017.object.d.ts","../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2017.string.d.ts","../node_modules/typescript/lib/lib.es2017.intl.d.ts","../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../node_modules/typescript/lib/lib.es2018.intl.d.ts","../node_modules/typescript/lib/lib.es2018.promise.d.ts","../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../node_modules/typescript/lib/lib.es2019.array.d.ts","../node_modules/typescript/lib/lib.es2019.object.d.ts","../node_modules/typescript/lib/lib.es2019.string.d.ts","../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../node_modules/typescript/lib/lib.es2019.intl.d.ts","../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../node_modules/typescript/lib/lib.es2020.date.d.ts","../node_modules/typescript/lib/lib.es2020.promise.d.ts","../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2020.string.d.ts","../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2020.intl.d.ts","../node_modules/typescript/lib/lib.es2020.number.d.ts","../node_modules/typescript/lib/lib.decorators.d.ts","../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../src/tools/Unite.ts","../src/tools/StrictEquals.ts","../src/Equals.ts","../src/Extends.ts","../src/MethodNames.ts","../src/Not.ts","../src/Parameters.ts","../src/Param0.ts","../src/PickOptionals.ts","../src/PickRequired.ts","../src/Reflect.ts","../src/ReturnType.ts","../src/UnionToIntersection.ts","../src/UnpackPromise.ts","../src/lab/overwriteReadonlyProp.ts","../src/assert.ts","../src/capitalize.ts","../src/exclude.ts","../src/flip.ts","../src/id.ts","../src/isPromiseLike.ts","../src/objectKeys.ts","../src/typeGuard.ts","../src/isAmong.ts","../src/objectEntries.ts","../src/objectFromEntries.ts","../src/noUndefined.ts","../src/uncapitalize.ts","../src/symToStr.ts","../src/index.ts","../src/is.ts","../src/lab/PromiseOrNot.ts","../src/lab/UnpackTypeGuard.ts","../src/lab/defineAccessors.ts","../src/tools/Object.fromEntries.ts","../src/lab/withDefaults.ts","../src/lab/index.ts","../src/tools/toUpperCase.ts","../src/tools/index.ts","../node_modules/@types/estree/index.d.ts","../node_modules/@types/node/compatibility/disposable.d.ts","../node_modules/@types/node/compatibility/indexable.d.ts","../node_modules/@types/node/compatibility/iterators.d.ts","../node_modules/@types/node/compatibility/index.d.ts","../node_modules/@types/node/ts5.6/globals.typedarray.d.ts","../node_modules/@types/node/ts5.6/buffer.buffer.d.ts","../node_modules/undici-types/header.d.ts","../node_modules/undici-types/readable.d.ts","../node_modules/undici-types/file.d.ts","../node_modules/undici-types/fetch.d.ts","../node_modules/undici-types/formdata.d.ts","../node_modules/undici-types/connector.d.ts","../node_modules/undici-types/client.d.ts","../node_modules/undici-types/errors.d.ts","../node_modules/undici-types/dispatcher.d.ts","../node_modules/undici-types/global-dispatcher.d.ts","../node_modules/undici-types/global-origin.d.ts","../node_modules/undici-types/pool-stats.d.ts","../node_modules/undici-types/pool.d.ts","../node_modules/undici-types/handlers.d.ts","../node_modules/undici-types/balanced-pool.d.ts","../node_modules/undici-types/agent.d.ts","../node_modules/undici-types/mock-interceptor.d.ts","../node_modules/undici-types/mock-agent.d.ts","../node_modules/undici-types/mock-client.d.ts","../node_modules/undici-types/mock-pool.d.ts","../node_modules/undici-types/mock-errors.d.ts","../node_modules/undici-types/proxy-agent.d.ts","../node_modules/undici-types/env-http-proxy-agent.d.ts","../node_modules/undici-types/retry-handler.d.ts","../node_modules/undici-types/retry-agent.d.ts","../node_modules/undici-types/api.d.ts","../node_modules/undici-types/interceptors.d.ts","../node_modules/undici-types/util.d.ts","../node_modules/undici-types/cookies.d.ts","../node_modules/undici-types/patch.d.ts","../node_modules/undici-types/websocket.d.ts","../node_modules/undici-types/eventsource.d.ts","../node_modules/undici-types/filereader.d.ts","../node_modules/undici-types/diagnostics-channel.d.ts","../node_modules/undici-types/content-type.d.ts","../node_modules/undici-types/cache.d.ts","../node_modules/undici-types/index.d.ts","../node_modules/@types/node/globals.d.ts","../node_modules/@types/node/assert.d.ts","../node_modules/@types/node/assert/strict.d.ts","../node_modules/@types/node/async_hooks.d.ts","../node_modules/@types/node/buffer.d.ts","../node_modules/@types/node/child_process.d.ts","../node_modules/@types/node/cluster.d.ts","../node_modules/@types/node/console.d.ts","../node_modules/@types/node/constants.d.ts","../node_modules/@types/node/crypto.d.ts","../node_modules/@types/node/dgram.d.ts","../node_modules/@types/node/diagnostics_channel.d.ts","../node_modules/@types/node/dns.d.ts","../node_modules/@types/node/dns/promises.d.ts","../node_modules/@types/node/domain.d.ts","../node_modules/@types/node/dom-events.d.ts","../node_modules/@types/node/events.d.ts","../node_modules/@types/node/fs.d.ts","../node_modules/@types/node/fs/promises.d.ts","../node_modules/@types/node/http.d.ts","../node_modules/@types/node/http2.d.ts","../node_modules/@types/node/https.d.ts","../node_modules/@types/node/inspector.d.ts","../node_modules/@types/node/module.d.ts","../node_modules/@types/node/net.d.ts","../node_modules/@types/node/os.d.ts","../node_modules/@types/node/path.d.ts","../node_modules/@types/node/perf_hooks.d.ts","../node_modules/@types/node/process.d.ts","../node_modules/@types/node/punycode.d.ts","../node_modules/@types/node/querystring.d.ts","../node_modules/@types/node/readline.d.ts","../node_modules/@types/node/readline/promises.d.ts","../node_modules/@types/node/repl.d.ts","../node_modules/@types/node/sea.d.ts","../node_modules/@types/node/sqlite.d.ts","../node_modules/@types/node/stream.d.ts","../node_modules/@types/node/stream/promises.d.ts","../node_modules/@types/node/stream/consumers.d.ts","../node_modules/@types/node/stream/web.d.ts","../node_modules/@types/node/string_decoder.d.ts","../node_modules/@types/node/test.d.ts","../node_modules/@types/node/timers.d.ts","../node_modules/@types/node/timers/promises.d.ts","../node_modules/@types/node/tls.d.ts","../node_modules/@types/node/trace_events.d.ts","../node_modules/@types/node/tty.d.ts","../node_modules/@types/node/url.d.ts","../node_modules/@types/node/util.d.ts","../node_modules/@types/node/v8.d.ts","../node_modules/@types/node/vm.d.ts","../node_modules/@types/node/wasi.d.ts","../node_modules/@types/node/worker_threads.d.ts","../node_modules/@types/node/zlib.d.ts","../node_modules/@types/node/ts5.6/index.d.ts","../node_modules/@types/parse-json/index.d.ts","../node_modules/@types/resolve/index.d.ts"],"fileIdsList":[[91,133],[91,130,133],[91,132,133],[91,133,138,168],[91,133,134,139,145,146,153,165,176],[91,133,134,135,145,153],[86,87,88,91,133],[91,133,136,177],[91,133,137,138,146,154],[91,133,138,165,173],[91,133,139,141,145,153],[91,132,133,140],[91,133,141,142],[91,133,145],[91,133,143,145],[91,132,133,145],[91,133,145,146,147,165,176],[91,133,145,146,147,160,165,168],[91,128,133,181],[91,128,133,141,145,148,153,165,176],[91,133,145,146,148,149,153,165,173,176],[91,133,148,150,165,173,176],[91,133,145,151],[91,133,152,176,181],[91,133,141,145,153,165],[91,133,154],[91,133,155],[91,132,133,156],[91,130,131,132,133,134,135,136,137,138,139,140,141,142,143,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182],[91,133,158],[91,133,159],[91,133,145,160,161],[91,133,160,162,177,179],[91,133,145,165,166,167,168],[91,133,165,167],[91,133,165,166],[91,133,168],[91,133,169],[91,130,133,165],[91,133,145,171,172],[91,133,171,172],[91,133,138,153,165,173],[91,133,174],[133],[89,90,91,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182],[91,133,153,175],[91,133,148,159,176],[91,133,138,177],[91,133,165,178],[91,133,152,179],[91,133,180],[91,133,138,145,147,156,165,176,179,181],[91,133,165,182],[91,100,104,133,176],[91,100,133,165,176],[91,95,133],[91,97,100,133,173,176],[91,133,153,173],[91,133,183],[91,95,133,183],[91,97,100,133,153,176],[91,92,93,96,99,133,145,165,176],[91,100,107,133],[91,92,98,133],[91,100,121,122,133],[91,96,100,133,168,176,183],[91,121,133,183],[91,94,95,133,183],[91,100,133],[91,94,95,96,97,98,99,100,101,102,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,122,123,124,125,126,127,133],[91,100,115,133],[91,100,107,108,133],[91,98,100,108,109,133],[91,99,133],[91,92,95,100,133],[91,100,104,108,109,133],[91,104,133],[91,98,100,103,133,176],[91,92,97,100,107,133],[91,133,165],[91,95,100,121,133,181,183],[46,47,91,133],[47,91,133],[52,91,133],[54,91,133],[48,60,91,133],[48,49,50,51,52,53,54,55,56,57,58,59,61,62,63,64,65,66,67,68,69,70,71,72,73,74,91,133],[61,91,133],[60,77,78,79,81,91,133],[80,91,133],[46,47,80,83,91,133]],"fileInfos":[{"version":"44e584d4f6444f58791784f1d530875970993129442a847597db702a073ca68c","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"9e8ca8ed051c2697578c023d9c29d6df689a083561feba5c14aedee895853999","affectsGlobalScope":true,"impliedFormat":1},{"version":"6920e1448680767498a0b77c6a00a8e77d14d62c3da8967b171f1ddffa3c18e4","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"45d8ccb3dfd57355eb29749919142d4321a0aa4df6acdfc54e30433d7176600a","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true,"impliedFormat":1},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true,"impliedFormat":1},{"version":"ea011c76963fb15ef1cdd7ce6a6808b46322c527de2077b6cfdf23ae6f5f9ec7","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"1a94697425a99354df73d9c8291e2ecd4dddd370aed4023c2d6dee6cccb32666","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true,"impliedFormat":1},{"version":"e3f9fc0ec0b96a9e642f11eda09c0be83a61c7b336977f8b9fdb1e9788e925fe","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"479553e3779be7d4f68e9f40cdb82d038e5ef7592010100410723ceced22a0f7","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"f6b19500d5de61452d537a4a495cfae224ff97de8b2afa9b156a14e261d9dc45","signature":"2ac80842d9cafe9e128a13bd4a26813cc5902ececc48de01367f38b52798bf8f"},{"version":"dfcc960e925b12f997798b18975d16d82ca2138907ce163832ea4f753a6026b1","signature":"18b1d10d73315c68e4a35eb2b70a662fa89f8c3a1287180f69415e80f9d4feb9"},{"version":"6696cbbf4e0aef7d295e4fe0475a7544cf02b3a5595bd1b22ed9ad22d379bfad","signature":"72f1c4c1b9fb45abab255f752dd46cbd01c9126888e2a0cf2db27bc89b6987cb"},{"version":"ad4db6954784838eb954201a77db42c9fd0cf2fd0899921d2e8f64558e1f10f1","signature":"d24e0412575e658221cd145cdd7b9ddc42efba03559f54a837a3d075a2719f83"},{"version":"3ecd442844194ce480cce579ff8c2be076c891e04e5fa8bb0b49900c70a5ac4a","signature":"0edd97545aea79cec27098c40ad8d09b35ecd0fa36fa6bdabe72d4772fe3a48a"},"02da4f252835cd9cdc1049dc4f27a336f44fc3fb2b587e340d03de45a48830e4",{"version":"565d63941eeb9103e33dc7beb7f7a8c7bfb505fd6adcec70685b2d5bceb07254","signature":"260a8544fe628efaed6408401910135295ff450af5c8ab76822db61e63ac6a32"},{"version":"5a2a089c405473a89f31ec31cc139252dfaa8b5db6652f9fe04c6856e0fab528","signature":"e896f32b7424fcc47a39ffaa580e2555f19da3129ad97e19825096e821a92d13"},{"version":"be2476a98a660ac0c6b14cb1bd09285f5d21e0fe5ba12b25adc2443db93421ce","signature":"00f6cb5af8f9ca81ad3e668aa743465587f0a609d3a7fbd113eefd561e6a137b"},{"version":"454fa710bcf4ac32638e96b0c467e1344165c927d221733aa2e77037b3539078","signature":"ce53f0cc7de2c5945e8828cc7651820a2ebdf90503a54de2bcf75f169ad2ad29"},{"version":"a579833fea0fbfa6f570fa782fc1d3bb7dc84e4366bd90ce1c63e5aa76b8a331","signature":"85d2371b2f96b2dd6ec7aa5f2d5099d5d10a4b4c614914f2b531872f7bdb037a"},{"version":"3fe43733113127f9873059a33ab3a1ee7761000f261159786ca2c85e736ddfa7","signature":"1eef420ff81e5840050097a0f15ab7858dca15aff0a2e9c7082c332c6fcef7ec"},{"version":"aa95feb248c3a59cb5f1d140b267f76420c7e99c5104726ac8d1e43cac3e146b","signature":"f54c9e9d1692e868be8e5da3638a5e38f5d2d1324de7752170d1ab4160d1cc67"},{"version":"37d5e328dceac953061ae95f6615f7ae4037f6ca53551c0fd246098e1142fe29","signature":"a2f01baa8dd04821fb53db2a4ce8770bed913354c5985163d0590fa4105db41a"},{"version":"155ca748fba2c70ffbebcc7b43a279c2a8b3924d2f0318f6d7b0a0c36bb78050","signature":"325901e778b557d39dc9796ce750c00e546cf13cfef7573717d77fb8c50687c8"},{"version":"185d654ab635adebd18b1cace92b18f2c161f5499d8cf060dd589dad40d22063","signature":"a934d18577892ccb9c785352562f0f352ea2da5773df02c72be235b2e34b6cdc"},{"version":"45a7c15ff5a0ee94f536f2ad4498f684c79f43a4e584935fa7ccba7541c29c7f","signature":"e9a099972022f2501f43698c344d04d55bcfd93233474d11039baa00cfb28bc4"},{"version":"afdf893e4c0326508a6eaf4fa01e48dd6fbc14be5db1e411643b1add6bfd1799","signature":"a58cff0575a3676a8706886ca86cdce3bd110f79961fb8f24529afed20269c01"},{"version":"eba74f85337fa43710efc6bbbc1f6197c3e971ca1518fd9dd823796b9e1bef3b","signature":"74b94d41129afb2f4ef6dae6669cc52f6352b83d11704e0143bbccbc483c2094"},{"version":"cb2b74bfed19553b90e37af353c58c53ee113af1406c580ab0b7a4b44aa9b022","signature":"9675934b30a3ba0582a480228b0770bc8b6e0612db80d930f829c1349a9cbf13"},{"version":"14bb1b036bfd724ba0bf734fd5ae9fea477b7fd1546b30c84d14f8d1f2ce0885","signature":"18f455507ad251d2e04fa76dc6e2a7ccb090329c092913fca6197c5fef5d19eb"},{"version":"af0d8efb7f42cdc0365c122faccbc9e2f86341cde8991d41e1f4887c50435711","signature":"0074b2c395fdd7241199a53b6b5a04c56af5a56366c9108491ea3a07676f364b"},{"version":"44ca42a7f19be47922792b05b903c31709e77423029a8cef6e4d1418ec43b27b","signature":"b998ec3bbb43f7486924f41b94f0380e62b83c656e12e97591bf1d7feb71d280"},{"version":"d78d41cc68cf3bdcd698165757b0ba5288d8bf4eb409cfd498365ec1557e3eaf","signature":"295d63f0ad3f577a40cbb630ce667e274908c814a2703fc13d103122b8215e9f"},{"version":"c060b86f89aa428249baa823f9e579f9075c40ef0552e790faba887de2758a71","signature":"82aeba550610395d2914fd6d1a4606d02b95a2a8b250a52ec303db71590b41b3"},{"version":"bb05a32e2d2173dca27c65b67edf40d15f08008c9f31069aaaa59ec9ecc1c9cd","signature":"14aff5197faa1b13369c3d455556e61f3f1bd0cd856a9fddefc37714d5fddab5"},{"version":"efd48cb21dfb286df7e29e009cd1e1ff5cfbfafa3ed162df78625a574af0f19c","signature":"4dde3a0c022816a842ebcaf7375b5e696736efd4836280377ec0aa0107879e4d"},{"version":"cd3f59c19b278b98cc209781c0836bddeb5527701d40b30935ea664ff2d7b4db","signature":"05232bf12123918b55128f74d7534831fea94983e8766b0cd8e9b2247e70217b"},{"version":"cc21a3b21e2f8f35dd8f90d28b6060a6c7bd1a72b99a77ec0556b519a7a73934","signature":"a8040c10d140be3f94f7bc993b29f8f7e34f56b5042b580ed8ca7a984fe95627"},"0e9a1b05166d67f3b3f622c21a6b21bd23ecaaa51215b46f2eabefca66a8c796",{"version":"4af3d826345b49f3e4b59a879277862b5b549773a91160bbb1b3cb3021e637f8","signature":"97b8f6bb0f05d60d72b4d10d70a1f897a1a8f37d4f68bf346afbdd32dbc7bbbe"},"ab46309b639fb01d162488e25afc36bf4a8da3ab37f09a6dc70c733a5b9829ba",{"version":"33fff7d4f694f3cfadba7d5b157a7ce4148a84b937b5184a6205e4a72dc41037","signature":"a14188d445479722060109930b6f38281cf57d2b370b6f3c4d89442504f3bed7"},{"version":"94e8eae7586e7b256cb3a0e266a0fb71d5307c542243963fad5f52c91ac40aa8","signature":"e71312168d55d3bfe145c4f577beb61b218c960454ce7658300e4bff58f60759"},{"version":"c57c3597ea5cdc3279a9fdcf085359c0a410289b7b66b933d05fba58c8a3ae9d","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"818a90c8cf7b30e27ac960d345a9f8bb4db0e3ae4f2cc5e8e4e961b77f29968c","signature":"da51336066b98b8b26a64d60f4185a10a801c71dc02c9065f8f90127e8813ce0"},"4d2aefa43e03d5a32d161ab91ed6c34a83c31573d107f6c2f503269552760727",{"version":"0f2ac3e73064d6a8ec7f3ef8c726ecc9bd2cc34045cf18b2ec8142790d75bbe7","signature":"55216b3caf3325c8aa65aab47b84e826fca2bb492e229733d5599cc2ba4958fe"},"5acc5684fe720fcc93f09ea807cadec0853406d0e077d2fe4f7e64399190ae56",{"version":"785b9d575b49124ce01b46f5b9402157c7611e6532effa562ac6aebec0074dfc","impliedFormat":1},{"version":"70521b6ab0dcba37539e5303104f29b721bfb2940b2776da4cc818c07e1fefc1","affectsGlobalScope":true,"impliedFormat":1},{"version":"030e350db2525514580ed054f712ffb22d273e6bc7eddc1bb7eda1e0ba5d395e","affectsGlobalScope":true,"impliedFormat":1},{"version":"d153a11543fd884b596587ccd97aebbeed950b26933ee000f94009f1ab142848","affectsGlobalScope":true,"impliedFormat":1},{"version":"21d819c173c0cf7cc3ce57c3276e77fd9a8a01d35a06ad87158781515c9a438a","impliedFormat":1},{"version":"613b21ccdf3be6329d56e6caa13b258c842edf8377be7bc9f014ed14cdcfc308","affectsGlobalScope":true,"impliedFormat":1},{"version":"2d1319e6b5d0efd8c5eae07eb864a00102151e8b9afddd2d45db52e9aae002c4","affectsGlobalScope":true,"impliedFormat":1},{"version":"5929864ce17fba74232584d90cb721a89b7ad277220627cc97054ba15a98ea8f","impliedFormat":1},{"version":"24bd580b5743dc56402c440dc7f9a4f5d592ad7a419f25414d37a7bfe11e342b","impliedFormat":1},{"version":"25c8056edf4314820382a5fdb4bb7816999acdcb929c8f75e3f39473b87e85bc","impliedFormat":1},{"version":"c464d66b20788266e5353b48dc4aa6bc0dc4a707276df1e7152ab0c9ae21fad8","impliedFormat":1},{"version":"78d0d27c130d35c60b5e5566c9f1e5be77caf39804636bc1a40133919a949f21","impliedFormat":1},{"version":"c6fd2c5a395f2432786c9cb8deb870b9b0e8ff7e22c029954fabdd692bff6195","impliedFormat":1},{"version":"1d6e127068ea8e104a912e42fc0a110e2aa5a66a356a917a163e8cf9a65e4a75","impliedFormat":1},{"version":"5ded6427296cdf3b9542de4471d2aa8d3983671d4cac0f4bf9c637208d1ced43","impliedFormat":1},{"version":"6bdc71028db658243775263e93a7db2fd2abfce3ca569c3cca5aee6ed5eb186d","impliedFormat":1},{"version":"cadc8aced301244057c4e7e73fbcae534b0f5b12a37b150d80e5a45aa4bebcbd","impliedFormat":1},{"version":"385aab901643aa54e1c36f5ef3107913b10d1b5bb8cbcd933d4263b80a0d7f20","impliedFormat":1},{"version":"9670d44354bab9d9982eca21945686b5c24a3f893db73c0dae0fd74217a4c219","impliedFormat":1},{"version":"0b8a9268adaf4da35e7fa830c8981cfa22adbbe5b3f6f5ab91f6658899e657a7","impliedFormat":1},{"version":"11396ed8a44c02ab9798b7dca436009f866e8dae3c9c25e8c1fbc396880bf1bb","impliedFormat":1},{"version":"ba7bc87d01492633cb5a0e5da8a4a42a1c86270e7b3d2dea5d156828a84e4882","impliedFormat":1},{"version":"4893a895ea92c85345017a04ed427cbd6a1710453338df26881a6019432febdd","impliedFormat":1},{"version":"c21dc52e277bcfc75fac0436ccb75c204f9e1b3fa5e12729670910639f27343e","impliedFormat":1},{"version":"13f6f39e12b1518c6650bbb220c8985999020fe0f21d818e28f512b7771d00f9","impliedFormat":1},{"version":"9b5369969f6e7175740bf51223112ff209f94ba43ecd3bb09eefff9fd675624a","impliedFormat":1},{"version":"4fe9e626e7164748e8769bbf74b538e09607f07ed17c2f20af8d680ee49fc1da","impliedFormat":1},{"version":"24515859bc0b836719105bb6cc3d68255042a9f02a6022b3187948b204946bd2","impliedFormat":1},{"version":"ea0148f897b45a76544ae179784c95af1bd6721b8610af9ffa467a518a086a43","impliedFormat":1},{"version":"24c6a117721e606c9984335f71711877293a9651e44f59f3d21c1ea0856f9cc9","impliedFormat":1},{"version":"dd3273ead9fbde62a72949c97dbec2247ea08e0c6952e701a483d74ef92d6a17","impliedFormat":1},{"version":"405822be75ad3e4d162e07439bac80c6bcc6dbae1929e179cf467ec0b9ee4e2e","impliedFormat":1},{"version":"0db18c6e78ea846316c012478888f33c11ffadab9efd1cc8bcc12daded7a60b6","impliedFormat":1},{"version":"4d2b0eb911816f66abe4970898f97a2cfc902bcd743cbfa5017fad79f7ef90d8","impliedFormat":1},{"version":"bd0532fd6556073727d28da0edfd1736417a3f9f394877b6d5ef6ad88fba1d1a","impliedFormat":1},{"version":"89167d696a849fce5ca508032aabfe901c0868f833a8625d5a9c6e861ef935d2","impliedFormat":1},{"version":"e53a3c2a9f624d90f24bf4588aacd223e7bec1b9d0d479b68d2f4a9e6011147f","impliedFormat":1},{"version":"24b8685c62562f5d98615c5a0c1d05f297cf5065f15246edfe99e81ec4c0e011","impliedFormat":1},{"version":"93507c745e8f29090efb99399c3f77bec07db17acd75634249dc92f961573387","impliedFormat":1},{"version":"339dc5265ee5ed92e536a93a04c4ebbc2128f45eeec6ed29f379e0085283542c","impliedFormat":1},{"version":"4732aec92b20fb28c5fe9ad99521fb59974289ed1e45aecb282616202184064f","impliedFormat":1},{"version":"2e85db9e6fd73cfa3d7f28e0ab6b55417ea18931423bd47b409a96e4a169e8e6","impliedFormat":1},{"version":"c46e079fe54c76f95c67fb89081b3e399da2c7d109e7dca8e4b58d83e332e605","impliedFormat":1},{"version":"bf67d53d168abc1298888693338cb82854bdb2e69ef83f8a0092093c2d562107","impliedFormat":1},{"version":"81184fe8e67d78ac4e5374650f0892d547d665d77da2b2f544b5d84729c4a15d","affectsGlobalScope":true,"impliedFormat":1},{"version":"f52e8dacc97d71dcc96af29e49584353f9c54cb916d132e3e768d8b8129c928d","impliedFormat":1},{"version":"7394959e5a741b185456e1ef5d64599c36c60a323207450991e7a42e08911419","impliedFormat":1},{"version":"76103716ba397bbb61f9fa9c9090dca59f39f9047cb1352b2179c5d8e7f4e8d0","impliedFormat":1},{"version":"53eac70430b30089a3a1959d8306b0f9cfaf0de75224b68ef25243e0b5ad1ca3","affectsGlobalScope":true,"impliedFormat":1},{"version":"4314c7a11517e221f7296b46547dbc4df047115b182f544d072bdccffa57fc72","impliedFormat":1},{"version":"115971d64632ea4742b5b115fb64ed04bcaae2c3c342f13d9ba7e3f9ee39c4e7","impliedFormat":1},{"version":"c2510f124c0293ab80b1777c44d80f812b75612f297b9857406468c0f4dafe29","affectsGlobalScope":true,"impliedFormat":1},{"version":"a40826e8476694e90da94aa008283a7de50d1dafd37beada623863f1901cb7fb","impliedFormat":1},{"version":"a76037255d4e7af8b20d191a4d3ad13236fba352239d3d9d54868a98dbb222f5","affectsGlobalScope":true,"impliedFormat":1},{"version":"24642567d3729bcc545bacb65ee7c0db423400c7f1ef757cab25d05650064f98","impliedFormat":1},{"version":"e6f5a38687bebe43a4cef426b69d34373ef68be9a6b1538ec0a371e69f309354","impliedFormat":1},{"version":"a6bf63d17324010ca1fbf0389cab83f93389bb0b9a01dc8a346d092f65b3605f","impliedFormat":1},{"version":"e009777bef4b023a999b2e5b9a136ff2cde37dc3f77c744a02840f05b18be8ff","impliedFormat":1},{"version":"1e0d1f8b0adfa0b0330e028c7941b5a98c08b600efe7f14d2d2a00854fb2f393","impliedFormat":1},{"version":"ee1ee365d88c4c6c0c0a5a5701d66ebc27ccd0bcfcfaa482c6e2e7fe7b98edf7","affectsGlobalScope":true,"impliedFormat":1},{"version":"875928df2f3e9a3aed4019539a15d04ff6140a06df6cd1b2feb836d22a81eaca","affectsGlobalScope":true,"impliedFormat":1},{"version":"20b97c3368b1a63d2156deea35d03b125bb07908906eb35e0438042a3bbb3e71","impliedFormat":1},{"version":"f65eecc63138013d13fefea9092e83c3043cb52a5e351d22ea194e81021c1cd5","impliedFormat":1},{"version":"4617299caf33afef24b5e074e6d20ce8f510dd212cebd75884ef27c64457a77b","impliedFormat":1},{"version":"fa56be9b96f747e93b895d8dc2aa4fb9f0816743e6e2abb9d60705e88d4743a2","impliedFormat":1},{"version":"8257c55ff6bff6169142a35fce6811b511d857b4ae4f522cdb6ce20fd2116b2c","impliedFormat":1},{"version":"6d386bc0d7f3afa1d401afc3e00ed6b09205a354a9795196caed937494a713e6","impliedFormat":1},{"version":"5990bd8b9bc91f6e90269685ff5a154eeda52c18238f89f0101fb4d08cd80476","affectsGlobalScope":true,"impliedFormat":1},{"version":"94c4187083503a74f4544503b5a30e2bd7af0032dc739b0c9a7ce87f8bddc7b9","impliedFormat":1},{"version":"b1b6ee0d012aeebe11d776a155d8979730440082797695fc8e2a5c326285678f","impliedFormat":1},{"version":"45875bcae57270aeb3ebc73a5e3fb4c7b9d91d6b045f107c1d8513c28ece71c0","impliedFormat":1},{"version":"3eb62baae4df08c9173e6903d3ca45942ccec8c3659b0565684a75f3292cffbb","affectsGlobalScope":true,"impliedFormat":1},{"version":"6f6abdaf8764ef01a552a958f45e795b5e79153b87ddad3af5264b86d2681b72","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f16a7e4deafa527ed9995a772bb380eb7d3c2c0fd4ae178c5263ed18394db2c","impliedFormat":1},{"version":"c6b4e0a02545304935ecbf7de7a8e056a31bb50939b5b321c9d50a405b5a0bba","impliedFormat":1},{"version":"fab29e6d649aa074a6b91e3bdf2bff484934a46067f6ee97a30fcd9762ae2213","impliedFormat":1},{"version":"8145e07aad6da5f23f2fcd8c8e4c5c13fb26ee986a79d03b0829b8fce152d8b2","impliedFormat":1},{"version":"e1120271ebbc9952fdc7b2dd3e145560e52e06956345e6fdf91d70ca4886464f","impliedFormat":1},{"version":"15c5e91b5f08be34a78e3d976179bf5b7a9cc28dc0ef1ffebffeb3c7812a2dca","impliedFormat":1},{"version":"a8f06c2382a30b7cb89ad2dfc48fc3b2b490f3dafcd839dadc008e4e5d57031d","impliedFormat":1},{"version":"553870e516f8c772b89f3820576152ebc70181d7994d96917bb943e37da7f8a7","impliedFormat":1},{"version":"37ba7b45141a45ce6e80e66f2a96c8a5ab1bcef0fc2d0f56bb58df96ec67e972","impliedFormat":1},{"version":"93452d394fdd1dc551ec62f5042366f011a00d342d36d50793b3529bfc9bd633","impliedFormat":1},{"version":"745c4240220559bd340c8aeb6e3c5270a709d3565e934dc22a69c304703956bc","affectsGlobalScope":true,"impliedFormat":1},{"version":"2754d8221d77c7b382096651925eb476f1066b3348da4b73fe71ced7801edada","impliedFormat":1},{"version":"918d3b03a75858dcd5dbb275f19448b6b9a222aa8fc8471aca38c28a32ecb40f","affectsGlobalScope":true,"impliedFormat":1},{"version":"bef91efa0baea5d0e0f0f27b574a8bc100ce62a6d7e70220a0d58af6acab5e89","affectsGlobalScope":true,"impliedFormat":1},{"version":"282fd2a1268a25345b830497b4b7bf5037a5e04f6a9c44c840cb605e19fea841","impliedFormat":1},{"version":"5360a27d3ebca11b224d7d3e38e3e2c63f8290cb1fcf6c3610401898f8e68bc3","impliedFormat":1},{"version":"66ba1b2c3e3a3644a1011cd530fb444a96b1b2dfe2f5e837a002d41a1a799e60","impliedFormat":1},{"version":"7e514f5b852fdbc166b539fdd1f4e9114f29911592a5eb10a94bb3a13ccac3c4","impliedFormat":1},{"version":"7d6ff413e198d25639f9f01f16673e7df4e4bd2875a42455afd4ecc02ef156da","affectsGlobalScope":true,"impliedFormat":1},{"version":"6bd91a2a356600dee28eb0438082d0799a18a974a6537c4410a796bab749813c","affectsGlobalScope":true,"impliedFormat":1},{"version":"a5c09990a37469b0311a92ce8feeb8682e83918723aedbd445bd7a0f510eaaa3","impliedFormat":1},{"version":"ae25afbbf1ed5df63a177d67b9048bf7481067f1b8dc9c39212e59db94fc9fc6","impliedFormat":1},{"version":"ac5ed35e649cdd8143131964336ab9076937fa91802ec760b3ea63b59175c10a","impliedFormat":1},{"version":"89332fc3cc945c8df2bc0aead55230430a0dabd3277c39a43315e00330de97a6","affectsGlobalScope":true,"impliedFormat":1},{"version":"78dc0513cc4f1642906b74dda42146bcbd9df7401717d6e89ea6d72d12ecb539","impliedFormat":1},{"version":"171fd8807643c46a9d17e843959abdf10480d57d60d38d061fb44a4c8d4a8cc4","impliedFormat":1},{"version":"2b8264b2fefd7367e0f20e2c04eed5d3038831fe00f5efbc110ff0131aab899b","impliedFormat":1},{"version":"8baa5d0febc68db886c40bf341e5c90dc215a90cd64552e47e8184be6b7e3358","impliedFormat":1}],"root":[[46,84]],"options":{"declaration":true,"downlevelIteration":true,"esModuleInterop":true,"module":1,"newLine":1,"noFallthroughCasesInSwitch":true,"noUnusedLocals":true,"noUnusedParameters":false,"outDir":"./","sourceMap":true,"strict":true,"target":1},"referencedMap":[[85,1],[130,2],[131,2],[132,3],[133,4],[134,5],[135,6],[86,1],[89,7],[87,1],[88,1],[136,8],[137,9],[138,10],[139,11],[140,12],[141,13],[142,13],[144,14],[143,15],[145,16],[146,17],[147,18],[129,19],[148,20],[149,21],[150,22],[151,23],[152,24],[153,25],[154,26],[155,27],[156,28],[157,29],[158,30],[159,31],[160,32],[161,32],[162,33],[163,1],[164,1],[165,34],[167,35],[166,36],[168,37],[169,38],[170,39],[171,40],[172,41],[173,42],[174,43],[91,44],[90,1],[183,45],[175,46],[176,47],[177,48],[178,49],[179,50],[180,51],[181,52],[182,53],[184,1],[185,1],[44,1],[45,1],[8,1],[10,1],[9,1],[2,1],[11,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[3,1],[19,1],[4,1],[20,1],[24,1],[21,1],[22,1],[23,1],[25,1],[26,1],[27,1],[5,1],[28,1],[29,1],[30,1],[31,1],[6,1],[35,1],[32,1],[33,1],[34,1],[36,1],[7,1],[37,1],[42,1],[43,1],[38,1],[39,1],[40,1],[41,1],[1,1],[107,54],[117,55],[106,54],[127,56],[98,57],[97,58],[126,59],[120,60],[125,61],[100,62],[114,63],[99,64],[123,65],[95,66],[94,59],[124,67],[96,68],[101,69],[102,1],[105,69],[92,1],[128,70],[118,71],[109,72],[110,73],[112,74],[108,75],[111,76],[121,59],[103,77],[104,78],[113,79],[93,80],[116,71],[115,69],[119,1],[122,81],[48,82],[49,83],[50,1],[51,1],[53,84],[52,1],[54,1],[55,85],[56,1],[57,1],[58,1],[59,1],[61,86],[62,1],[63,1],[64,1],[65,1],[75,87],[76,88],[69,1],[66,1],[77,1],[78,1],[79,1],[82,89],[60,1],[81,90],[72,1],[70,1],[71,1],[67,1],[74,1],[80,1],[47,1],[46,1],[84,91],[83,1],[68,1],[73,1]],"version":"5.6.3"} \ No newline at end of file diff --git a/typeGuard.d.ts b/typeGuard.d.ts new file mode 100644 index 0000000..a3e86f8 --- /dev/null +++ b/typeGuard.d.ts @@ -0,0 +1,2 @@ +/** https://docs.tsafe.dev/typeguard */ +export declare function typeGuard(value: any, isMatched: boolean): value is T; diff --git a/typeGuard.js b/typeGuard.js new file mode 100644 index 0000000..f58a476 --- /dev/null +++ b/typeGuard.js @@ -0,0 +1,8 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.typeGuard = typeGuard; +/** https://docs.tsafe.dev/typeguard */ +function typeGuard(value, isMatched) { + return isMatched; +} +//# sourceMappingURL=typeGuard.js.map \ No newline at end of file diff --git a/typeGuard.js.map b/typeGuard.js.map new file mode 100644 index 0000000..272310d --- /dev/null +++ b/typeGuard.js.map @@ -0,0 +1 @@ +{"version":3,"file":"typeGuard.js","sourceRoot":"","sources":["src/typeGuard.ts"],"names":[],"mappings":";;AACA,8BAEC;AAHD,uCAAuC;AACvC,SAAgB,SAAS,CAAI,KAAU,EAAE,SAAkB;IACvD,OAAO,SAAS,CAAC;AACrB,CAAC"} \ No newline at end of file diff --git a/uncapitalize.d.ts b/uncapitalize.d.ts new file mode 100644 index 0000000..1496b91 --- /dev/null +++ b/uncapitalize.d.ts @@ -0,0 +1,2 @@ +/** @see */ +export declare function uncapitalize(str: S): Uncapitalize; diff --git a/uncapitalize.js b/uncapitalize.js new file mode 100644 index 0000000..8472bdb --- /dev/null +++ b/uncapitalize.js @@ -0,0 +1,8 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.uncapitalize = uncapitalize; +/** @see */ +function uncapitalize(str) { + return (str.charAt(0).toLowerCase() + str.slice(1)); +} +//# sourceMappingURL=uncapitalize.js.map \ No newline at end of file diff --git a/uncapitalize.js.map b/uncapitalize.js.map new file mode 100644 index 0000000..86aabcd --- /dev/null +++ b/uncapitalize.js.map @@ -0,0 +1 @@ +{"version":3,"file":"uncapitalize.js","sourceRoot":"","sources":["src/uncapitalize.ts"],"names":[],"mappings":";;AACA,oCAEC;AAHD,4DAA4D;AAC5D,SAAgB,YAAY,CAAmB,GAAM;IACjD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAQ,CAAC;AAC/D,CAAC"} \ No newline at end of file