Compare commits
No commits in common. "source" and "main" have entirely different histories.
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,4 +11,3 @@
|
|||||||
|
|
||||||
#!.yarn/cache
|
#!.yarn/cache
|
||||||
.pnp.*
|
.pnp.*
|
||||||
node_modules
|
|
@ -1,6 +0,0 @@
|
|||||||
/node_modules
|
|
||||||
package*.json
|
|
||||||
.gitignore
|
|
||||||
*.local
|
|
||||||
*_local
|
|
||||||
__test__
|
|
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"useTabs": true,
|
|
||||||
"tabWidth": 2,
|
|
||||||
"singleQuote": true,
|
|
||||||
"trailingComma": "none",
|
|
||||||
"printWidth": 100
|
|
||||||
}
|
|
36
dist/index.cjs
vendored
Normal file
36
dist/index.cjs
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||||
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||||
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||||
|
var __export = (target, all) => {
|
||||||
|
for (var name in all)
|
||||||
|
__defProp(target, name, { get: all[name], enumerable: true });
|
||||||
|
};
|
||||||
|
var __copyProps = (to, from, except, desc) => {
|
||||||
|
if (from && typeof from === "object" || typeof from === "function") {
|
||||||
|
for (let key of __getOwnPropNames(from))
|
||||||
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||||
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||||
|
}
|
||||||
|
return to;
|
||||||
|
};
|
||||||
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||||
|
|
||||||
|
// libs/index.ts
|
||||||
|
var index_exports = {};
|
||||||
|
__export(index_exports, {
|
||||||
|
formatMoney: () => formatMoney,
|
||||||
|
helloWorld: () => helloWorld
|
||||||
|
});
|
||||||
|
module.exports = __toCommonJS(index_exports);
|
||||||
|
function helloWorld() {
|
||||||
|
console.log("Hello World!");
|
||||||
|
}
|
||||||
|
function formatMoney(amount) {
|
||||||
|
return new Intl.NumberFormat("en-US", { style: "decimal", minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(amount);
|
||||||
|
}
|
||||||
|
// Annotate the CommonJS export names for ESM import in node:
|
||||||
|
0 && (module.exports = {
|
||||||
|
formatMoney,
|
||||||
|
helloWorld
|
||||||
|
});
|
10
libs/utils/index.ts → dist/index.d.cts
vendored
10
libs/utils/index.ts → dist/index.d.cts
vendored
@ -1,6 +1,4 @@
|
|||||||
export function helloWorld() {
|
declare function helloWorld(): void;
|
||||||
console.log("Hello World!");
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* 将数字格式化为美式金额表示法
|
* 将数字格式化为美式金额表示法
|
||||||
* 将金额格式化为两位小数,需要处理千分位格式
|
* 将金额格式化为两位小数,需要处理千分位格式
|
||||||
@ -10,6 +8,6 @@ export function helloWorld() {
|
|||||||
* formatMoney(1234.5) // 返回 "1,234.50"
|
* formatMoney(1234.5) // 返回 "1,234.50"
|
||||||
* formatMoney(1000000) // 返回 "1,000,000.00"
|
* formatMoney(1000000) // 返回 "1,000,000.00"
|
||||||
*/
|
*/
|
||||||
export function formatMoney(amount: number) {
|
declare function formatMoney(amount: number): string;
|
||||||
return new Intl.NumberFormat('en-US', { style: 'decimal', minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(amount);
|
|
||||||
}
|
export { formatMoney, helloWorld };
|
@ -1 +1,15 @@
|
|||||||
export {AppRoutes} from './routes'
|
export function helloWorld() {
|
||||||
|
console.log("Hello World!");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 将数字格式化为美式金额表示法
|
||||||
|
* 将金额格式化为两位小数,需要处理千分位格式
|
||||||
|
* @param amount - 需要格式化的数字金额
|
||||||
|
* @returns 返回格式化后的金额字符串,保留2位小数
|
||||||
|
* @example
|
||||||
|
* formatMoney(1234.5) // 返回 "1,234.50"
|
||||||
|
* formatMoney(1000000) // 返回 "1,000,000.00"
|
||||||
|
*/
|
||||||
|
export function formatMoney(amount: number) {
|
||||||
|
return new Intl.NumberFormat('en-US', { style: 'decimal', minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(amount);
|
||||||
|
}
|
@ -1,6 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
export default class About extends React.Component {
|
|
||||||
render() {
|
|
||||||
return <h1>About</h1>
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
export default function Home() {
|
|
||||||
return (<h1>Home</h1>)
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
import { Route, Routes, BrowserRouter } from "react-router-dom";
|
|
||||||
|
|
||||||
import Home from '../pages/home';
|
|
||||||
import About from '../pages/about';
|
|
||||||
|
|
||||||
export const AppRoutes = () => (<Routes>
|
|
||||||
<Route path="/" element={<Home />} />
|
|
||||||
<Route path="ablout" element={<About />} />
|
|
||||||
</Routes>)
|
|
||||||
|
|
||||||
const AppBrowserRouterRouter = () => (
|
|
||||||
<BrowserRouter>
|
|
||||||
<AppRoutes />
|
|
||||||
</BrowserRouter>
|
|
||||||
);
|
|
||||||
|
|
||||||
export default AppBrowserRouterRouter;
|
|
2011
package-lock.json
generated
2011
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
15
package.json
15
package.json
@ -1,13 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "packages",
|
"name": "packages",
|
||||||
"version": "0.0.5",
|
"version": "0.0.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "callmeyan <me@xiaoyan.me>",
|
"author": "callmeyan <me@xiaoyan.me>",
|
||||||
"main": "libs/index.ts",
|
"main": "dist/index.cjs",
|
||||||
|
"types": "dist/index.d.cts",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git@e.coding.net:ctrl-01/default/npm-package-demo.git"
|
"url": "git://git.wm-app.xyz/packages/npm-package-demo.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"packages",
|
"packages",
|
||||||
@ -21,15 +22,9 @@
|
|||||||
"clean": "git clean -xdf dist",
|
"clean": "git clean -xdf dist",
|
||||||
"test": "bun test"
|
"test": "bun test"
|
||||||
},
|
},
|
||||||
|
"packageManager": "yarn@4.5.2",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/react": "^19.1.2",
|
|
||||||
"tsup": "^8.4.0",
|
"tsup": "^8.4.0",
|
||||||
"typescript": "^5.8.3"
|
"typescript": "^5.8.3"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"react": "^19.1.0",
|
|
||||||
"react-dom": "^19.1.0",
|
|
||||||
"react-router-dom": "^7.5.1",
|
|
||||||
"zustand": "^5.0.3"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// index.test.ts
|
// index.test.ts
|
||||||
import { formatMoney } from '../libs/utils/index';
|
import { formatMoney } from '../libs/index';
|
||||||
|
|
||||||
describe('FormatMoneyTest', () => {
|
describe('FormatMoneyTest', () => {
|
||||||
test('should format positive integer correctly', () => {
|
test('should format positive integer correctly', () => {
|
@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "ES2020",
|
|
||||||
"useDefineForClassFields": true,
|
|
||||||
"module": "ESNext",
|
|
||||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
||||||
"skipLibCheck": true,
|
|
||||||
|
|
||||||
/* Bundler mode */
|
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"allowImportingTsExtensions": true,
|
|
||||||
"isolatedModules": true,
|
|
||||||
"moduleDetection": "force",
|
|
||||||
"noEmit": true,
|
|
||||||
"jsx": "react-jsx",
|
|
||||||
"jsxImportSource": "react",
|
|
||||||
|
|
||||||
/* Linting */
|
|
||||||
"strict": true,
|
|
||||||
"noUnusedLocals": true,
|
|
||||||
"noUnusedParameters": true,
|
|
||||||
"noFallthroughCasesInSwitch": true,
|
|
||||||
"noUncheckedSideEffectImports": true
|
|
||||||
},
|
|
||||||
"include": ["libs", "tests"]
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user