Skip to content

Commit effdc0d

Browse files
Merge pull request #1 from avoidwork/master
Merge latest
2 parents 901be1f + cb26761 commit effdc0d

File tree

6 files changed

+98
-2
lines changed

6 files changed

+98
-2
lines changed

.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"amd": true
77
},
88
"parserOptions": {
9-
"ecmaVersion": 2020,
9+
"ecmaVersion": "latest",
1010
"sourceType": "module"
1111
},
1212
"globals": {

.github/workflows/ci.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: ci
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- master
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [18.x, 20.x]
16+
17+
steps:
18+
- name: Checkout Repository
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 1
22+
23+
- name: Setup Node ${{ matrix.node-version }}
24+
uses: actions/setup-node@v3
25+
with:
26+
always-auth: false
27+
node-version: ${{ matrix.node-version }}
28+
29+
- name: Install dependencies
30+
run: npm install
31+
32+
- name: Build
33+
run: npm run rollup
34+
35+
- name: Run Tests
36+
run: npm run test
37+
38+
automerge:
39+
needs: build
40+
runs-on: ubuntu-latest
41+
permissions:
42+
pull-requests: write
43+
contents: write
44+
steps:
45+
- uses: fastify/github-action-merge-dependabot@v3
46+
with:
47+
github-token: ${{ secrets.GITHUB_TOKEN }}

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npm test

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,27 @@ _*(string)*_ Standard unit of measure, can be `iec` or `jedec`, default is `iec`
6161
### symbols
6262
_*(object)*_ Dictionary of IEC/JEDEC symbols to replace for localization, defaults to english if no match is found
6363

64+
## Examples
65+
66+
```javascript
67+
filesize(500); // "500 B"
68+
filesize(500, {bits: true}); // "4 kbit"
69+
filesize(265318, {base: 2}); // "259.1 KiB"
70+
filesize(265318); // "265.32 kB"
71+
filesize(265318, {round: 0}); // "265 kB"
72+
filesize(265318, {output: "array"}); // [265.32, "kB"]
73+
filesize(265318, {output: "object"}); // {value: 265.32, symbol: "kB", exponent: 1, unit: "kB"}
74+
filesize(1, {symbols: {B: "Б"}}); // "1 Б"
75+
filesize(1024); // "1.02 kB"
76+
filesize(1024, {exponent: 0}); // "1024 B"
77+
filesize(1024, {output: "exponent"}); // 1
78+
filesize(265318, {standard: "jedec"}); // "259.1 KB"
79+
filesize(265318, {base: 2, fullform: true}); // "259.1 kibibytes"
80+
filesize(12, {fullform: true, fullforms: ["байтов"]}); // "12 байтов"
81+
filesize(265318, {separator: ","}); // "265,32 kB"
82+
filesize(265318, {locale: "de"}); // "265,32 kB"
83+
```
84+
6485

6586
## Partial Application
6687
`partial()` takes the second parameter of `filesize()` and returns a new function with the configuration applied

package-lock.json

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@
3333
"rollup": "rollup --config",
3434
"test": "npm run lint && npm run mocha",
3535
"test-webpack": "mkdir -p test/webpack && rm -rf test/webpack/* && git clone [email protected]:rabelais88/typescript-webpack.git test/webpack && echo \"import { filesize } from 'filesize';console.log(filesize(1234));\" >> test/webpack/src/index.ts && cd test/webpack && npm install && mkdir -p node_modules/filesize/dist && cp ../../package.json node_modules/filesize/ && cp ../../dist/* node_modules/filesize/dist/ && npm run build",
36-
"types": "npx -p typescript tsc src/*.js --declaration --allowJs --emitDeclarationOnly --outDir types"
36+
"types": "npx -p typescript tsc src/*.js --declaration --allowJs --emitDeclarationOnly --outDir types",
37+
"prepare": "husky install"
3738
},
3839
"devDependencies": {
3940
"@rollup/plugin-terser": "^0.4.0",
4041
"auto-changelog": "^2.4.0",
4142
"eslint": "^8.37.0",
43+
"husky": "^8.0.3",
4244
"mocha": "^10.2.0",
4345
"rollup": "^3.20.2",
4446
"typescript": "^5.0.2"

0 commit comments

Comments
 (0)