Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
serialize-as-code
Advanced tools
This serializer is intended for serializing ANY Javascript objects into
its source code representation. It is cyclomatic-save extension and alternative
to e.g. JSON.stringify
. It can even be used to perform deep comparisions
for most cases. ATTENTION: There is no functionality to parse the string back
to the provided object. (one-direction-flow)
yarn add serialize-as-code # if you want to use it for prod
yarn add --dev serialize-as-code # if only used in tests
You may import the named import Serializer
and call run with ANY object.
It prints the object as its source code. So you should be able to copy-paste
the printed result and most deep comparisons should work.
import { Serializer } from 'serialize-as-code';
// Arrays or Objects
console.log(Serializer.run({foo: 'bar'})); // prints: {foo: 'bar'}
console.log(Serializer.run([1, 2])); // prints: [1, 2]
// Symbols (not suppoerted on JSON.stringify)
console.log(Serializer.run(Symbol.for('my-key')));
// prints: Symbol.for('my-key')
// JSX (but react is not needed and their is no dependency)
console.log(Serializer.run(<Fragment key="foo"><div>Test that</div></Fragment>));
// prints: <Fragment key="foo"><div>Test that</div></Fragment>
If you try to serialize cyclomatic structures, you will see within the result were they were detected.
You have the possibility to apply ANY custom serialization just on top.
import { Serializer } from 'serialize-as-code';
const someObjectToMatch = { foo: 'foo' };
const CustomSerializer = (o: any): string | void => {
if (o === someObjectToMatch) return 'FOO';
// return undefined to proceed with regular serialization
};
const YourSerializer = Serializer.create(CustomSerializer);
console.log({canBe: 'nested', here: someObjectToMatch});
// prints: {canBe: 'nested', here: FOO}
FAQs
Serialize any Javascript object as its source code
The npm package serialize-as-code receives a total of 1,952 weekly downloads. As such, serialize-as-code popularity was classified as popular.
We found that serialize-as-code 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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.