Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

expect-more

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expect-more - npm Package Compare versions

Comparing version 0.5.5 to 0.6.0

dist/ends-with.d.ts

17

CHANGELOG.md

@@ -6,2 +6,19 @@ # Change Log

# [0.6.0](https://github.com/JamieMason/expect-more/compare/expect-more@0.5.5...expect-more@0.6.0) (2019-11-03)
### Bug Fixes
* **expect:** include async functions in isFunction ([8525ec0](https://github.com/JamieMason/expect-more/commit/8525ec0c423dd378b2f69784f6efbb435c6fa355)), closes [#21](https://github.com/JamieMason/expect-more/issues/21)
### Features
* **jest:** add toBeAsyncFunction matcher ([1f49f77](https://github.com/JamieMason/expect-more/commit/1f49f771e8c0543b1e57e8435e9d69859574d913)), closes [#21](https://github.com/JamieMason/expect-more/issues/21)
* **jest:** add toBeGeneratorFunction matcher ([4fde99e](https://github.com/JamieMason/expect-more/commit/4fde99e485a35403dd5c139c5b2a0b932a1833dd)), closes [#21](https://github.com/JamieMason/expect-more/issues/21)
## [0.5.5](https://github.com/JamieMason/expect-more/compare/expect-more@0.5.4...expect-more@0.5.5) (2019-06-17)

@@ -8,0 +25,0 @@

99

dist/index.d.ts

@@ -1,49 +0,50 @@

import { ICurry2Args, ICurry3Args, VoidFn } from './typings';
export declare const isArray: (value: any) => boolean;
export declare const isBoolean: (value: any) => boolean;
export declare const isDate: (value: any) => boolean;
export declare const isFunction: (value: any) => boolean;
export declare const isNull: (value: any) => boolean;
export declare const isObject: (value: any) => boolean;
export declare const isRegExp: (value: any) => boolean;
export declare const isString: (value: any) => boolean;
export declare const isUndefined: (value: any) => boolean;
export declare const isWalkable: (value: any) => boolean;
export declare const isAfter: ICurry2Args<Date, any, boolean>;
export declare const isFalse: (value: any) => boolean;
export declare const isTrue: (value: any) => boolean;
export declare const isBefore: ICurry2Args<Date, any, boolean>;
export declare const isNumber: (value: any) => boolean;
export declare const isDivisibleBy: ICurry2Args<number, any, boolean>;
export declare const isEvenNumber: (value: any) => boolean;
export declare const isOddNumber: (value: any) => boolean;
export declare const isWholeNumber: (value: any) => boolean;
export declare const isDecimalNumber: (value: any) => boolean;
export declare const isCalculable: (value: any) => boolean;
export declare const isGreaterThanOrEqualTo: ICurry2Args<number, any, boolean>;
export declare const isLessThanOrEqualTo: ICurry2Args<number, any, boolean>;
export declare const isWithinRange: ICurry3Args<number, number, any, boolean>;
export declare const isNear: ICurry3Args<number, number, any, boolean>;
export declare const isArrayOfBooleans: (value: any) => boolean;
export declare const isArrayOfNumbers: (value: any) => boolean;
export declare const isArrayOfObjects: (value: any) => boolean;
export declare const isArrayOfStrings: (value: any) => boolean;
export declare const isArrayOfSize: ICurry2Args<number, any, boolean>;
export declare const isEmptyArray: import("./typings").ICurry1Arg<any, boolean>;
export declare const isEmptyObject: (value: any) => boolean;
export declare const isEmptyString: (value: any) => boolean;
export declare const isValidDate: (value: any) => boolean;
export declare const isWhitespace: (value: any) => boolean;
export declare const startsWith: ICurry2Args<string, any, boolean>;
export declare const endsWith: ICurry2Args<string, any, boolean>;
export declare const isNonEmptyArray: (value: any) => boolean;
export declare const isNonEmptyObject: (value: any) => boolean;
export declare const isNonEmptyString: (value: any) => boolean;
export declare const isSameLengthAs: ICurry2Args<string | any[], any, boolean>;
export declare const isShorterThan: ICurry2Args<string | any[], any, boolean>;
export declare const isLongerThan: ICurry2Args<string | any[], any, boolean>;
export declare const hasMember: ICurry2Args<string, any, boolean>;
export declare const isIso8601: (value: any) => boolean;
export declare const isJsonString: (value: any) => boolean;
export declare const throwsAnyError: (value: VoidFn) => boolean;
export declare const throwsErrorOfType: ICurry2Args<string, VoidFn, boolean>;
export { endsWith } from './ends-with';
export { hasMember } from './has-member';
export { isAfter } from './is-after';
export { isArray } from './is-array';
export { isArrayOfBooleans } from './is-array-of-booleans';
export { isArrayOfNumbers } from './is-array-of-numbers';
export { isArrayOfObjects } from './is-array-of-objects';
export { isArrayOfSize } from './is-array-of-size';
export { isArrayOfStrings } from './is-array-of-strings';
export { isAsyncFunction } from './is-async-function';
export { isBefore } from './is-before';
export { isBoolean } from './is-boolean';
export { isCalculable } from './is-calculable';
export { isDate } from './is-date';
export { isDecimalNumber } from './is-decimal-number';
export { isDivisibleBy } from './is-divisible-by';
export { isEmptyArray } from './is-empty-array';
export { isEmptyObject } from './is-empty-object';
export { isEmptyString } from './is-empty-string';
export { isEvenNumber } from './is-even-number';
export { isFalse } from './is-false';
export { isFunction } from './is-function';
export { isGeneratorFunction } from './is-generator-function';
export { isGreaterThanOrEqualTo } from './is-greater-than-or-equal-to';
export { isIso8601 } from './is-iso-8601';
export { isJsonString } from './is-json-string';
export { isLessThanOrEqualTo } from './is-less-than-or-equal-to';
export { isLongerThan } from './is-longer-than';
export { isNear } from './is-near';
export { isNonEmptyArray } from './is-non-empty-array';
export { isNonEmptyObject } from './is-non-empty-object';
export { isNonEmptyString } from './is-non-empty-string';
export { isNull } from './is-null';
export { isNumber } from './is-number';
export { isObject } from './is-object';
export { isOddNumber } from './is-odd-number';
export { isRegExp } from './is-reg-exp';
export { isSameLengthAs } from './is-same-length-as';
export { isShorterThan } from './is-shorter-than';
export { isString } from './is-string';
export { isTrue } from './is-true';
export { isUndefined } from './is-undefined';
export { isValidDate } from './is-valid-date';
export { isWalkable } from './is-walkable';
export { isWhitespace } from './is-whitespace';
export { isWholeNumber } from './is-whole-number';
export { isWithinRange } from './is-within-range';
export { startsWith } from './starts-with';
export { throwsAnyError } from './throws-any-error';
export { throwsErrorOfType } from './throws-error-of-type';
"use strict";
exports.__esModule = true;
var curryFn = function (f, xs, ctx) {
return f.length <= xs.length ? f.apply(ctx, xs.slice(0, f.length)) : function () {
var ys = [];
for (var _i = 0; _i < arguments.length; _i++) {
ys[_i] = arguments[_i];
}
return curryFn(f, xs.concat(ys), ctx);
};
};
var curry = (function (f, ctx) {
return f.length === 0 ? function () { return f.call(ctx); } : curryFn(f, [], ctx);
});
var every = curry(function (fn, array) {
for (var i = 0, len = array.length; i < len; i++) {
if (fn(array[i]) === false) {
return false;
}
}
return array.length > 0;
});
var keys = function (object) {
var returnValue = [];
for (var key in object) {
if ({}.hasOwnProperty.call(object, key)) {
returnValue.push(key);
}
}
return returnValue;
};
var getType = function (value) { return Object.prototype.toString.call(value); };
var hasType = function (type) { return function (value) { return getType(value) === "[object " + type + "]"; }; };
var isIndexedList = function (value) { return exports.isString(value) || exports.isArray(value); };
exports.isArray = hasType('Array');
exports.isBoolean = hasType('Boolean');
exports.isDate = hasType('Date');
exports.isFunction = hasType('Function');
exports.isNull = hasType('Null');
exports.isObject = hasType('Object');
exports.isRegExp = hasType('RegExp');
exports.isString = hasType('String');
exports.isUndefined = hasType('Undefined');
exports.isWalkable = function (value) { return !exports.isNull(value) && !exports.isUndefined(value); };
var isGivenBoolean = function (bool) { return function (value) {
return value === bool || (exports.isBoolean(value) && value.valueOf() === bool);
}; };
exports.isAfter = curry(function (otherDate, value) { return exports.isDate(value) && exports.isDate(otherDate) && value.getTime() > otherDate.getTime(); });
exports.isFalse = isGivenBoolean(false);
exports.isTrue = isGivenBoolean(true);
exports.isBefore = curry(function (otherDate, value) { return exports.isAfter(value, otherDate); });
exports.isNumber = function (value) { return hasType('Number')(value) && !isNaN(parseFloat(value)); };
exports.isDivisibleBy = curry(function (other, value) { return value % other === 0; });
exports.isEvenNumber = function (value) { return exports.isNumber(value) && exports.isDivisibleBy(2, value); };
exports.isOddNumber = function (value) { return exports.isNumber(value) && !exports.isDivisibleBy(2, value); };
exports.isWholeNumber = function (value) { return exports.isNumber(value) && (value === 0 || exports.isDivisibleBy(1, value)); };
exports.isDecimalNumber = function (value) { return exports.isNumber(value) && String(value).indexOf('.') !== -1; };
exports.isCalculable = function (value) { return !isNaN(value * 2); };
exports.isGreaterThanOrEqualTo = curry(function (other, value) { return exports.isNumber(value) && exports.isNumber(other) && value >= other; });
exports.isLessThanOrEqualTo = curry(function (other, value) { return exports.isNumber(value) && exports.isNumber(other) && value <= other; });
exports.isWithinRange = curry(function (floor, ceiling, value) { return exports.isLessThanOrEqualTo(ceiling, value) && exports.isGreaterThanOrEqualTo(floor, value); });
exports.isNear = curry(function (other, epsilon, value) {
return exports.isWithinRange(other - epsilon, other + epsilon, value);
});
exports.isArrayOfBooleans = function (value) { return exports.isArray(value) && every(exports.isBoolean, value); };
exports.isArrayOfNumbers = function (value) { return exports.isArray(value) && every(exports.isNumber, value); };
exports.isArrayOfObjects = function (value) { return exports.isArray(value) && every(exports.isObject, value); };
exports.isArrayOfStrings = function (value) { return exports.isArray(value) && every(exports.isString, value); };
exports.isArrayOfSize = curry(function (size, value) { return exports.isArray(value) && value.length === size; });
exports.isEmptyArray = exports.isArrayOfSize(0);
exports.isEmptyObject = function (value) { return exports.isObject(value) && keys(value).length === 0; };
exports.isEmptyString = function (value) { return exports.isString(value) && value.length === 0; };
exports.isValidDate = function (value) { return exports.isDate(value) && !isNaN(value.getTime()); };
exports.isWhitespace = function (value) { return exports.isString(value) && value.search(/\S/) === -1; };
exports.startsWith = curry(function (otherString, value) {
return exports.isNonEmptyString(value) && exports.isNonEmptyString(otherString) && value.slice(0, otherString.length) === otherString;
});
exports.endsWith = curry(function (otherString, value) {
return exports.isNonEmptyString(value) &&
exports.isNonEmptyString(otherString) &&
value.slice(value.length - otherString.length, value.length) === otherString;
});
exports.isNonEmptyArray = function (value) { return exports.isArray(value) && value.length > 0; };
exports.isNonEmptyObject = function (value) { return exports.isObject(value) && keys(value).length > 0; };
exports.isNonEmptyString = function (value) { return exports.isString(value) && value.length > 0; };
exports.isSameLengthAs = curry(function (otherString, value) {
return isIndexedList(value) && isIndexedList(otherString) && value.length === otherString.length;
});
exports.isShorterThan = curry(function (otherString, value) {
return isIndexedList(value) && isIndexedList(otherString) && value.length < otherString.length;
});
exports.isLongerThan = curry(function (otherString, value) {
return isIndexedList(value) && isIndexedList(otherString) && value.length > otherString.length;
});
exports.hasMember = curry(function (key, value) { return exports.isString(key) && exports.isWalkable(value) && key in value; });
exports.isIso8601 = function (value) {
// '1999-12-31'
// '1999-12-31T23:59'
// '1999-12-31T23:59:59'
// '1999-12-31T23:59:59.000'
// '1999-12-31T23:59:59.000Z'
return (exports.isString(value) &&
(/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.test(value) ||
/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2})$/.test(value) ||
/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})$/.test(value) ||
/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})\.([0-9]{3})$/.test(value) ||
/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})\.([0-9]{3})Z$/.test(value)) &&
exports.isValidDate(new Date(value)));
};
exports.isJsonString = function (value) {
try {
return JSON.parse(value) !== null;
}
catch (err) {
return false;
}
};
exports.throwsAnyError = function (value) {
try {
value();
return false;
}
catch (err) {
return true;
}
};
exports.throwsErrorOfType = curry(function (type, value) {
try {
value();
return false;
}
catch (err) {
return err.name === type;
}
});
var ends_with_1 = require("./ends-with");
exports.endsWith = ends_with_1.endsWith;
var has_member_1 = require("./has-member");
exports.hasMember = has_member_1.hasMember;
var is_after_1 = require("./is-after");
exports.isAfter = is_after_1.isAfter;
var is_array_1 = require("./is-array");
exports.isArray = is_array_1.isArray;
var is_array_of_booleans_1 = require("./is-array-of-booleans");
exports.isArrayOfBooleans = is_array_of_booleans_1.isArrayOfBooleans;
var is_array_of_numbers_1 = require("./is-array-of-numbers");
exports.isArrayOfNumbers = is_array_of_numbers_1.isArrayOfNumbers;
var is_array_of_objects_1 = require("./is-array-of-objects");
exports.isArrayOfObjects = is_array_of_objects_1.isArrayOfObjects;
var is_array_of_size_1 = require("./is-array-of-size");
exports.isArrayOfSize = is_array_of_size_1.isArrayOfSize;
var is_array_of_strings_1 = require("./is-array-of-strings");
exports.isArrayOfStrings = is_array_of_strings_1.isArrayOfStrings;
var is_async_function_1 = require("./is-async-function");
exports.isAsyncFunction = is_async_function_1.isAsyncFunction;
var is_before_1 = require("./is-before");
exports.isBefore = is_before_1.isBefore;
var is_boolean_1 = require("./is-boolean");
exports.isBoolean = is_boolean_1.isBoolean;
var is_calculable_1 = require("./is-calculable");
exports.isCalculable = is_calculable_1.isCalculable;
var is_date_1 = require("./is-date");
exports.isDate = is_date_1.isDate;
var is_decimal_number_1 = require("./is-decimal-number");
exports.isDecimalNumber = is_decimal_number_1.isDecimalNumber;
var is_divisible_by_1 = require("./is-divisible-by");
exports.isDivisibleBy = is_divisible_by_1.isDivisibleBy;
var is_empty_array_1 = require("./is-empty-array");
exports.isEmptyArray = is_empty_array_1.isEmptyArray;
var is_empty_object_1 = require("./is-empty-object");
exports.isEmptyObject = is_empty_object_1.isEmptyObject;
var is_empty_string_1 = require("./is-empty-string");
exports.isEmptyString = is_empty_string_1.isEmptyString;
var is_even_number_1 = require("./is-even-number");
exports.isEvenNumber = is_even_number_1.isEvenNumber;
var is_false_1 = require("./is-false");
exports.isFalse = is_false_1.isFalse;
var is_function_1 = require("./is-function");
exports.isFunction = is_function_1.isFunction;
var is_generator_function_1 = require("./is-generator-function");
exports.isGeneratorFunction = is_generator_function_1.isGeneratorFunction;
var is_greater_than_or_equal_to_1 = require("./is-greater-than-or-equal-to");
exports.isGreaterThanOrEqualTo = is_greater_than_or_equal_to_1.isGreaterThanOrEqualTo;
var is_iso_8601_1 = require("./is-iso-8601");
exports.isIso8601 = is_iso_8601_1.isIso8601;
var is_json_string_1 = require("./is-json-string");
exports.isJsonString = is_json_string_1.isJsonString;
var is_less_than_or_equal_to_1 = require("./is-less-than-or-equal-to");
exports.isLessThanOrEqualTo = is_less_than_or_equal_to_1.isLessThanOrEqualTo;
var is_longer_than_1 = require("./is-longer-than");
exports.isLongerThan = is_longer_than_1.isLongerThan;
var is_near_1 = require("./is-near");
exports.isNear = is_near_1.isNear;
var is_non_empty_array_1 = require("./is-non-empty-array");
exports.isNonEmptyArray = is_non_empty_array_1.isNonEmptyArray;
var is_non_empty_object_1 = require("./is-non-empty-object");
exports.isNonEmptyObject = is_non_empty_object_1.isNonEmptyObject;
var is_non_empty_string_1 = require("./is-non-empty-string");
exports.isNonEmptyString = is_non_empty_string_1.isNonEmptyString;
var is_null_1 = require("./is-null");
exports.isNull = is_null_1.isNull;
var is_number_1 = require("./is-number");
exports.isNumber = is_number_1.isNumber;
var is_object_1 = require("./is-object");
exports.isObject = is_object_1.isObject;
var is_odd_number_1 = require("./is-odd-number");
exports.isOddNumber = is_odd_number_1.isOddNumber;
var is_reg_exp_1 = require("./is-reg-exp");
exports.isRegExp = is_reg_exp_1.isRegExp;
var is_same_length_as_1 = require("./is-same-length-as");
exports.isSameLengthAs = is_same_length_as_1.isSameLengthAs;
var is_shorter_than_1 = require("./is-shorter-than");
exports.isShorterThan = is_shorter_than_1.isShorterThan;
var is_string_1 = require("./is-string");
exports.isString = is_string_1.isString;
var is_true_1 = require("./is-true");
exports.isTrue = is_true_1.isTrue;
var is_undefined_1 = require("./is-undefined");
exports.isUndefined = is_undefined_1.isUndefined;
var is_valid_date_1 = require("./is-valid-date");
exports.isValidDate = is_valid_date_1.isValidDate;
var is_walkable_1 = require("./is-walkable");
exports.isWalkable = is_walkable_1.isWalkable;
var is_whitespace_1 = require("./is-whitespace");
exports.isWhitespace = is_whitespace_1.isWhitespace;
var is_whole_number_1 = require("./is-whole-number");
exports.isWholeNumber = is_whole_number_1.isWholeNumber;
var is_within_range_1 = require("./is-within-range");
exports.isWithinRange = is_within_range_1.isWithinRange;
var starts_with_1 = require("./starts-with");
exports.startsWith = starts_with_1.startsWith;
var throws_any_error_1 = require("./throws-any-error");
exports.throwsAnyError = throws_any_error_1.throwsAnyError;
var throws_error_of_type_1 = require("./throws-error-of-type");
exports.throwsErrorOfType = throws_error_of_type_1.throwsErrorOfType;

