thaw 6.0.0 → 6.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
@@ -37,7 +37,7 @@ import {
37
37
  {
38
38
  const fn = after(
39
39
  (v) => v + 1,
40
- (...args) => console.log('args passed to fn', args), // [ 1 ]
40
+ (...args) => console.log('after fn args', args), // [ 1 ]
41
41
  );
42
42
 
43
43
  console.log('after', fn(1)); // 2
@@ -55,13 +55,15 @@ import {
55
55
  {
56
56
  const fn = afterThrowing(
57
57
  () => { throw new Error('boom'); },
58
- (err, ...args) => console.error('afterThrowing', `${ err.message }-${ args }`), // boom-2,3
58
+ (err, ...args) => {
59
+ console.error('afterThrowing', `${ err.message }-${ args }`); // Boom-2,3
60
+ },
59
61
  );
60
62
 
61
63
  try {
62
64
  fn(2, 3);
63
65
  } catch (err) {
64
- console.error('afterThrowing', err.message); // boom
66
+ console.error('afterThrowing', err.message); // Boom
65
67
  }
66
68
  }
67
69
 
@@ -77,7 +79,7 @@ import {
77
79
  {
78
80
  const fn = before(
79
81
  (v) => v + 1,
80
- (...args) => console.log('args passed to fn', args), // [ 1 ]
82
+ (...args) => console.log('before fn args', args), // [ 1 ]
81
83
  );
82
84
 
83
85
  console.log('before', fn(1)); // 2
package/dist/index.cjs CHANGED
@@ -6,9 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.throttle = exports.pipe = exports.debounce = exports.before = exports.around = exports.afterThrowing = exports.afterReturning = exports.after = void 0;
7
7
  const after = (fn, advice) => {
8
8
  return function (...args) {
9
- const result = fn.apply(this, args);
10
- advice.apply(this, args);
11
- return result;
9
+ try {
10
+ return fn.apply(this, args);
11
+ } finally {
12
+ advice.apply(this, args);
13
+ }
12
14
  };
13
15
  };
14
16
  exports.after = after;
package/package.json CHANGED
@@ -12,9 +12,10 @@
12
12
  "@babel/cli": "^7.28.6",
13
13
  "@babel/core": "^7.29.0",
14
14
  "@babel/preset-env": "^7.29.0",
15
+ "@eslint/markdown": "^7.5.1",
15
16
  "c8": "^10.1.3",
16
- "eslint": "^10.0.0",
17
- "eslint-config-ultra-refined": "^4.0.1",
17
+ "eslint": "^10.0.1",
18
+ "eslint-config-ultra-refined": "^4.1.2",
18
19
  "mocha": "^11.7.5"
19
20
  },
20
21
  "engines": {
@@ -41,14 +42,14 @@
41
42
  "url": "git+https://github.com/bricss/thaw.git"
42
43
  },
43
44
  "scripts": {
44
- "build": "rm -rf dist && npx babel src --out-dir dist --out-file-extension .cjs",
45
+ "build": "rm -rf dist && npx babel src --out-dir dist --out-file-extension .cjs && sh misc.sh",
45
46
  "lint": "eslint --concurrency=auto",
46
- "prepack": "npm run build && sh misc.sh && npm run lint",
47
+ "prepack": "npm run build && npm run lint",
47
48
  "pretest": "rm -rf coverage",
48
49
  "test": "mocha",
49
50
  "test:bail": "mocha --bail",
50
51
  "test:cover": "c8 --include=src --reporter=lcov --reporter=text npm test"
51
52
  },
52
53
  "type": "module",
53
- "version": "6.0.0"
54
+ "version": "6.0.2"
54
55
  }
package/src/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  export const after = (fn, advice) => {
2
2
  return function (...args) {
3
- const result = fn.apply(this, args);
4
-
5
- advice.apply(this, args);
6
-
7
- return result;
3
+ try {
4
+ return fn.apply(this, args);
5
+ } finally {
6
+ advice.apply(this, args);
7
+ }
8
8
  };
9
9
  };
10
10