# formatting

> format value letter

Latest version **1.0.6** (published 2017-04-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install formatting
pnpm add formatting
yarn add formatting
bun add formatting
```

## 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.0.6 |
| Published | 2017-04-26 |
| First published | 2017-04-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ge6285790 |
| Maintainers | kylecheng |
| Keywords | format, value, javascript, es6, object, array, file, url, value, deep merge, leading |

## Links

- npm: https://www.npmjs.com/package/formatting
- Repository: https://github.com/ge6285790/formatting
- Homepage: https://github.com/ge6285790/formatting#readme
- Issues: https://github.com/ge6285790/formatting/issues
- npm.io page: https://npm.io/package/formatting

## Dependencies (1)

- [deep-equal](https://npm.io/package/deep-equal.md) ^1.0.1

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.0.6 (latest) — 2017-04-26
- 1.0.5 — 2017-04-26
- 1.0.4 — 2017-04-24
- 1.0.0 — 2017-04-24

## README

# Formatting

Process data like value, file, url, array and object.
Demo page: https://goo.gl/djJJ17

## Installation

1. node
```
npm install formatting --save
```

2. browser
```
find node_modules/formatting/bin/browser.js
and use <script src=""></script> to require it
```

## Usage

1. node
```js
import Formatting from 'formatting';

const valueFormat = new Formatting('value');
valueFormat.leading(1, 3, 0);
```

2. browser
```js
<script>
const valueFormat = new Formatting('value');
valueFormat.leading(1, 3, 0);
</script>
```

## API

Create a Constructor like `const format = new Formatting(type)`,and type is the mode which your data is. If you want to use all methods, type can be empty.

const format = new Formatting()

Object APIs                                | explan                                                              | return type
------------------------------------------ | ------------------------------------------------------------------- | -------------------
format.deepMerge(obj1, obj2)               | Combine two nested object                                           | object
format.deepEuqal(obj1, obj2)               | Compared two nested object(use deep-equal module)                   | boolean

Array APIs                                 | explan                                                              | return type
------------------------------------------ | ------------------------------------------------------------------- | ------------------
format.arrayMerge(array1, array2)          | Merge two nested array with non duplicate value. (array2 to array1) | array
format.arraySameValue(array1, array2) | Compare two nested array, and get duplicate value                   | array
format.arrayRemoveValue(array1, array2)    | Remove children value that array2 has from array1                   | array
format.arrayNonrepeatValue(array1, array2) | Compare two nested array, and get non duplicate value               | array

Value APIs                                 | explan                                                              | return type
------------------------------------------ | --------------------------------------------------------------------|-------------------
format.leading(value, length, letter)      | value: the data you want to format. length the result string length. letter: fill leading character | string
format.tailing(value, length, letter)      | value: the data you want to format. length the result string length. letter: fill tailing character | string
format.sequence(value, letter, number)     |  value: the data you want to format. letter: the character want to insert. number: loop number. | string
format.insert(value, letter, start)        | value: the data you want to format. letter: the character want to insert. start: insert index. | string
format.replace(value, letter, replaceLetter) | value: the data you want to format. letter: the character want to be replaced. replaceLetter: the replace character. | string
format.replaceWithRange(value, replaceLetter, start, end) | value: the data you want to format. replaceLetter: the replace character. start: replace start index. end: replace end index. | string

File APIs                     | explan        | return type
------------------------------ | -------------|------------
format.file(selector) | Get input file info, selector is className / id / etc selector | array
format.size(value) | Compute file size, minimal unit is Bytes | string
format.duration(Second) | Convert Time to HH:MM:SS | string
format.videoInfo(selector) | Get input file info with formatted size, type and duration. Selector is className / id / etc selector. The return value is promise, so if want to see the result, it would look like format.videoInfo(selector).then(data) => { console.log(data) }  | promise
format.imageInfo(selector) | Get input file info with formatted size and type. Selector is className / id / etc selector. The return value is promise, so if want to see the result, it would look like format.imageInfo(selector).then(data) => { console.log(data) }  | promise

Url APIs                     | explan        | return type
------------------------------ | -------------|------------
format.getHash(url) | Get url hash value, if url variable is empty, it will get location.href. | object
format.getParamByName(url, name) | Get url param value with indicate name. If url variable is empty, it will get location.href. | string
format.getParams(url) | Get all url params value. If url variable is empty, it will get location.href. | object

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