
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
@caasi/then
Advanced tools
A Promise
toolset for asynchronous React apps.
It is created for rapid prototyping without setting up any framework like Redux.
npm install @caasi/then
It lifts a React component from Component<Props>
to
Component<PromisedEach<Props>>
.
type PromisedEach<T> = {
[P in keyof T]: Promise<T[P]>
}
You can use it to resolve promises for the inner component:
import { Then } from '@caasi/then'
const Foobar = ({ name }) => <span>I am { name }.</span>
class MyComp extends PureComponent {
render() {
return (
<Then name={Promise.resolve('John')}>
<Foobar />
</Then>
)
}
}
export default MyComp
Then the inner component will get the promised value "John" when the promise is resolved.
Unresolved values will be undefined so you can deal with them in the inner component:
const Foobar = ({ name = 'John' }) => <span>I am { name }.</span>
It also works on a function as child component(FaCC):
<Then name={Promise.resolve('Isaac')}>{
({ name = 'John' }) => <span>I am { name }.</span>
}</Then>
It lifts the React component from Component<Props, State>
to
Component<Props, Promise<State>>
. And make the setState
function a effective
>>=
function.
class PromisedComponent {
setState: (State => Promise<State>) => Promise<State>
getState: () => Promise<State>
dispatch: ((...args: any[]) => State => Promise<State>) => (...args: any[]) => Promise<State>
}
So you can create component independent actions like this:
type Action<T> = T => Promise<T>
login
: (username: string, password: string) => Action<State>
= (username, password) => async (state) => {
const { data: profile } = await axios.post('http://example.com/login', { username, password })
return { profile }
}
fireAndForget
: () => Action<State>
= () => async (state) => {
await axios.put('http://example.com/cleanup');
}
And use them in your PromisedComponent
:
class App extends PromisedComponent {
state = {
// the promised state
p: Promise.resolve({}),
// other states
username: '',
password: '',
}
render() {
const { username, password } = this.state
return (
<button onClick={() => this.dispatch(login)(username, password)} />
);
}
}
FAQs
A `Promise` toolset for asynchronous React apps.
We found that @caasi/then 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
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.