
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
@ddoronin/super-object
Advanced tools
$ yarn add @ddoronin/super-object
It's like
Object.assign(), but even more.
Suppose you compose a request to upload a file. You decided to set different content types based on a file extension and apply gzip if this a javascript or css file.
import { compose } from 'super-object';
...
function createRequest(payload: any, fileExt: string) {
return api.compose({
body: { ...payload }
}).if(fileExt === '.js', {
contentType: 'text/javascript'
}).elseif(fileExt === '.css', {
contentType: 'text/css'
}).else({
contentType: 'application/octet-stream'
}).if(fileExt === '.js' || fileExt === '.css', {
encoding: 'gzip'
}).val();
}
| method | description |
|---|---|
| compose<A extends {}>(a: A = {} as any): IComposer<A> | Creates a wrapper around a given object a: A that is a context object. |
| append<B>(b: B): IComposer<A | B> | Appends a given object b to the context A |
| if<B>(condition: boolean, b: B): IComposer<A | B> | Appends a given object b to the context A if and only if the condition is satisfied. |
| elseif<C>(condition: boolean, c: C): IComposer<A | C> | Appends a given object c to the context A if and only if the condition is satisfied and a previous conditions were falsy. |
| else<D>(d: D): IComposer<A | D> | Appends a given object d to the context A if all previous conditions were falsy. |
| val(): A | Simply returns the context object A. |
export interface IComposer<A> {
append<B>(b: B): IComposer<A | B>;
if<B>(condition: boolean, b: B): IComposer<A | B>;
elseif<C>(condition: boolean, c: C): IComposer<A | C>
else<D>(d: D): IComposer<A | D>;
val(): A;
}
MIT
FAQs
Object on drugs
We found that @ddoronin/super-object 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
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.