kareem 2.3.0 → 2.3.1

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/.travis.yml CHANGED
@@ -1,5 +1,7 @@
1
1
  language: node_js
2
2
  node_js:
3
+ - "12"
4
+ - "10"
3
5
  - "9"
4
6
  - "8"
5
7
  - "7"
package/index.js CHANGED
@@ -395,6 +395,10 @@ Kareem.prototype.pre = function(name, isAsync, fn, error, unshift) {
395
395
  ++pres.numAsync;
396
396
  }
397
397
 
398
+ if (typeof fn !== 'function') {
399
+ throw new Error('pre() requires a function, got "' + typeof fn + '"');
400
+ }
401
+
398
402
  if (unshift) {
399
403
  pres.unshift(Object.assign({}, options, { fn: fn, isAsync: isAsync }));
400
404
  } else {
@@ -413,6 +417,10 @@ Kareem.prototype.post = function(name, options, fn, unshift) {
413
417
  options = {};
414
418
  }
415
419
 
420
+ if (typeof fn !== 'function') {
421
+ throw new Error('post() requires a function, got "' + typeof fn + '"');
422
+ }
423
+
416
424
  if (unshift) {
417
425
  hooks.unshift(Object.assign({}, options, { fn: fn }));
418
426
  } else {
package/package.json CHANGED
@@ -1,31 +1,21 @@
1
1
  {
2
2
  "name": "kareem",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Next-generation take on pre/post function hooks",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "./node_modules/mocha/bin/mocha ./test/*",
8
- "test-travis": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- -R spec ./test/*"
7
+ "test": "mocha ./test/*",
8
+ "test-travis": "nyc mocha ./test/*"
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "git://github.com/vkarpov15/kareem.git"
13
13
  },
14
14
  "devDependencies": {
15
- "acquit": "0.5.1",
16
- "gulp": "3.8.10",
17
- "gulp-mocha": "2.0.0",
18
- "gulp-jscs": "1.4.0",
19
- "istanbul": "0.4.5",
20
- "jscs": "1.9.0",
21
- "mocha": "3.2.0",
15
+ "nyc": "11.x",
16
+ "mocha": "5.x",
22
17
  "standard-version": "4.4.0"
23
18
  },
24
- "jscsConfig": {
25
- "preset": "airbnb",
26
- "requireMultipleVarDecl": null,
27
- "disallowMultipleVarDecl": true
28
- },
29
19
  "author": "Valeri Karpov <val@karpov.io>",
30
20
  "license": "Apache-2.0"
31
21
  }
package/test/post.test.js CHANGED
@@ -40,6 +40,10 @@ describe('execPost', function() {
40
40
  assert.equal(hooks._posts.get('cook')[0].bar, 'baz');
41
41
  });
42
42
 
43
+ it('throws error if no function', function() {
44
+ assert.throws(() => hooks.post('test'), /got "undefined"/);
45
+ });
46
+
43
47
  it('multiple posts', function(done) {
44
48
  hooks.post('cook', function(eggs, callback) {
45
49
  setTimeout(
package/test/pre.test.js CHANGED
@@ -65,6 +65,10 @@ describe('execPre', function() {
65
65
  assert.strictEqual(hooks._pres.get('cook')[1].fn, f1);
66
66
  });
67
67
 
68
+ it('throws error if no function', function() {
69
+ assert.throws(() => hooks.pre('test'), /got "undefined"/);
70
+ });
71
+
68
72
  it('arbitrary options', function() {
69
73
  const f1 = function() {};
70
74
  const f2 = function() {};