@@ -5,31 +5,1 @@ export declare type Collection = any[] | object;

export declare type Reducer = (memo: any, value: any, key: number | string, collection: Collection) => any;
export declare type ICurry1Arg<a, z> = (a: a) => z;
export interface ICurry2Args<a, b, z> {
(a: a, b: b): z;
(a: a): ICurry1Arg<b, z>;
}
export interface ICurry3Args<a, b, c, z> {
(a: a, b: b, c: c): z;
(a: a, b: b): ICurry1Arg<c, z>;
(a: a): ICurry2Args<b, c, z>;
}
export interface ICurry4Args<a, b, c, d, z> {
(a: a, b: b, c: c, d: d): z;
(a: a, b: b, c: c): ICurry1Arg<d, z>;
(a: a, b: b): ICurry2Args<c, d, z>;
(a: a): ICurry3Args<b, c, d, z>;
}
export interface ICurry5Args<a, b, c, d, e, z> {
(a: a, b: b, c: c, d: d, e: e): z;
(a: a, b: b, c: c, d: d): ICurry1Arg<e, z>;
(a: a, b: b, c: c): ICurry2Args<d, e, z>;
(a: a, b: b): ICurry3Args<c, d, e, z>;
(a: a): ICurry4Args<b, c, d, e, z>;
}
export interface ICurry {
<a, z>(f: (a: a) => z, ctx?: any): ICurry1Arg<a, z>;
<a, b, z>(f: (a: a, b: b) => z, ctx?: any): ICurry2Args<a, b, z>;
<a, b, c, z>(f: (a: a, b: b, c: c) => z, ctx?: any): ICurry3Args<a, b, c, z>;
<a, b, c, d, z>(f: (a: a, b: b, c: c, d: d) => z, ctx?: any): ICurry4Args<a, b, c, d, z>;
<a, b, c, d, e, z>(f: (a: a, b: b, c: c, d: d, e: e) => z, ctx?: any): ICurry5Args<a, b, c, d, e, z>;
}
{
"name": "expect-more",
"description": "Curried JavaScript Type Testing Library with Zero Dependencies",
"version": "0.5.5",
"version": "0.6.0",
"author": "Jamie Mason <jamie@foldleft.io> (https://github.com/JamieMason)",

@@ -18,4 +18,3 @@ "bugs": "https://github.com/JamieMason/expect-more/issues",

},
"typings": "./dist/index.d.ts",
"gitHead": "ced2b30b1e1270ae26adb1e2db7ba949a9756492"
"typings": "./dist/index.d.ts"
}

