Skip to content

Commit c524ac2

Browse files
Prepare the NPM package for release (#6616)
1 parent 89c1631 commit c524ac2

20 files changed

+190
-85
lines changed

examples/npm/package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/npm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"start": "node dist/main.js"
77
},
88
"dependencies": {
9-
"icu4x": "file:../../ffi/npm"
9+
"icu": "file:../../ffi/npm"
1010
},
1111
"devDependencies": {
1212
"typescript": "^4.7.4"

examples/npm/src/main.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
import { Decimal, DecimalFormatter, DecimalGroupingStrategy, Locale } from "icu4x";
1+
// This file is part of ICU4X. For terms of use, please see the file
2+
// called LICENSE at the top level of the ICU4X source tree
3+
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
24

3-
var locale = Locale.fromString("bn");
5+
import { Decimal, DecimalFormatter, DecimalGroupingStrategy, Locale } from 'icu';
6+
7+
var locale = Locale.fromString('bn');
48
var groupingStrategy = DecimalGroupingStrategy.Auto;
5-
var decimal = Decimal.fromString("123");
9+
var decimal = Decimal.fromString('123');
610

711
var formatter = DecimalFormatter.createWithGroupingStrategy(
812
locale,

ffi/npm/LICENSE

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
UNICODE LICENSE V3
2+
3+
COPYRIGHT AND PERMISSION NOTICE
4+
5+
Copyright © 2020-2024 Unicode, Inc.
6+
7+
NOTICE TO USER: Carefully read the following legal agreement. BY
8+
DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
9+
SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
10+
TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
11+
DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
12+
13+
Permission is hereby granted, free of charge, to any person obtaining a
14+
copy of data files and any associated documentation (the "Data Files") or
15+
software and any associated documentation (the "Software") to deal in the
16+
Data Files or Software without restriction, including without limitation
17+
the rights to use, copy, modify, merge, publish, distribute, and/or sell
18+
copies of the Data Files or Software, and to permit persons to whom the
19+
Data Files or Software are furnished to do so, provided that either (a)
20+
this copyright and permission notice appear with all copies of the Data
21+
Files or Software, or (b) this copyright and permission notice appear in
22+
associated Documentation.
23+
24+
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
25+
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
27+
THIRD PARTY RIGHTS.
28+
29+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
30+
BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
31+
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
32+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
33+
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
34+
FILES OR SOFTWARE.
35+
36+
Except as contained in this notice, the name of a copyright holder shall
37+
not be used in advertising or otherwise to promote the sale, use or other
38+
dealings in these Data Files or Software without prior written
39+
authorization of the copyright holder.
40+
41+
SPDX-License-Identifier: Unicode-3.0
42+
43+
44+
45+
Portions of ICU4X may have been adapted from ICU4C and/or ICU4J.
46+
ICU 1.8.1 to ICU 57.1 © 1995-2016 International Business Machines Corporation and others.

ffi/npm/README.md

Lines changed: 31 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ffi/npm/bench/all.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
import "./fixed-decimal.mjs";
2-
import "./fixed-decimal-format.mjs";
1+
// This file is part of ICU4X. For terms of use, please see the file
2+
// called LICENSE at the top level of the ICU4X source tree
3+
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4+
5+
import './decimal.mjs';
6+
import './decimal-format.mjs';

ffi/npm/bench/decimal-format.mjs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// This file is part of ICU4X. For terms of use, please see the file
2+
// called LICENSE at the top level of the ICU4X source tree
3+
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4+
5+
import Benchmark from 'benchmark';
6+
7+
import { Decimal, Locale, DecimalFormatter, DecimalGroupingStrategy } from 'icu'
8+
9+
const locale = Locale.fromString('bn');
10+
11+
let suite = new Benchmark.Suite();
12+
13+
suite = suite.add('DecimalFormatter.create', () => {
14+
DecimalFormatter.createWithGroupingStrategy(locale, DecimalGroupingStrategy.Auto);
15+
});
16+
17+
const format = DecimalFormatter.createWithGroupingStrategy(locale, DecimalGroupingStrategy.Auto);
18+
const decimal = Decimal.fromBigInt(BigInt(1234));
19+
decimal.multiplyPow10(-2);
20+
21+
suite = suite.add('DecimalFormatter.format', () => {
22+
format.format(decimal);
23+
});
24+
25+
suite
26+
.on('cycle', (event) => {
27+
console.log(String(event.target));
28+
console.log('μs/it:', event.target.stats.mean * 1000 * 1000);
29+
console.log();
30+
})
31+
.run({ 'async': false });

ffi/npm/bench/decimal.mjs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// This file is part of ICU4X. For terms of use, please see the file
2+
// called LICENSE at the top level of the ICU4X source tree
3+
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4+
5+
import Benchmark from 'benchmark';
6+
7+
import { Decimal, DecimalSign } from 'icu'
8+
9+
let suite = new Benchmark.Suite();
10+
11+
suite = suite.add('Decimal.fromBigInt', () => {
12+
(Decimal.fromBigInt(BigInt(1234))).underlying > 0;
13+
});
14+
15+
const decimal = Decimal.fromBigInt(BigInt(1234));
16+
decimal.multiplyPow10(-2);
17+
18+
suite = suite.add('Decimal.toString', () => {
19+
decimal.toString();
20+
});
21+
22+
suite = suite.add('Decimal.multiplyPow10', () => {
23+
decimal.multiplyPow10(2);
24+
decimal.multiplyPow10(-2);
25+
});
26+
27+
suite = suite.add('Decimal.sign', () => {
28+
decimal.sign = DecimalSign.Negative;
29+
decimal.sign = new DecimalSign('Positive');
30+
decimal.sign = null;
31+
});
32+
33+
suite
34+
.on('cycle', (event) => {
35+
console.log(String(event.target));
36+
console.log('μs/it:', event.target.stats.mean * 1000 * 1000);
37+
console.log();
38+
})
39+
.run({ 'async': false });

ffi/npm/bench/fixed-decimal-format.mjs

Lines changed: 0 additions & 28 deletions
This file was deleted.

ffi/npm/bench/fixed-decimal.mjs

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)