# @john-yuan/utils

> Basic utils.

Latest version **1.1.2** (published 2019-04-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @john-yuan/utils
pnpm add @john-yuan/utils
yarn add @john-yuan/utils
bun add @john-yuan/utils
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2019-04-29 |
| First published | 2019-02-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | JOHN YUAN |
| Maintainers | john-yuan |
| Keywords | utils |

## Links

- npm: https://www.npmjs.com/package/@john-yuan/utils
- Repository: https://github.com/john-yuan/utils
- Homepage: https://github.com/john-yuan/utils#readme
- Issues: https://github.com/john-yuan/utils/issues
- npm.io page: https://npm.io/package/@john-yuan/utils

## Recent versions

- 1.1.2 (latest) — 2019-04-29
- 1.1.1 — 2019-04-27
- 1.1.0 — 2019-04-27
- 1.0.0 — 2019-02-06

## README

# Basic Utils for JavaScript

[![Build Status](https://travis-ci.org/john-yuan/utils.svg?branch=master)](https://travis-ci.org/john-yuan/utils)

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:

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

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

## Install

```bash
npm i @john-yuan/utils
```

## Modules

* [isAbsoluteURL(url)](#isabsoluteurlurl)
* [isArray(it)](#isarrayit)
* [isFunction(it)](#isfunctionit)
* [isPlainObject(it)](#isplainobjectit)
* [merge(target, ...source)](#mergetarget-source)
* [trim(str)](#trimstr)

## 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.

---
_Source: https://npm.io/package/@john-yuan/utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
