@ndriadev/futurable 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,11 +3,18 @@
3
3
  <p align="center">
4
4
  Power up for Javascript's Promise API with cancellation support and more.
5
5
  </p>
6
- <p align="center">
7
- <a href="https://www.npmjs.com/package/futurable">
8
- <img src="https://img.shields.io/npm/v/futurable?color=orange&label=" alt="version" />
9
- </a>
10
- </p>
6
+ <div align="center">
7
+
8
+ [![npm version](https://img.shields.io/npm/v/%40ndriadev/futurable?color=orange&style=flat)](https://www.npmjs.org/package/%40ndriadev/futurable)
9
+ [![npm bundle size](https://img.shields.io/bundlephobia/min/%40ndriadev/futurable)](https://bundlephobia.com/package/%40ndriadev/futurable)
10
+ </div>
11
+ <div align="center">
12
+
13
+ ![Statements](https://img.shields.io/badge/statements-100%25-brightgreen.svg?style=flat)
14
+ ![Branches](https://img.shields.io/badge/branches-96.46%25-brightgreen.svg?style=flat)
15
+ ![Functions](https://img.shields.io/badge/functions-100%25-brightgreen.svg?style=flat)
16
+ ![Lines](https://img.shields.io/badge/lines-100%25-brightgreen.svg?style=flat)
17
+ </div>
11
18
 
12
19
 
13
20
  # Summary
@@ -68,6 +75,8 @@ const { Futurable } = require('futurable'); // ok
68
75
  ## Use-case
69
76
  ### React
70
77
  Thanks to the use of this library, there is a simple and effective way to be able to cancel an Api request executed in a useEffect which, due to the Strict Mode, is executed twice:
78
+
79
+ *Example*
71
80
  ```jsx
72
81
  export default function Component() {
73
82
  //...code
@@ -76,8 +85,7 @@ export default function Component() {
76
85
  const f;
77
86
  function callApi() {
78
87
  f = Futurable
79
- .fetch("https://jsonplaceholder.typicode.com/todos/2")
80
- .onAbort(() => console.log("aborted"))
88
+ .fetch("...")
81
89
  .then(resp => resp.json())
82
90
  .then(setTodo);
83
91
  }
@@ -93,7 +101,7 @@ export default function Component() {
93
101
  const controller = new AbortController();
94
102
  Futurable
95
103
  .fetch(
96
- "https://jsonplaceholder.typicode.com/todos/2",
104
+ "...",
97
105
  {
98
106
  signal: controller.signal
99
107
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@ndriadev/futurable",
3
3
  "description": "Extension Javascript's Promise API with more functionalities",
4
4
  "private": false,
5
- "version": "1.0.0",
5
+ "version": "1.0.2",
6
6
  "type": "module",
7
7
  "engines": {
8
8
  "node": ">=16.13.2"
@@ -27,9 +27,11 @@
27
27
  },
28
28
  "main": "./src/index.ts",
29
29
  "types": "./src/index.d.ts",
30
- "scripts": {
30
+ "//scripts": {
31
31
  "preinstall": "node ./scripts/preinstall.js --foreground-script",
32
- "postinstall": "echo 'postinstall executed'",
32
+ "postinstall": "echo 'postinstall executed'"
33
+ },
34
+ "scripts": {
33
35
  "build": "tsc && vite build",
34
36
  "test": "NODE_OPTIONS=--experimental-vm-modules jest",
35
37
  "lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'",
@@ -1,17 +1,17 @@
1
- import { exec } from 'child_process';
1
+ // import { exec } from 'child_process';
2
2
 
3
- const result = process.versions;
3
+ // const result = process.versions;
4
4
 
5
- if (result && result.node && parseInt(result.node) < 16) {
6
- exec("npm install node-fetch", (err, stdout, sterr) => {
7
- if (err) {
8
- console.log("err", err.message);
9
- process.exit(1);
10
- } else if (sterr) {
11
- console.log("stderr", sterr);
12
- process.exit(1);
13
- }
14
- console.log("stdout", stdout);
15
- process.exit(0);
16
- });
17
- }
5
+ // if (result && result.node && parseInt(result.node) < 16) {
6
+ // exec("npm install node-fetch", (err, stdout, sterr) => {
7
+ // if (err) {
8
+ // console.log("err", err.message);
9
+ // process.exit(1);
10
+ // } else if (sterr) {
11
+ // console.log("stderr", sterr);
12
+ // process.exit(1);
13
+ // }
14
+ // console.log("stdout", stdout);
15
+ // process.exit(0);
16
+ // });
17
+ // }