Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Commit

Permalink
Release 11.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
btd committed Aug 14, 2016
1 parent 2b39dda commit 34edd41
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
5 changes: 5 additions & 0 deletions History.md
@@ -1,3 +1,8 @@
11.1.0 / 2016-08-14
===================

* Update modules

11.0.0 / 2016-08-10
===================

Expand Down
4 changes: 2 additions & 2 deletions 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 <tj@vision-media.ca>, Denis Bardadym <bardadymchik@gmail.com> and other contributors",
"repository": {
"type": "git",
Expand Down Expand Up @@ -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"
},
Expand Down
27 changes: 21 additions & 6 deletions should.js
@@ -1,6 +1,6 @@
/*!
* should - test framework agnostic BDD-style assertions
* @version v11.0.0
* @version v11.1.0
* @author TJ Holowaychuk <tj@vision-media.ca>, Denis Bardadym <bardadymchik@gmail.com> and other contributors
* @link https://github.com/shouldjs/should.js
* @license MIT
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -108,6 +106,10 @@
}
};

var toString = Object.prototype.toString;



/**
* Function to store type checks
* @private
Expand All @@ -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) {
Expand All @@ -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;
}
};

Expand Down

0 comments on commit 34edd41

Please sign in to comment.