🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@john-yuan/utils

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@john-yuan/utils

Basic utils.

latest
Source
npmnpm
Version
1.1.2
Version published
Maintainers
1
Created
Source

Basic Utils for JavaScript

Build Status

The basic utils for javascript. This library will keep the utils as small as possible. You can import the module you want to use on demand. Here is an example:

var isArray = require('@john-yuan/utils/isArray');

if (!isArray(it)) {
    throw new TypeError('it is not an array');
}

Install

npm i @john-yuan/utils

Modules

API

isAbsoluteURL(url)

  • url {string}
  • Returns: {boolean}

Check whether the url is absolute url. Returns true if the url is abosolute, otherwise false is returned.

isArray(it)

  • it {any}
  • Returns: {boolean}

Check whether the variable is an instance of Array. Returns true if the variable is an instance of Array, otherwise false is returned.

isFunction(it)

  • it {any}
  • Returns: {boolean}

Check whether the variable is a function. Returns true if the variable is a function, otherwise false is returned.

isPlainObject(it)

  • it {any}
  • Returns: {boolean}

Check whether the variable is a plain object. Returns true if the variable is a plain object, otherwise false is returned.

merge(target, ...source)

  • target {Object}
  • source {Object}
  • Returns: {Object}

Copy any non-undefined values of source to target and overwrites the corresponding original values. This function will modify the target object. Returns the modified target object.

trim(str)

  • str {string}
  • Returns: {string}

Removes the leading and trailing white space and line terminator characters from a string. If str is null or undefined, it is treated as an empty string. If str is not a string, it will be converted to a string first. This function retruns the trimed string.

Keywords

utils

FAQs

Package last updated on 29 Apr 2019

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