# slo-tool-lib

> some js tool for easyer development

Latest version **1.1.1** (published 2020-09-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install slo-tool-lib
pnpm add slo-tool-lib
yarn add slo-tool-lib
bun add slo-tool-lib
```

## 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.1 |
| Published | 2020-09-12 |
| First published | 2020-09-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Slogki |
| Maintainers | slogki |
| Keywords | slo-tool-lib, ES6, javascript |

## Links

- npm: https://www.npmjs.com/package/slo-tool-lib
- Repository: https://github.com/SlogKi/slo-tool-lib
- Homepage: https://github.com/SlogKi/slo-tool-lib#readme
- Issues: https://github.com/SlogKi/slo-tool-lib/issues
- npm.io page: https://npm.io/package/slo-tool-lib

## Recent versions

- 1.1.1 (latest) — 2020-09-12
- 1.1.0 — 2020-09-12
- 1.0.2 — 2020-09-12
- 1.0.1 — 2020-09-11
- 1.0.0 — 2020-09-11

## README

# Slo-tool-lib
Tool function lib
# Installation
Using npm:
```
  $ npm i -D slo-tool-lib
  ...
  $ import { toFixedN, GetQueryStr, CreateStrategy } from 'slo-tool-lib';
```
# Syntax
```
  /**
  * @description limit user input
  * @param { string } input from user input
  * @param { number } n decimal digits [default:2]
  * @param { number } maxLength allow max input length [default:9]
  * @return { string } num
  */
  toFixedN(input, [n, maxLength])
  ...
```
```
  /**
  * @description get window.location.search to obj
  */
  let qs = new GetQueryStr(search)
  qs.has(key)
  qs.get([key])
```
```
  /**
  * @description handle if/switch with strategy design model
  *
  let strategy = new CreateStrategy()
  strategy.add(key, fn)
  strategy.modify(key, fn)
  strategy.remove([key])
  strategy.has(key)
  strategy.get([key])
  strategy.toDo(key[, param])
```
# Example
In index.vue
```
  <input type="text" v-model="val" v-change="handleChange(val)" />
```
In index.js
```
  import { toFixedN, GetQueryStr, CreateStrategy } from 'slo-tool-lib';
  ...
  data() {
    return {
      val: '123'
    }
  },
  beforeCreated() {
    let qs = new GetQueryStr('?a=1&b=2')
    console.log(qs.has('a')) // true
    console.log(qs.get()) // { a: 1, b: 2 }
    console.log(qs.get('b')) // 2

    let pages = new CreateStrategy()
    pages
    .add('home', () => { console.log('go home') })
    .add('user', param => { console.log('param') })
    .add('x')
    pages.toDo('home') // go home
  },
  methods: {
    handleChange(val) {
      this.val = toFixedN(val);
    }
  }
```
Note:  
Involving ES6+
# Keywords
javascript tool lib ES6

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