polish-pluralize 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +46 -0
- package/dist/index.mjs +21 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# polish-pluralize 馃嚨馃嚤
|
|
2
|
+
|
|
3
|
+
Ma艂a i szybka biblioteka do poprawnej odmiany s艂贸w z liczebnikami w j臋zyku polskim (np. 1 plik, 2 pliki, 5 plik贸w).
|
|
4
|
+
|
|
5
|
+
## Instalacja
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install polish-pluralize
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## U偶ycie
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
import { pluralize } from 'polish-pluralize';
|
|
15
|
+
|
|
16
|
+
const count = 5;
|
|
17
|
+
const text = pluralize(count, ['plik', 'pliki', 'plik贸w']);
|
|
18
|
+
|
|
19
|
+
console.log(`Pobrano ${count} ${text}`);
|
|
20
|
+
// Wynik: Pobrano 5 plik贸w
|
|
21
|
+
```
|
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
pluralize: () => pluralize
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
function pluralize(count, forms) {
|
|
27
|
+
const remainder = count % 10;
|
|
28
|
+
const remainder100 = count % 100;
|
|
29
|
+
if (remainder100 > 10 && remainder100 < 20) {
|
|
30
|
+
return forms[2];
|
|
31
|
+
}
|
|
32
|
+
switch (remainder) {
|
|
33
|
+
case 1:
|
|
34
|
+
return forms[0];
|
|
35
|
+
case 2:
|
|
36
|
+
case 3:
|
|
37
|
+
case 4:
|
|
38
|
+
return forms[1];
|
|
39
|
+
default:
|
|
40
|
+
return forms[2];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
pluralize
|
|
46
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
function pluralize(count, forms) {
|
|
3
|
+
const remainder = count % 10;
|
|
4
|
+
const remainder100 = count % 100;
|
|
5
|
+
if (remainder100 > 10 && remainder100 < 20) {
|
|
6
|
+
return forms[2];
|
|
7
|
+
}
|
|
8
|
+
switch (remainder) {
|
|
9
|
+
case 1:
|
|
10
|
+
return forms[0];
|
|
11
|
+
case 2:
|
|
12
|
+
case 3:
|
|
13
|
+
case 4:
|
|
14
|
+
return forms[1];
|
|
15
|
+
default:
|
|
16
|
+
return forms[2];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
pluralize
|
|
21
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "polish-pluralize",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Ma艂a biblioteka do odmiany s艂贸w w j臋zyku polskim dla liczebnik贸w.",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "vitest",
|
|
13
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"polish",
|
|
17
|
+
"pluralize",
|
|
18
|
+
"pluralization",
|
|
19
|
+
"polski",
|
|
20
|
+
"gramatyka",
|
|
21
|
+
"liczebniki",
|
|
22
|
+
"i18n"
|
|
23
|
+
],
|
|
24
|
+
"author": "lapkaq",
|
|
25
|
+
"license": "ISC",
|
|
26
|
+
"type": "commonjs",
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"tsup": "^8.5.1",
|
|
29
|
+
"typescript": "^6.0.3",
|
|
30
|
+
"vitest": "^4.1.5"
|
|
31
|
+
}
|
|
32
|
+
}
|