Skip to content

Commit

Permalink
Reduce size
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Feb 1, 2024
1 parent 7863ce5 commit 4db3464
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.id-ID.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Sebuah generator ID yang unik dalam bentuk string yang ringan, aman, serta _URL-
> "Sebuah tingkat kesempurnaan yang luar biasa,
> yang mana tidak mungkin untuk tidak dihormati."
- **Ringan.** Hanya 124 bytes (diperkecil dan brotlied). Tidak ada ketergantungan (dependencies) apapun. [Size Limit](https://github.com/ai/size-limit) mengatur ukuran dari generator ini.
- **Ringan.** Hanya 116 bytes (diperkecil dan brotlied). Tidak ada ketergantungan (dependencies) apapun. [Size Limit](https://github.com/ai/size-limit) mengatur ukuran dari generator ini.
- **Aman.** Nano ID menggunakan RNG yang terdapat pada perangkat keras. Dapat digunakan dalam lingkungan seperti klaster.
- **ID yang pendek.** Nano ID menggunakan alfabet yang lebih banyak ketimbang UUID (`A-Za-z0-9_-`), karenanya ukuran ID menjadi berkurang dari 36 menjadi 21 simbol.
- **Portabel.** Nano ID telah dimigrasi untuk [20 bahasa pemrograman lainnya](#bahasa-pemrograman-lainnya).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A tiny, secure, URL-friendly, unique string ID generator for JavaScript.
> “An amazing level of senseless perfectionism,
> which is simply impossible not to respect.”
* **Small.** 124 bytes (minified and brotlied). No dependencies.
* **Small.** 116 bytes (minified and brotlied). No dependencies.
[Size Limit] controls the size.
* **Safe.** It uses hardware random generator. Can be used in clusters.
* **Short IDs.** It uses a larger alphabet than UUID (`A-Za-z0-9_-`).
Expand Down
2 changes: 1 addition & 1 deletion README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ID можно применять в URL.
> «Поразительный уровень бессмысленного перфекционизма,
> который просто невозможно не уважать»
- **Лёгкий.** 124 байт (после минификации и Brotli). Без зависимостей.
- **Лёгкий.** 116 байт (после минификации и Brotli). Без зависимостей.
[Size Limit] следит за размером.
- **Безопасный.** Использует аппаратный генератор случайных чисел.
Можно использовать в кластерах машин.
Expand Down
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

> “一个惊人的无意义的完美主义水平,这简直让人无法不敬佩。”
* **小巧.** 124字节 (经过压缩和Brotli处理)。没有依赖。[Size Limit] 控制大小。
* **小巧.** 116字节 (经过压缩和Brotli处理)。没有依赖。[Size Limit] 控制大小。
* **安全.** 它使用硬件随机生成器。可在集群中使用。
* **紧凑.** 它使用比 UUID(`A-Za-z0-9_-`)更大的字母表。因此,ID 大小从36个符号减少到21个符号。
* **可移植.** Nano ID 已被移植到 [20种编程语言](#其他编程语言)
Expand Down
6 changes: 3 additions & 3 deletions index.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ export let customAlphabet = (alphabet, size = 21) =>

export let nanoid = (size = 21) => {
let id = ''
let rand = crypto.getRandomValues(new Uint8Array(size))
for (let i = 0; i < size; i++) {
let bytes = crypto.getRandomValues(new Uint8Array(size))
while (size--) {
// Using the bitwise AND operator to "cap" the value of
// the random byte from 255 to 63, in that way we can make sure
// that the value will be a valid index for the "chars" string.
id += urlAlphabet[rand[i] & 63]
id += urlAlphabet[bytes[size] & 63]
}
return id
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nanoid",
"version": "5.0.4",
"description": "A tiny (124 bytes), secure URL-friendly unique string ID generator",
"description": "A tiny (116 bytes), secure URL-friendly unique string ID generator",
"keywords": [
"uuid",
"random",
Expand Down Expand Up @@ -79,7 +79,7 @@
{
"name": "nanoid",
"import": "{ nanoid }",
"limit": "124 B"
"limit": "116 B"
},
{
"name": "customAlphabet",
Expand Down

0 comments on commit 4db3464

Please sign in to comment.