Giter VIP home page Giter VIP logo

utils's Introduction

@jairwinl/utils

在线文档

说明

阅读对象:库使用者

安装和使用

// 安装
pnpm add @jairwinl/utils

引入

// 1. 单个方法引入方式(✅ 推荐)
import { isArray } from '@jairwinl/utils/esm/isArray';
console.log(isArray(array));

// 2. 批量引入多个方法(❌ 不推荐,所有函数会构建到产物中)
import { isArray } from '@jairwinl/utils/esm';
console.log(isArray(array));

// 3. 引入某个子包(❌ 不推荐,包大小太大)
import * as isArray from '@jairwinl/utils/esm';
console.log(isArray(array));

// 4. 引入整个库(❌ 不推荐,包大小太大)
import * as @jairwinl/utils from '@jairwinl/utils/esm';
console.log(isArray(array));

代码提示

vscode 代码提示:安装steoates.autoimport插件,并在工程根目录创建 index.d.ts, 然后添加如下内容 index.d.ts

/* 引入对应的{esm/umd/cjs}/index.d.ts */
/// <reference path="@jairwinl/utils/esm/index.d.ts" />

维护

阅读对象:库函维护者

build

pnpm build

构建 js 库,构建成功后将根据不同的模块化方式分别输出到 esm/umd/cjs 目录,并将 JSDOC 文档输出到 doc/(doc/用于部署为在线文档)

publish

  1. 切换到 main 分支
  2. 执行发布命令
npm run pub:major / pub:minor / pub:patch
  • pub:major:不兼容,或很大的变更
  • pub:minor:小版本迭代,比如新增 utils,必须兼容
  • pub:patch:bugfix、文档修改

单元测试

命令:

pnpm build && pnpm test

# 如果只是修改单测,只需
pnpm test

开发规范

目录结构

|____README.md
|____package.json
|____src                源码
| |____index.ts         入口
|____test/            	单元测试
|____esm/             	[构建产物]es module产物,适用于浏览器以及小程序
|____umd/             	[构建产物]umd产物,通用模块定义,适用于amd, script tag等场景
|____cjs/             	[构建产物]common js产物,适用于 Node 或 Browserify/webpack
|____doc/             	[构建生成]jsdoc文档,主要作用文档站点部署
|____jsdoc.json         jsdoc配置
|____rollup.config.js   打包配置
|___ __docdash          docdash相关文档配置文件
|____jsdoc.json 				jsdoc配置

refs

Typescript Definitions

采用@types方式独立输出 tsd 需要向DefinitelyTyped提 PR,维护不方便;js 和 types 一致性难保障参考。最终选择直接将 tsd 输出到打包产物目录中。

utils's People

Contributors

jairwin-l avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.