
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@nkp/is-promise
Advanced tools
Utility functions for determining if values are Promises or Promise-Like's.
Utility functions for determining if values conform to the Promise or PromiseLike interfaces.
// interface
/**
* Does the unknown value conform to the Promise interface?
*
* @param value any value
* @returns whether the value is Promise
*/
declare function isPromise<T>(value: PromiseLike<T> | unknown): value is Promise<T>;
/**
* Does the unknown value conform to the PromiseLike interface?
*
* @param value any value
* @returns whether the value is a PromiseLike
*/
declare function isPromiseLike<T>(value: PromiseLike<T> | unknown): value is PromiseLike<T>;
/**
* Does the PromiseLike value conform to the Promise interface?
*
* @param like PromiseLike value
* @returns whether the value is a Promise
*/
declare function andIsPromise<T>(like: PromiseLike<T>): like is Promise<T>;
// usage
import { isPromise, isPromiseLike, andIsPromise, } from '@nkp/is-promise';
// isPromiseLike
console.log(isPromiseLike(new Promise<void>((res) => res()))); // true
console.log(isPromiseLike(Promise.reject())); // true
console.log(isPromiseLike(Promise.resolve().catch(() => {}))); // true
console.log(isPromiseLike({ then() {}, catch() {}, })); // true
console.log(isPromiseLike({ then: () => {}, catch: () => {}, })); // true
console.log(isPromiseLike({ then: () => {}, })); // true
console.log(isPromiseLike({ catch: () => {}, })); // false
// isPromise
console.log(isPromise(new Promise<void>((res) => res()))); // true
console.log(isPromise(Promise.resolve())); // true
console.log(isPromise(Promise.reject().catch(() => {}))); // true
console.log(isPromise({ then() {}, catch() {}, })); // true
console.log(isPromise({ then: () => {}, catch: () => {}, })); // true
console.log(isPromise({ then: () => {}, })); // false
console.log(isPromise({ catch: () => {}, })); // false
// andIsPromise
// takes a PromiseLike value and determines if it is actually a promise
npm install @nkp/is-promise
yarn add @nkp/is-promise
pnpm add @nkp/is-promise
To a release a new version:
master
branch on GitHubnew release
on GitHub for the latest versionThis will trigger a GitHub action that tests and publishes the npm package.
FAQs
Utility functions for determining if values are Promises or Promise-Like's.
We found that @nkp/is-promise 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
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.