HyURL Utilities
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.
isFloatuseNumber.isFloatfrom@ayonli/jsext/number/augmentinstead.isIntegeruseNumber.isIntegerinstead.isNumericuseNumber.isNumericfrom@ayonli/jsext/number/augmentinstead.isBetweenuseNumber.isBetweenfrom@ayonli/jsext/number/augmentinstead.isOwnKeyuseObject.hasOwnfrom@ayonli/jsext/object/augmentinstead.isOwnMethoduseObject.hasOwnMethodfrom@ayonli/jsext/object/augmentinstead.isSubClassOfusejsext.jsSubclassOffrom@ayonli/jsextinstead.isVoiduse!Object.isValidfrom@ayonli/jsext/object/augmentinstead.omituseObject.omitfrom@ayonli/jsext/object/augmentinstead.pickuseObject.pickfrom@ayonli/jsext/object/augmentinstead.omitVoiduseomitInvalidinstead.randuseNumber.randomfrom@ayonli/jsext/number/augmentinstead.randStruseString.randomfrom@ayonli/jsext/string/augmentinstead.sleepusePromise.sleepfrom@ayonli/jsext/promise/augmentinstead.typeAsuseObject.asfrom@ayonli/jsext/object/augmentinstead.untilusePromise.untilfrom@ayonli/jsext/promise/augmentinstead.useThrottleusejsext.throttlefrom@ayonli/jsextinstead.wrapusejsext.wrapfrom@ayonli/jsextinstead.
Import
There are two ways to import these functions.
NOTE: Configure tsconfig.json to set compilerOptions.module as NodeNext or ESNext
instead of CommonJS.
All At Once
This method will load all functions into memory, even if you don’t need some of them.
import * as utils from "@hyurl/utils";
// or import specific functions
import { count, ensureType } from "@hyurl/utils";Only Needed
This method will only load needed functions, which is recommended.
import count from "@hyurl/utils/count";
import ensureType from "@hyurl/utils/ensureType";Utilities Types
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";Web Support
When using this package in the browser, there are three ways to import this package.
- Import From
node_modules
This is the same as above, but requires a module bundler such as webpack.
- Import ES Module
<script type="module">
import * as utils from "https://deno.land/x/hyurl_utils/esm/index.js";
// or individuals
import count from "https://deno.land/x/hyurl_utils/esm/count.js";
import split from "https://deno.land/x/hyurl_utils/esm/split.js";
</script>- Include Bundle
<script src="https://deno.land/x/hyurl_utils/bundle/index.js"></script>
<script>
const utils = window["@hyurl/utils"];
<script>