Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

promise-make-naked

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-make-naked - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

11

dist/index.js

@@ -10,6 +10,11 @@ /* IMPORT */

const promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
resolve = value => {
resolved = true;
return res(value);
};
reject = value => {
rejected = true;
return rej(value);
};
});
promise.then(() => resolved = true, () => rejected = true);
const isPending = () => !resolved && !rejected;

@@ -16,0 +21,0 @@ const isResolved = () => resolved;

@@ -5,3 +5,3 @@ {

"description": "A simple function that makes a promise that can be resolved or rejected from the outside.",
"version": "2.1.0",
"version": "2.1.1",
"type": "module",

@@ -8,0 +8,0 @@ "main": "dist/index.js",

@@ -18,8 +18,15 @@

const promise = new Promise<T> ( ( res, rej ): void => {
resolve = res;
reject = rej;
resolve = value => {
resolved = true;
return res ( value );
};
reject = value => {
rejected = true;
return rej ( value );
};
});
promise.then ( () => resolved = true, () => rejected = true );
const isPending = (): boolean => !resolved && !rejected;

@@ -26,0 +33,0 @@ const isResolved = (): boolean => resolved;

@@ -32,3 +32,3 @@

it ( 'returns a function which can be used to check if the promise is pending, resolve branch', async t => {
it ( 'returns a function which can be used to check if the promise is pending, resolve branch', t => {

@@ -41,4 +41,2 @@ const {resolve, isPending} = makeNakedPromise ();

await delay ( 50 );
t.false ( isPending () );

@@ -48,6 +46,8 @@

it ( 'returns a function which can be used to check if the promise is pending, reject branch', async t => {
it ( 'returns a function which can be used to check if the promise is pending, reject branch', t => {
const {reject, isPending} = makeNakedPromise ();
const {promise, reject, isPending} = makeNakedPromise ();
promise.catch ( () => {} );
t.true ( isPending () );

@@ -57,4 +57,2 @@

await delay ( 50 );
t.false ( isPending () );

@@ -64,3 +62,3 @@

it ( 'returns a function which can be used to check if the promise is resolved, resolve branch', async t => {
it ( 'returns a function which can be used to check if the promise is resolved, resolve branch', t => {

@@ -73,4 +71,2 @@ const {resolve, isResolved} = makeNakedPromise ();

await delay ( 50 );
t.true ( isResolved () );

@@ -80,6 +76,8 @@

it ( 'returns a function which can be used to check if the promise is resolved, reject branch', async t => {
it ( 'returns a function which can be used to check if the promise is resolved, reject branch', t => {
const {reject, isResolved} = makeNakedPromise ();
const {promise, reject, isResolved} = makeNakedPromise ();
promise.catch ( () => {} );
t.false ( isResolved () );

@@ -89,4 +87,2 @@

await delay ( 50 );
t.false ( isResolved () );

@@ -96,3 +92,3 @@

it ( 'returns a function which can be used to check if the promise is rejected, resolve branch', async t => {
it ( 'returns a function which can be used to check if the promise is rejected, resolve branch', t => {

@@ -105,4 +101,2 @@ const {resolve, isRejected} = makeNakedPromise ();

await delay ( 50 );
t.false ( isRejected () );

@@ -112,6 +106,8 @@

it ( 'returns a function which can be used to check if the promise is rejected, reject branch', async t => {
it ( 'returns a function which can be used to check if the promise is rejected, reject branch', t => {
const {reject, isRejected} = makeNakedPromise ();
const {promise, reject, isRejected} = makeNakedPromise ();
promise.catch ( () => {} );
t.false ( isRejected () );

@@ -121,4 +117,2 @@

await delay ( 50 );
t.true ( isRejected () );

@@ -125,0 +119,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc