Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

browser-utily-tools

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-utily-tools

Utility tools in the browser environment

  • 1.2.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

browser-utily-tools

Utility tools in the browser environment

API

API 参考

usage

npm install browser-utily-tools --save

DEMO-01 适配一个集合对数据

import { adapterDataListFormatSync } from "browser-utily-tools";

const source = [
    { number: 10, value: "黎明" },
    { number: 23, value: "liling" },
];
const rules = { number: "age", value: "name" };

const result = adapterDataListFormatSync(source, rules);
// [{ age: 10, name: "黎明" }, { age: 23, name: "liling" }];

DEMO-02 适配一组数据

import { adapterDataFormatSync } from "browser-utily-tools";

const obj = { a: "a", b: "b" };
const rules = { a: "c" };

adapterDataFormatSync(obj);
// { c: "a" , b: "b" }

DEMO-03 List 转为 Tree

import { listToTree } from "browser-utily-tools";

const entries = [
    {
        id: "12",
        parentId: "0",
        text: "Man",
        level: "1",
        children: null,
    },
    {
        id: "6",
        parentId: "12",
        text: "Boy",
        level: "2",
        children: null,
    },
    {
        id: "7",
        parentId: "12",
        text: "Other",
        level: "2",
        children: null,
    },
    {
        id: "9",
        parentId: "0",
        text: "Woman",
        level: "1",
        children: null,
    },
    {
        id: "11",
        parentId: "9",
        text: "Girl",
        level: "2",
        children: null,
    },
];

listToTree(entries);

DEMO-04 一些基本类型方法

import { types } from "browser-utily-tools";

types.isArray([]); // true
types.isNAN(NAN); // true
types.isEqual({ a: 10 }, { a: 10 }); // false
types.isNull(null); // true
types.isRegExp(/\[|]/g); // true
// ...

types.hasType(null); // Null
types.hasType({}); // Object
// ....

Keywords

FAQs

Package last updated on 06 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc