Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
🎶 Typed Serialization and Deserialization
This library is a type-safe serialization/deserialization library inspired by serde.rs
.
It contains the basic abstract types, some primitive functions, and object functions.
npm i ts-serde
import { Serde } from 'ts-serde'
import { Serialize, Deserialize } from 'ts-serde/types'
type Serialize<T> = (val: T) => string
type Deserialize<T> = (str: string) => T
type Serde<T> = {
serialize: Serialize<T>
deserialize: Deserialize<T>
}
Simple implementation using standard constructors.
import { string, number, boolean, bigint } from 'ts-serde/primitive'
Type | serialize | deserialize |
---|---|---|
string | String | String |
number | String | Number |
bigint | String | BigInt |
boolean | String | x === 'true' |
integer | String | parseInt |
import { enums } from 'ts-serde/object'
const e = enums(['foo', 'bar', 'baz'])
e.serialize('foo') // => 'foo'
e.deserialize('foo') // => 'foo'
e.deserialize('qux') // => To Throw Error
const withFallback = enums(['foo', 'bar', 'baz'], 'fallback')
withFallback.deserialize('qux') // => 'fallback'
The object conversion methods are JSON
and devalue
.
import { json } from 'ts-serde/object'
const j = json(
(x): x is { key: string } =>
// ... Type Guard
)
j.serialize({ key: 'value' }) // => '{"key":"value"}'
j.deserialize('') // => To Throw Error
devalue
supports more types than JSON.
import { devalue } from 'ts-serde/object'
const d = devalue(
(x): x is Set<Date> =>
// ... Type Guard
,
null // fallback value
)
d.serialize(new Set([new Date()]))
// => '[["Set",1],["Date","20XX-01-01T00:00:00.000Z"]]'
d.deserialize('') // => null (fallback value)
FAQs
🎶 Typed Serialization and Deserialization
The npm package ts-serde receives a total of 3,888 weekly downloads. As such, ts-serde popularity was classified as popular.
We found that ts-serde demonstrated a healthy version release cadence and project activity because the last version was released less than 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.