Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@ttw_xing/com_utils

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ttw_xing/com_utils

工具函数组件库

latest
Source
npmnpm
Version
0.1.6
Version published
Maintainers
1
Created
Source

SUI-UTILS

业务工具函数库, 提供常用的函数集合

安装

snpm install @ttw_xing/com_utils

# OR 设置 registry=http://snpm-registry.sto.cn
# use npm
npm i @ttw_xing/com_utils
# use yarn
yarn add @ttw_xing/com_utils

引入

全量引入

import * as S from '@ttw_xing/com_utils';

const { example, formatNumber } = S;

或者

import { example, formatNumber } from '@ttw_xing/com_utils';

即使利用解构赋值也会引入整个库,未用到的函数会占用额外的体积

按需引入

1. 手动挑选函数

import example from '@ttw_xing/com_utils/lib/example';
import formatNumber from '@ttw_xing/com_utils/lib/formatNumber';

手动引入比较麻烦,建议使用下面的方法

2. 推荐使用 babel-plugin-import 切分代码

import { example, formatNumber } from '@ttw_xing/com_utils';

经过打包前 babel 的编译,上面的代码会变为

import example from '@ttw_xing/com_utils/lib/example';
import formatNumber from '@ttw_xing/com_utils/lib/formatNumber';

对应 babel 配置:

{
  "plugins": [
    ["import",
      {
        "libraryName": "@ttw_xing/com_utils"
      }
    ]
  ],
}

未来计划

  • prettier
  • typescript & d.ts 类型支持
  • 添加测试用例
  • 文档主题色替换

Keywords

util

FAQs

Package last updated on 10 Nov 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