# upwoardjs

> 工具库 Upwoard

Latest version **0.1.0** (published 2018-05-16) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2018-05-16 |
| First published | 2018-05-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | yc |
| Maintainers | jcxq |
| Keywords | tool, util, js, library |

## Links

- npm: https://www.npmjs.com/package/upwoardjs
- Repository: https://github.com/jcxq/upward
- Homepage: https://github.com/jcxq/upward#readme
- Issues: https://github.com/jcxq/upward/issues
- npm.io page: https://npm.io/package/upwoardjs

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.1.0 (latest) — 2018-05-16

## README

# upwardjs
一个封装函数包（自己写的封装一些实用函数的包）
- npm-url：[github](http://git.imweb.io/jcxq/adam.git)

# 安装
- 你可以用npm来安装：

- $ npm install upwardjs

# 用法
- import upward from 'upwardjs'

#功能
###  查询（名称，查询字符串）
- 函数for获取指定查询字符串中指定名称的值
- upward.query('name', '?name=js') //return 'js'

###  序列化（数据）
- 将对象转换为url字符串的函数
- upward.serialize({hello: 'js'}) //return '?hello=js'

###  $（选择）
- 模拟jQuery的函数
- upward.$(selector) //return {DOM|undefined}

###  removeNode（节点）
- 删除DOM节点的函数
- upward.removeNode(node) //return {DOM}

###  insertAfter（节点）
- 用于在目标节点之后插入节点节点的函数
- upward.insertAfter(node, target) //return true or false

###  addClass（node，className）
- 添加类名的函数
- upward.addClass(node, className) //return true or false

###  removeClass（node，className）
- 删除类名称的函数
- upward.removeClass(node, className) //return true or false

###  getAbsoluteUrl（URL）
- 获取绝对网址的功能
- upward.getAbsoluteUrl('/hhh') //return 'https://github.com/hhh'

###  去抖（回调，时间）
- 避免摇晃的功能
例：
 test('test true', () => {
    const debounce = upward.debounce
    jest.useFakeTimers() // 声明语句，启用jest伪装计时器函数，因为使用了advanceTimersByTime()
    const callback = jest.fn() // 声明语句，使用jest伪装函数
    const createDebounce = debounce(callback, 300)
    expect(callback).not.toBeCalled() // callback还未被调用
    for (let i = 0; i < 11; i++) { // 循环执行createDebounce 11次，每次都在经过299ms时setTimeout被刷新
      createDebounce()
      jest.advanceTimersByTime(299) // 过了299ms
    }
    expect(callback).not.toBeCalled() // callback还未被调用
    jest.advanceTimersByTime(1) // 再过1ms
    expect(callback).toBeCalled() // callback被调用
    expect(callback).toHaveBeenCalledTimes(1) // callback只被调用1次
  })

###  removeItemByIndex（index，arr）
- 按索引删除项目的功能
- upward.removeItemByIndex(1, [1, 2, 3]) //return [1, 3]

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