assert-match
Version:
assert + matchers <3
69 lines (48 loc) • 1.6 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _strict = require('../matchers/strict');
var _strict2 = _interopRequireDefault(_strict);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = {
hasOwn: hasOwn,
isMatcher: isMatcher,
isObject: isObject,
isStandardObject: isStandardObject,
iterateKeys: iterateKeys
};
function hasOwn(obj, key) {
return isObject(obj) && Object.prototype.hasOwnProperty.call(obj, key);
}
function isMatcher(obj) {
return obj instanceof _strict2.default;
}
function isObject(obj) {
return obj && (typeof obj === 'undefined' ? 'undefined' : (0, _typeof3.default)(obj)) === 'object';
}
function isStandardObject(obj) {
return obj instanceof Buffer || obj instanceof ArrayBuffer || obj instanceof Boolean || obj instanceof Date || obj instanceof Number || obj instanceof RegExp || obj instanceof String || isArguments(obj);
}
function isArguments(object) {
return Object.prototype.toString.call(object) === '[object Arguments]';
}
function iterateKeys() {
var visited = [];
return function keysIterator(obj, cb) {
if (!isObject(obj)) {
return;
}
if (visited.indexOf(obj) !== -1) {
return;
}
visited.push(obj);
for (var key in obj) {
cb(key);
}
visited.pop();
};
}
module.exports = exports['default'];
;