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.
Function.prototype.bind with typings for TypeScript
Function#bind
is untyped in TypeScript (in v3.0 at least, cf: #212).
It always returns any
.
function foo(a: number, b: number): string {
return `${this.msg}: ${a + b}`;
}
// bar is `any`!
const bar = foo.bind({msg: 'hello'}, 10);
// ok
bar(20); // 'hello: 30'
// should be a type error, but actually allowed...
bar('anything');
bind.ts
is a workaround for this issue.
import bind from 'bind.ts';
// bar is `(b: number) => string`
const bar = bind(foo, {msg: 'hello'}, 10);
// ok
bar(20); // 'hello: 30'
// error!
bar('anything');
Note: TypeScript v3.0 introduces generic rest parameters. It's helpful but cannot solve this issue completely and the type definition of Function#bind
in TypeScript core is not changed.
bind.ts v2 requires TypeScript v3.0+. For TypeScript v2.x, use bind.ts v1.
The maximum number of params of bind()
is 5.
MIT License: Teppei Sato <teppeis@gmail.com>
FAQs
Function.prototype.bind with typings for TypeScript
The npm package bind.ts receives a total of 33 weekly downloads. As such, bind.ts popularity was classified as not popular.
We found that bind.ts 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 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.