New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@hyurl/utils

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hyurl/utils

Utility functions of HyURL collection.

  • 0.2.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
218
increased by8.46%
Maintainers
1
Weekly downloads
 
Created
Source

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.ts
  • define.d.ts
  • diff.d.ts
  • ensureType.d.ts
  • flatObject.d.ts
  • getGlobal.d.ts
  • isBetween.d.ts
  • isEmpty.d.ts
  • isFloat.d.ts
  • isInteger.d.ts
  • isNumeric.d.ts
  • isOwnKey.d.ts
  • isOwnMethod.d.ts
  • isSubClassOf.d.ts
  • isVoid.d.ts
  • keysOf.d.ts
  • omit.d.ts
  • omitVoid.d.ts
  • patch.d.ts
  • pick.d.ts
  • rand.d.ts
  • randStr.d.ts
  • sleep.d.ts
  • sort.d.ts
  • split.d.ts
  • timestamp.d.ts
  • typeAs.d.ts
  • typeOf.d.ts
  • until.d.ts
  • useThrottle.d.ts
  • wrap.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, either loads it as a ESModule/CommonJS Module as in Node.js, or loads the bundle file ./bundle/index.js instead.

<script src="./node_modules/@hyurl/utils/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, just add this repository as a submodule to your project, and then import it locally,

git submodule add https://github.com/hyurl/utils vendors/hyurl/utils

(It is recommended that you should store all your third party packages in a common directory, for example, vendors as used here.)

import * as utils from "./vendors/hyurl/utils/mod.ts";

However, there is a trick under the hood that allows a Node.js module working in Deno, and it requires read permission of the disk for loading the Node.js module.

For example, a file named test-deno.ts:

import { sleep, timestamp } from "./vendors/hyurl/utils/mod.ts";

await sleep(1000);

console.log(timestamp());

You will need to use this command to run the program:

deno run --unstable --allow-read --allow-env test-deno.ts

Unit Test

In Node.js

npm test

In Deno

npm run test-deno
# or
deno test --unstable --allow-read --allow-env test/deno/example.ts
Test as Submodule
deno test --unstable --allow-read --allow-env vendors/hyurl/utils/test/deno/example.ts

Keywords

FAQs

Package last updated on 09 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc