From 34edd4199f539b7c0e4da4e4c017e7357aeb30d0 Mon Sep 17 00:00:00 2001 From: Denis Bardadym Date: Sun, 14 Aug 2016 12:41:25 +0300 Subject: [PATCH] Release 11.1.0 --- History.md | 5 +++++ package.json | 4 ++-- should.js | 27 +++++++++++++++++++++------ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/History.md b/History.md index f747ee7..5c53307 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +11.1.0 / 2016-08-14 +=================== + + * Update modules + 11.0.0 / 2016-08-10 =================== diff --git a/package.json b/package.json index 56c405e..cfcbdf3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "should", "description": "test framework agnostic BDD-style assertions", - "version": "11.0.0", + "version": "11.1.0", "author": "TJ Holowaychuk , Denis Bardadym and other contributors", "repository": { "type": "git", @@ -39,7 +39,7 @@ "dependencies": { "should-equal": "^1.0.0", "should-format": "^3.0.1", - "should-type": "^1.1.0", + "should-type": "^1.4.0", "should-type-adaptors": "^1.0.0", "should-util": "^1.0.0" }, diff --git a/should.js b/should.js index e68a939..4422bff 100644 --- a/should.js +++ b/should.js @@ -1,6 +1,6 @@ /*! * should - test framework agnostic BDD-style assertions - * @version v11.0.0 + * @version v11.1.0 * @author TJ Holowaychuk , Denis Bardadym and other contributors * @link https://github.com/shouldjs/should.js * @license MIT @@ -52,9 +52,7 @@ SIMD: 'simd' }; - var toString = Object.prototype.toString; - - /** + /* * Simple data function to store type information * @param {string} type Usually what is returned from typeof * @param {string} cls Sanitized @Class via Object.prototype.toString @@ -108,6 +106,10 @@ } }; + var toString = Object.prototype.toString; + + + /** * Function to store type checks * @private @@ -122,6 +124,15 @@ return this; }, + addBeforeFirstMatch: function(obj, func) { + var match = this.getFirstMatch(obj); + if (match) { + this.checks.splice(match.index, 0, func); + } else { + this.add(func); + } + }, + addTypeOf: function(type, res) { return this.add(function(obj, tpeOf) { if (tpeOf === type) { @@ -138,17 +149,21 @@ }); }, - getType: function(obj) { + getFirstMatch: function(obj) { var typeOf = typeof obj; var cls = toString.call(obj); for (var i = 0, l = this.checks.length; i < l; i++) { var res = this.checks[i].call(this, obj, typeOf, cls); if (typeof res !== 'undefined') { - return res; + return { result: res, func: this.checks[i], index: i }; } } + }, + getType: function(obj) { + var match = this.getFirstMatch(obj); + return match && match.result; } };