Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
jmni-cn committed Nov 19, 2024
1 parent 5c3f023 commit 0a53546
Show file tree
Hide file tree
Showing 12 changed files with 658 additions and 0 deletions.
101 changes: 101 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
9 changes: 9 additions & 0 deletions lib/index.cjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

function generateUID() {
var timestamp = Date.now().toString(36); // 时间戳转为36进制
var randomPart = Math.random().toString(36).substring(2, 10); // 随机数转为36进制
return timestamp + randomPart;
}

exports.generateUID = generateUID;
1 change: 1 addition & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { generateUID } from './until';
7 changes: 7 additions & 0 deletions lib/index.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function generateUID() {
var timestamp = Date.now().toString(36); // 时间戳转为36进制
var randomPart = Math.random().toString(36).substring(2, 10); // 随机数转为36进制
return timestamp + randomPart;
}

export { generateUID };
1 change: 1 addition & 0 deletions lib/index.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/until.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare function generateUID(): string;
38 changes: 38 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "jmni",
"version": "0.1.1",
"description": "js until lib",
"main": "lib/index.cjs.js",
"module": "lib/index.esm.js",
"jsnext:main": "lib/index.esm.js",
"browser": "lib/index.umd.js",
"types": "lib/index.d.ts",
"files": [
"dist",
"lib"
],
"scripts": {
"build": "rollup -c",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jmni-cn/juntils.git"
},
"author": "jmni.cn",
"license": "ISC",
"sideEffects": false,
"bugs": {
"url": "https://github.com/jmni-cn/juntils/issues"
},
"homepage": "https://github.com/jmni-cn/juntils#readme",
"devDependencies": {
"@rollup/plugin-commonjs": "^28.0.1",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-typescript": "^12.1.1",
"rollup": "^4.27.3",
"rollup-plugin-terser": "^7.0.2",
"tslib": "^2.8.1",
"typescript": "^5.6.3"
}
}
39 changes: 39 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// import resolve from "@rollup/plugin-node-resolve";
// import typescript from "@rollup/plugin-typescript";
// import commonjs from "@rollup/plugin-commonjs";
// import { terser } from "rollup-plugin-terser";
// import pkg from "./package.json";

const resolve = require('@rollup/plugin-node-resolve');
const typescript = require('@rollup/plugin-typescript');
const commonjs = require('@rollup/plugin-commonjs');
const { terser } = require('rollup-plugin-terser')

module.exports = [
{
input: './src/index.ts',
output: [
{
dir: 'lib',
format: 'cjs',
entryFileNames: '[name].cjs.js',
sourcemap: false, // 是否输出sourcemap
},
{
dir: 'lib',
format: 'esm',
entryFileNames: '[name].esm.js',
sourcemap: false, // 是否输出sourcemap
},
{
dir: 'lib',
format: 'umd',
entryFileNames: '[name].umd.js',
name: 'FE_utils', // umd模块名称,相当于一个命名空间,会自动挂载到window下面
sourcemap: false,
plugins: [terser()],
},
],
plugins: [resolve(), commonjs(), typescript({ module: "ESNext" })],
}
];
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { generateUID } from './until';
5 changes: 5 additions & 0 deletions src/until.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function generateUID() {
const timestamp = Date.now().toString(36); // 时间戳转为36进制
const randomPart = Math.random().toString(36).substring(2, 10); // 随机数转为36进制
return timestamp + randomPart;
}
18 changes: 18 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "es5" /* 编译目标 */,
"module": "commonjs" /* 项目模块类型 */,
"lib": ["ES2018", "DOM"],
"allowJs": true /* 是否允许js代码 */,
"checkJs": true /* 检查js代码错误 */,
"declaration": true /* 自动创建声明文件(.d.ts) */,
"declarationDir": "./lib" /* 声明文件目录 */,
"sourceMap": true /* 自动生成sourcemap文件 */,
"outDir": "lib" /* 编译输出目录 */,
"rootDir": "./src" /* 项目源码根目录,用来控制编译输出的目录结构 */,
"strict": true /* 启用严格模式 */
},
"include": ["src/index.ts"],
"exclude": ["node_modules", "lib"]
}

Loading

0 comments on commit 0a53546

Please sign in to comment.