内容简介:Disclaimer: This library is part of a bigger project and it's goal is to be as small as possible (I don't want to use the >200kb bundle ofThe name is based on nashorn which is the German word for rhino.
Ultra tiny object serializer
Disclaimer: This library is part of a bigger project and it's goal is to be as small as possible (I don't want to use the >200kb bundle of bson ). This lib is only around 4kb, uncompressed. It's only supposed to work within JS itself and not all data-types are implemented so far (see types-table at the bottom).
The name is based on nashorn which is the German word for rhino.
Installation
Install via npm
or yarn
:
$ npm install nason # or $ yarn add nason
Include directly via jsdelivr :
<script src="https://cdn.jsdelivr.net/npm/nason/lib/nason.min.js"></script>
Using JavaScript Modules :
import {...} from 'https://cdn.jsdelivr.net/npm/nason/lib/nason.min.mjs'
Usage
import {deserialize, serialize} from 'nason'; // Serialize something, you'll get a Uint8Array in return. // You can pass any kind of supported data-type you want to serialize. const enc = serialize({ 'hello': 'world', 'number': 13235, 'array': [1, 2, 3, 'abc'] }); // ... save enc to file or do whatever you want with it // Deserialize a previously serialized value const dec = deserialize(enc); console.log(dec); // Will be the same as initially passed into serialize
nason
exports the following properties and functions:
import { deserialize, // Takes a single Uint8Array and decodes it serialize, // Takes any supported value and converts it to a Uint8Array version // Current version of this package } from 'nason';
There's even more if you want to develop plugins !
Data-types
Data-type | Status |
---|---|
object |
|
array |
|
string |
|
number |
|
boolean |
|
null |
|
undefined
is not part of the json specification and will throw an error if you try to serialize it.
I'm facing several problems supporting floating-point numbers. PR's and / or issues with ideas / suggestions are highly appreciated!
Plugins
It's possible to write custom encoders for data-types not supported out-of-the-box. Head to plugins to get started!
Logo / Icon provided by Icons8 .
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
算法艺术与信息学竞赛
刘汝佳 / 清华大学出版社 / 2004-1 / 45.00元
《算法艺术与信息学竞赛》较为系统和全面地介绍了算法学最基本的知识。这些知识和技巧既是高等院校“算法与数据结构”课程的主要内容,也是国际青少年信息学奥林匹克(IOI)竞赛和ACM/ICPC国际大学生程序设计竞赛中所需要的。书中分析了相当数量的问题。 本书共3章。第1章介绍算法与数据结构;第2章介绍数学知识和方法;第3章介绍计算机几何。全书内容丰富,分析透彻,启发性强,既适合读者自学,也适合于课......一起来看看 《算法艺术与信息学竞赛》 这本书的介绍吧!
HTML 编码/解码
HTML 编码/解码
MD5 加密
MD5 加密工具