Utility functions of HyURL collection.
This package currently contains the following functions, more functions may be included in the future. Each function is stored in a separated file.
count.tsdefine.tsdiff.tsensureType.tsflatObject.tsgetGlobal.tsisEmpty.tskeysOf.tsomitInvalid.tspatch.tssort.tssplit.tstimestamp.tstrim.tstypeOf.ts
Deprecated
Since v0.3.0, the following functions have been merged to @ayonli/jsext. The two packages serve different purposes, while @ayonli/jsext provides basic and semantic APIs for the JavaScript language, @hyurl/utils provides higher level functions that deal with objects.
This package still keeps a link to these functions, but they have been marked deprecated and will be removed in v0.4.0.
isFloatuseisFloatfrom@ayonli/jsext/numberinstead.isIntegeruseNumber.isIntegerinstead.isNumericuseisNumericfrom@ayonli/jsext/numberinstead.isBetweenuseisBetweenfrom@ayonli/jsext/numberinstead.isOwnKeyusehasOwnfrom@ayonli/jsext/objectinstead.isOwnMethodusehasOwnMethodfrom@ayonli/jsext/objectinstead.isSubClassOfusejsext.isSubclassOffrom@ayonli/jsextinstead.isVoiduse!isValidfrom@ayonli/jsext/objectinstead.omituseomitfrom@ayonli/jsext/objectinstead.pickusepickfrom@ayonli/jsext/objectinstead.omitVoiduseomitInvalidinstead.randuserandomfrom@ayonli/jsext/numberinstead.randStruserandomfrom@ayonli/jsext/stringinstead.sleepusesleepfrom@ayonli/jsext/promiseinstead.typeAsuseasfrom@ayonli/jsext/objectinstead.untiluseuntilfrom@ayonli/jsext/promiseinstead.useThrottleusejsext.throttlefrom@ayonli/jsextinstead.wrapusejsext.wrapfrom@ayonli/jsextinstead.
There are many ways to import these functions.
This method will load all functions into memory, even if you don't need some of them.
// Node.js
import * as utils from "@hyurl/utils";
// Deno
import * as utils from "https://lib.deno.dev/x/hyurl_utils@latest/index.ts";
// Browser
import * as utils from "https://lib.deno.dev/x/hyurl_utils@latest/esm/index.js";This method will only load needed functions, which is recommended.
// Node.js
import count from "@hyurl/utils/count";
import ensureType from "@hyurl/utils/ensureType";
// Deno
import count from "https://lib.deno.dev/x/hyurl_utils@latest/count.ts";
import ensureType from "https://lib.deno.dev/x/hyurl_utils@latest/ensureType.ts";
// Browser
import count from "https://lib.deno.dev/x/hyurl_utils@latest/esm/count.js";
import ensureType from "https://lib.deno.dev/x/hyurl_utils@latest/esm/ensureType.js";NOTE: Configure tsconfig.json to set compilerOptions.module as NodeNext or ESNext
instead of CommonJS for this to work with Node.js+TypeScript.
<script src="https://lib.deno.dev/x/hyurl_utils@latest/bundle/index.js"></script>
<script>
const utils = window["@hyurl/utils"];
<script>Other than utility functions, this package also provides some utility types for TypeScript, they are located in the following file and exposed to the global namespace.
import "@hyurl/utils/types";