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.
Since 0.1.50, this package now supports Node.js, Web and Deno.
count.d.tsdefine.d.tsdiff.d.tsensureType.d.tsflatObject.d.tsgetGlobal.d.tsisBetween.d.tsisEmpty.d.tsisFloat.d.tsisInteger.d.tsisNumeric.d.tsisOwnKey.d.tsisOwnMethod.d.tsisSubClassOf.d.tsisVoid.d.tskeysOf.d.tsomit.d.tsomitVoid.d.tspatch.d.tspick.d.tsrand.d.tsrandStr.d.tssleep.d.tssort.d.tssplit.d.tstimestamp.d.tstypeAs.d.tstypeOf.d.tsuntil.d.tsuseThrottle.d.tswrap.d.ts
Import
There are two ways to import these functions.
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.
- Load ES Module
<script type="module">
import utils from "https://github.com/hyurl/utils/raw/master/esm/index.js";
// Note the difference with the TypeScript/CommonJS version.
</script>Note: this module can also be used Node.js as well.
Load Bundle
<script src="https://github.com/hyurl/utils/raw/master/bundle/index.js"></script>
<script>
const { count } = window["@hyurl/utils"];
console.log(count([1,2,3]));
<script>Deno Support
Yes, this package can be used directly in Deno, to use it, there are two ways to import:
- Directly from GitHub (recommended):
import * as utils from "https://github.com/hyurl/utils/raw/master/mod.ts";- Via Deno hosting service:
import * as utils from "https://deno.land/x/hyurl_utils/mod.ts";Unit Test
In Node.js
npm testIn Deno
npm run test-deno
# or
deno test test/deno/example.ts