Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@krakenjs/universal-serialize
Advanced tools
Universal serializer and deserializer, which supports many build-in javascript types, and any number of custom types you want to support
import { serialize, deserialize } from 'universal-serialize';
// Define a complex object
const originalObject = {
foo: 'bar',
date: new Date(),
error: new Error('world')
};
// Serialize the complex object
const jsonString = serialize(originalObject);
// Deserialize the object
const deserializedObject = deserialize(jsonString);
// Make use of the deserialized data and objects
console.log(
deserializedObject.foo,
deserializedObject.date.toUTCString(),
deserializedObject.error.stack
);
By default universal serialize will serialize:
import { serialize, deserialize, serializeType, TYPE } from 'universal-serialize';
// Define a new serialization type
const SERIALIZED_FUNCTION = 'SERIALIZED_FUNCTION';
// Define a complex object containing a function
const originalObject = {
sayHello: () => {
console.log('Hello world!');
};
};
// Serialize the object with a special handler to serialize function types
const jsonString = serialize(originalObject, {
[ TYPE.FUNCTION ]: (val) => {
// Serialize the function as a 'serialized function'
return serializeType(SERIALIZED_FUNCTION, val.toString());
}
});
// Deserialize any `SERIALIZED_FUNCTION` types from the serialized object
const deserializedObject = deserialize(jsonString, {
[ SERIALIZED_FUNCTION ]: (fnString) => {
return eval(fnString);
}
});
// Call the deserialized functionn
deserializedObject.sayHello();
npm install
./src
and writing tests in ./tests
npm run build
npm run build
Edit tests in ./test/tests
Run the tests:
npm run test
npm run karma -- --browser=PhantomJS
npm run karma -- --browser=Chrome
npm run karma -- --browser=Safari
npm run karma -- --browser=Firefox
npm run karma -- --browser=PhantomJS,Chrome,Safari,Firefox
npm run karma -- --browser=Chrome --keep-open
./src
, ./test/tests
and ./demo
package.json
README.md
and CONTRIBUTING.md
npm run release
to add a patch
npm run release:path
, npm run release:minor
, npm run release:major
2.0.0 (2022-02-28)
FAQs
Javascript module template.
The npm package @krakenjs/universal-serialize receives a total of 1,977 weekly downloads. As such, @krakenjs/universal-serialize popularity was classified as popular.
We found that @krakenjs/universal-serialize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.