https://github.com/cesiumlabs/serialize_javascript
Deno version of serialize-javascript
https://github.com/cesiumlabs/serialize_javascript
deno javascript serialize-javascript serializer typescript
Last synced: 2 months ago
JSON representation
Deno version of serialize-javascript
- Host: GitHub
- URL: https://github.com/cesiumlabs/serialize_javascript
- Owner: CesiumLabs
- Created: 2021-01-12T18:25:34.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-12T18:38:05.000Z (over 5 years ago)
- Last Synced: 2025-03-17T20:54:12.705Z (over 1 year ago)
- Topics: deno, javascript, serialize-javascript, serializer, typescript
- Language: TypeScript
- Homepage: https://deno.land/x/serialize_javascript
- Size: 2.93 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Serialize JavaScript
Deno version of **[serialize-javascript](https://npmjs.com/package/serialize-javascript)**.
# Example
```js
import { serialize, deserialize } from "https://deno.land/x/serialize_javascript/mod.ts";
const result = serialize({
str: 'string',
num: 0,
obj: { foo: 'foo' },
arr: [1, 2, 3],
bool: true,
nil: null,
undef: undefined,
inf: Infinity,
date: new Date(),
map: new Map([['hello', 'world']]),
set: new Set([123, 456]),
fn: function echo(arg: string) { return arg; },
re: /([^\s]+)/g,
big: BigInt(10)
})
console.log(result);
const parsed = deserialize(result);
console.log(parsed)
```
# Preview
## First
```js
{"str":"string","num":0,"obj":{"foo":"foo"},"arr":[1,2,3],"bool":true,"nil":null,"undef":undefined,"inf":Infinity,"date":new Date("2021-01-12T18:21:27.987Z"),"map":new Map([["hello","world"]]),"set":new Set([123,456]),"fn":function echo(arg) { return arg; },"re":new RegExp("([^\\s]+)", "g"),"big":BigInt("10")}
```
## Second
```js
{
str: "string",
num: 0,
obj: { foo: "foo" },
arr: [ 1, 2, 3 ],
bool: true,
nil: null,
undef: undefined,
inf: Infinity,
date: 2021-01-12T18:21:27.987Z,
map: Map { "hello" => "world" },
set: Set { 123, 456 },
fn: [Function: echo],
re: /([^\s]+)/g,
big: 10n
}
```