@@ -9,7 +9,2 @@ # expect-more

[![Maintainability](https://api.codeclimate.com/v1/badges/9f4abbef97ae0d23d97e/maintainability)](https://codeclimate.com/github/JamieMason/expect-more/maintainability)
[![Gitter Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/JamieMason/expect-more)
[![Donate via PayPal](https://img.shields.io/badge/donate-paypal-blue.svg)](https://www.paypal.me/foldleft)
[![Backers](https://opencollective.com/fold_left/backers/badge.svg)](https://opencollective.com/fold_left#backer)
[![Sponsors](https://opencollective.com/fold_left/sponsors/badge.svg)](https://opencollective.com/fold_left#sponsors)
[![Analytics](https://ga-beacon.appspot.com/UA-45466560-5/expect-more?flat&useReferer)](https://github.com/igrigorik/ga-beacon)
[![Follow JamieMason on GitHub](https://img.shields.io/github/followers/JamieMason.svg?style=social&label=Follow)](https://github.com/JamieMason)

@@ -62,3 +57,5 @@ [![Follow fold_left on Twitter](https://img.shields.io/twitter/follow/fold_left.svg?style=social&label=Follow)](https://twitter.com/fold_left)

- `isAsyncFunction: (value: any) => boolean`
- `isFunction: (value: any) => boolean`
- `isGeneratorFunction: (value: any) => boolean`
- `throwsAnyError: (value: () => void) => boolean`

@@ -65,0 +62,0 @@ - `throwsErrorOfType: (typeName: string, value: () => void) => boolean`

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc