si14/stuffed-naan-js

Stuff your Na(a)N

License

MIT license 10 stars 0 forks

license: MIT/ NPM Version

Stuffed-Na(a)N: 用数据填充你的 NaNs

一张蒜蓉烤馕的照片 图片来自 Wikimedia 你是否不小心做过这样的事情?

console.log(0 / 0)
// Output: NaN

或者这样?

console.log(Math.asin(2))
// Output: NaN

你是否厌倦了 NaN 的传播?

const a = NaN
console.log((a * 2) - 5)
// Output: NaN

有了 stuffed-naan,你终于可以利用 NaN 了。 用你的数据填充 ~~NaN~~Na(a)N 吧!

import { encode, decode } from 'stuffed-naan';
const encoded = encode("Hello world");
console.log(encoded);
// Output: [NaN, NaN, NaN]
console.log(decode(encoded));
// Output: Hello world

引用孙子的话,“不能战胜敌人,就利用敌人的优势来为自己服务”。即使在数学运算中使用,Na(a)Ns 也能保留数据:

import { encode, decode } from 'stuffed-naan';
const encoded = encode("Hello world");
console.log(decode(encoded.map(x => x * 2)));
// Output: Hello world

为什么选择 stuffed-naan

紧凑 💿

stuffed-naan 非常紧凑。社区版实现了 -25% 的压缩率。这意味着,每 1024 字节的数据,你将获得 1368 字节的 float64 Na(a)Ns! 这是业界领先的 Na(a)N 压缩水平。为了获得更好的压缩效果,请考虑 Enterprise Edition

闪电般的速度 🚀

stuffed-naan 速度非常快。 借助 ECMAScript® 2026 中提供的高级字节操作功能,填充开销非常小。 将一千个小对象 Na(a)N 化只需 1-3 毫秒。

隐私优先 🚫👀

stuffed-naan 隐私优先。 它是一种首创的隐私保护编码,因为 Na(a)N 数组如果未经处理直接复制粘贴,会丢失信息。 这使得 stuffed-naan 对于保护客户的 PII 至关重要。 联系 stuffed-naan DPO 了解更多信息。

安装

npm install stuffed-naan

或者你可以在你的浏览器控制台中这样做:

const stuffedNaan = await import('https://unpkg.com/stuffed-naan');
stuffedNaan.encode("hello world");

Enterprise Edition 🏦

Enterprise Edition 包括:

联系销售人员了解定价。

Roadmap

Testimonials

对我来说,这看起来真的很奇怪。我本可以把它当作某人的业余项目而一笑置之,但是……这似乎并不是它试图成为的东西。 这些应用可能真实存在 :D 我做了一个蒜蓉烤馕:https://www.godbolt.org/z/enjv1c7Tf (作者)

说真的

JS 数字是 IEEE 754 浮点数,64 位长。 它们由一个符号位、一个指数和一个尾数组成。 这就是它在内存中的样子: 来自 Wikipedia 的 float64 的内存布局 当浮点数上的数学运算应用不正确时(例如,0/0),结果是一个特殊的值,称为 Not a Number,简称 NaN。 NaN 表示为浮点数,指数设置为全 1,并且尾数部分中至少有一个非零位。 这意味着我可以犯罪并将数据走私到尾数部分中。 IEEE 不会阻止我! 这个技巧很傻,但是管用。 自然,我忍不住夸大了烤馕双关语。 支持您当地的咖喱店! (或者,更好的是,Come Back AliveBluesky / Twitter / Web

关于

Stuff your Na(a)N

Resources

Readme

License

MIT license Activity

Stars

10 stars

Watchers

1 watching

Forks

0 forks Report repository