
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
Painless object (de)serialization with simple schemas, optimized for speed (and not encoded size).
const { encode, decode } = codec({
id: "int",
url: "string",
method: "string",
headers: {
accept: "string",
"user-agent": "string"
}
});
const encoded = encode({
id: 2013820,
url: "/some/path?with=query",
method: "GET",
headers: {
accept: "application/json",
"user-agent": "Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/12.0"
}
});
console.log(encoded);
// Uint8Array [ 4 0 0 0 124 186 30 0 42 0 0 0 47 0 115 0 111 0 109 0 101 0 47 0 112 0 97 0
// 116 0 104 0 63 0 119 0 105 0 116 0 104 0 61 0 113 0 117 0 101 0 114 0 121 0 0 0 6 0 0 0
// 71 0 69 0 84 0 0 0 176 0 0 0 32 0 0 0 97 0 112 0 112 0 108 0 105 0 99 0 97 0 116 0 105
// 0 111 0 110 0 47 0 106 0 115 0 111 0 110 0 136 0 0 0 77 0 111 0 122 0 105 0 108 0 108 0
// 97 0 47 0 53 0 46 0 48 0 32 0 40 0 88 0 49 0 49 0 59 0 32 0 76 0 105 0 110 0 117 0 120
// 0 32 0 120 0 56 0 54 0 95 0 54 0 52 0 59 0 32 0 114 0 118 0 58 0 49 0 50 0 46 0 48 0 41
// 0 32 0 71 0 101 0 99 0 107 0 111 0 47 0 50 0 48 0 49 0 48 0 48 0 49 0 48 0 49 0 32 0 70
// 0 105 0 114 0 101 0 102 0 111 0 120 0 47 0 49 0 50 0 46 0 48 0 ]
console.log(JSON.stringify(decode(encoded), null, 2));
// {
// "id": 2013820,
// "url": "/some/path?with=query",
// "method": "GET",
// "headers": {
// "accept": "application/json",
// "user-agent": "Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/12.0"
// }
// }
The following field types are supported:
int: An unsigned integer.string: A string.json: A simple, hierarchical data-structure that can be JSON serialized.typed: A Uint8Array instance.Additionally, hierarchical data-structures are supported by passing an object where the values are valid field types.
FAQs
A simple object serialization library.
We found that cereal-box demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.