1.2.1 • Published 5 months ago

sculp-js v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Node.js CI sculp-js node license:MIT Downloads:? codecov

sculp-js

API文档

TS + Rollup, native implementation, without relying on any third-party libraries, outputs products of three module modes: ESM, CJS, and UMD

Features

  • Type

    • isString
    • isBoolean
    • isNumber
    • isUndefined
    • isNull
    • isPrimitive
    • isObject
    • typeIs
  • Array

    • arrayLike 判断类数组
    • arrayEachAsync 异步遍历数组,可中断,支持倒序
  • Tree

    • forEachDeep 高性能的深度优先遍历函数, 支持continue、break,可定制id、children
    • forEachMap 高性能的深度优先遍历的Map函数, 支持continue、break,可定制id、children
    • searchTreeById 在树中找到 id 为某个值的节点,并返回上游的所有父级节点
    • buildTree 根据 id 与 parentId 从对象数组中构建对应的树
    • formatTree 高性能的数组转树函数
  • Object

    • isPlainObject
    • objectHas
    • objectAssign 合并
    • objectEach
    • objectEachAsync
    • objectGet
  • Number

    • formatNumber
  • String

    • stringCamelCase
    • stringKebabCase
    • getStrWidthPx
  • Unique

    • uniqueString
    • uniqueNumber
  • Date

    • formatDate
    • dateToStart
    • dateToEnd
    • calculateDate
    • calculateDateTime
  • Download

    • downloadURL
    • downloadHref
    • downloadBlob
    • downloadData
  • File

    • chooseLocalFile
  • Dom

    • hasClass
    • addClass
    • removeClass
    • setStyle
    • getStyle
    • getComputedCssVal
  • Watermark

    • genCanvasWM
  • Clipboard

    • copyText

Install

npm i sculp-js

Usage

import { forEachDeep } from 'sculp-js';

const tree = [
  { id: 1, name: 'row1' },
  {
    id: 2,
    name: 'row2',
    children: [{ id: 21, name: 'row2-1' }]
  },
  { id: 3, name: 'row3' }
];

const arr = [];
forEachDeep(tree, ({ id, name }) => {
  arr.push(name);
});
// arr will be: ['row1', 'row2', 'row2-1', 'row3'];
1.2.0

5 months ago

1.2.1

5 months ago

1.1.0

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago

0.1.1

6 months ago

0.0.2

7 months ago

0.0.1

7 months ago