Skip to content

Commit

Permalink
refactor(core): convert to named exports
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMason committed Dec 23, 2018
1 parent 15b22dd commit 4817738
Show file tree
Hide file tree
Showing 88 changed files with 334 additions and 336 deletions.
60 changes: 32 additions & 28 deletions src/asymmetricMatchersByName.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
export { default as after } from './toBeAfter';
export { default as arrayOfBooleans } from './toBeArrayOfBooleans';
export { default as arrayOfNumbers } from './toBeArrayOfNumbers';
export { default as arrayOfObjects } from './toBeArrayOfObjects';
export { default as arrayOfSize } from './toBeArrayOfSize';
export { default as arrayOfStrings } from './toBeArrayOfStrings';
export { default as before } from './toBeBefore';
export { default as calculable } from './toBeCalculable';
export { default as emptyArray } from './toBeEmptyArray';
export { default as emptyObject } from './toBeEmptyObject';
export { default as endingWith } from './toEndWith';
export { default as evenNumber } from './toBeEvenNumber';
export { default as greaterThanOrEqualTo } from './toBeGreaterThanOrEqualTo';
export { default as iso8601 } from './toBeIso8601';
export { default as jsonString } from './toBeJsonString';
export { default as lessThanOrEqualTo } from './toBeLessThanOrEqualTo';
export { default as longerThan } from './toBeLongerThan';
export { default as nonEmptyArray } from './toBeNonEmptyArray';
export { default as nonEmptyObject } from './toBeNonEmptyObject';
export { default as nonEmptyString } from './toBeNonEmptyString';
export { default as oddNumber } from './toBeOddNumber';
export { default as regExp } from './toBeRegExp';
export { default as sameLengthAs } from './toBeSameLengthAs';
export { default as shorterThan } from './toBeShorterThan';
export { default as startingWith } from './toStartWith';
export { default as whitespace } from './toBeWhitespace';
export { default as wholeNumber } from './toBeWholeNumber';
export { default as withinRange } from './toBeWithinRange';
export { toBeAfter as after } from './toBeAfter';
export { toBeArrayOfBooleans as arrayOfBooleans } from './toBeArrayOfBooleans';
export { toBeArrayOfNumbers as arrayOfNumbers } from './toBeArrayOfNumbers';
export { toBeArrayOfObjects as arrayOfObjects } from './toBeArrayOfObjects';
export { toBeArrayOfSize as arrayOfSize } from './toBeArrayOfSize';
export { toBeArrayOfStrings as arrayOfStrings } from './toBeArrayOfStrings';
export { toBeBefore as before } from './toBeBefore';
export { toBeCalculable as calculable } from './toBeCalculable';
export { toBeEmptyArray as emptyArray } from './toBeEmptyArray';
export { toBeEmptyObject as emptyObject } from './toBeEmptyObject';
export { toEndWith as endingWith } from './toEndWith';
export { toBeEvenNumber as evenNumber } from './toBeEvenNumber';
export {
toBeGreaterThanOrEqualTo as greaterThanOrEqualTo
} from './toBeGreaterThanOrEqualTo';
export { toBeIso8601 as iso8601 } from './toBeIso8601';
export { toBeJsonString as jsonString } from './toBeJsonString';
export {
toBeLessThanOrEqualTo as lessThanOrEqualTo
} from './toBeLessThanOrEqualTo';
export { toBeLongerThan as longerThan } from './toBeLongerThan';
export { toBeNonEmptyArray as nonEmptyArray } from './toBeNonEmptyArray';
export { toBeNonEmptyObject as nonEmptyObject } from './toBeNonEmptyObject';
export { toBeNonEmptyString as nonEmptyString } from './toBeNonEmptyString';
export { toBeOddNumber as oddNumber } from './toBeOddNumber';
export { toBeRegExp as regExp } from './toBeRegExp';
export { toBeSameLengthAs as sameLengthAs } from './toBeSameLengthAs';
export { toBeShorterThan as shorterThan } from './toBeShorterThan';
export { toStartWith as startingWith } from './toStartWith';
export { toBeWhitespace as whitespace } from './toBeWhitespace';
export { toBeWholeNumber as wholeNumber } from './toBeWholeNumber';
export { toBeWithinRange as withinRange } from './toBeWithinRange';
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import addMatchers from 'add-matchers';
import { addMatchers } from 'add-matchers';
import * as asymmetricMatchersByName from './asymmetricMatchersByName';
import * as matchersByName from './matchersByName';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/every.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default (array, truthTest) => {
export const every = (array, truthTest) => {
for (let i = 0, len = array.length; i < len; i++) {
if (!truthTest(array[i])) {
return false;
Expand Down
4 changes: 1 addition & 3 deletions src/lib/is.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const createIs = (type) => (value) =>
const createIsBooleanObject = (trueOrFalse) => (value) =>
is.Boolean(value) && value.valueOf() === trueOrFalse;

const is = {
export const is = {
Array: createIs('Array'),
Boolean: createIs('Boolean'),
Date: createIs('Date'),
Expand All @@ -14,5 +14,3 @@ const is = {
String: createIs('String'),
True: createIsBooleanObject(true)
};

export default is;
6 changes: 3 additions & 3 deletions src/lib/keys.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import reduce from './reduce';
import { reduce } from './reduce';

export default (object) =>
reduce(object, (keys, value, key) => keys.concat(key), []);
export const keys = (object) =>
reduce(object, (array, value, key) => array.concat(key), []);
4 changes: 2 additions & 2 deletions src/lib/memberMatcherFor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import is from './is';
import { is } from './is';

export default (toBeX) => (key, actual) =>
export const memberMatcherFor = (toBeX) => (key, actual) =>
is.Object(actual) && toBeX(actual[key]);
4 changes: 2 additions & 2 deletions src/lib/reduce.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import is from './is';
import { is } from './is';

export default (collection, fn, memo) => {
export const reduce = (collection, fn, memo) => {
if (is.Array(collection)) {
for (let i = 0, len = collection.length; i < len; i++) {
memo = fn(memo, collection[i], i, collection);
Expand Down
162 changes: 79 additions & 83 deletions src/matchersByName.ts
Original file line number Diff line number Diff line change
@@ -1,83 +1,79 @@
export { default as toBeAfter } from './toBeAfter';
export { default as toBeArray } from './toBeArray';
export { default as toBeArrayOfBooleans } from './toBeArrayOfBooleans';
export { default as toBeArrayOfNumbers } from './toBeArrayOfNumbers';
export { default as toBeArrayOfObjects } from './toBeArrayOfObjects';
export { default as toBeArrayOfSize } from './toBeArrayOfSize';
export { default as toBeArrayOfStrings } from './toBeArrayOfStrings';
export { default as toBeBefore } from './toBeBefore';
export { default as toBeBoolean } from './toBeBoolean';
export { default as toBeCalculable } from './toBeCalculable';
export { default as toBeDate } from './toBeDate';
export { default as toBeEmptyArray } from './toBeEmptyArray';
export { default as toBeEmptyObject } from './toBeEmptyObject';
export { default as toBeEmptyString } from './toBeEmptyString';
export { default as toBeEvenNumber } from './toBeEvenNumber';
export { default as toBeFalse } from './toBeFalse';
export { default as toBeFunction } from './toBeFunction';
export {
default as toBeGreaterThanOrEqualTo
} from './toBeGreaterThanOrEqualTo';
export { default as toBeHtmlString } from './toBeHtmlString';
export { default as toBeIso8601 } from './toBeIso8601';
export { default as toBeJsonString } from './toBeJsonString';
export { default as toBeLessThanOrEqualTo } from './toBeLessThanOrEqualTo';
export { default as toBeLongerThan } from './toBeLongerThan';
export { default as toBeNear } from './toBeNear';
export { default as toBeNonEmptyArray } from './toBeNonEmptyArray';
export { default as toBeNonEmptyObject } from './toBeNonEmptyObject';
export { default as toBeNonEmptyString } from './toBeNonEmptyString';
export { default as toBeNumber } from './toBeNumber';
export { default as toBeObject } from './toBeObject';
export { default as toBeOddNumber } from './toBeOddNumber';
export { default as toBeRegExp } from './toBeRegExp';
export { default as toBeSameLengthAs } from './toBeSameLengthAs';
export { default as toBeShorterThan } from './toBeShorterThan';
export { default as toBeString } from './toBeString';
export { default as toBeTrue } from './toBeTrue';
export { default as toBeValidDate } from './toBeValidDate';
export { default as toBeWhitespace } from './toBeWhitespace';
export { default as toBeWholeNumber } from './toBeWholeNumber';
export { default as toBeWithinRange } from './toBeWithinRange';
export { default as toEndWith } from './toEndWith';
export { default as toHaveArray } from './toHaveArray';
export { default as toHaveArrayOfBooleans } from './toHaveArrayOfBooleans';
export { default as toHaveArrayOfNumbers } from './toHaveArrayOfNumbers';
export { default as toHaveArrayOfObjects } from './toHaveArrayOfObjects';
export { default as toHaveArrayOfSize } from './toHaveArrayOfSize';
export { default as toHaveArrayOfStrings } from './toHaveArrayOfStrings';
export { default as toHaveBoolean } from './toHaveBoolean';
export { default as toHaveCalculable } from './toHaveCalculable';
export { default as toHaveDate } from './toHaveDate';
export { default as toHaveDateAfter } from './toHaveDateAfter';
export { default as toHaveDateBefore } from './toHaveDateBefore';
export { default as toHaveEmptyArray } from './toHaveEmptyArray';
export { default as toHaveEmptyObject } from './toHaveEmptyObject';
export { default as toHaveEmptyString } from './toHaveEmptyString';
export { default as toHaveEvenNumber } from './toHaveEvenNumber';
export { default as toHaveFalse } from './toHaveFalse';
export { default as toHaveHtmlString } from './toHaveHtmlString';
export { default as toHaveIso8601 } from './toHaveIso8601';
export { default as toHaveJsonString } from './toHaveJsonString';
export { default as toHaveMember } from './toHaveMember';
export { default as toHaveMethod } from './toHaveMethod';
export { default as toHaveNonEmptyArray } from './toHaveNonEmptyArray';
export { default as toHaveNonEmptyObject } from './toHaveNonEmptyObject';
export { default as toHaveNonEmptyString } from './toHaveNonEmptyString';
export { default as toHaveNumber } from './toHaveNumber';
export { default as toHaveNumberWithinRange } from './toHaveNumberWithinRange';
export { default as toHaveObject } from './toHaveObject';
export { default as toHaveOddNumber } from './toHaveOddNumber';
export { default as toHaveString } from './toHaveString';
export { default as toHaveStringLongerThan } from './toHaveStringLongerThan';
export {
default as toHaveStringSameLengthAs
} from './toHaveStringSameLengthAs';
export { default as toHaveStringShorterThan } from './toHaveStringShorterThan';
export { default as toHaveTrue } from './toHaveTrue';
export { default as toHaveUndefined } from './toHaveUndefined';
export { default as toHaveWhitespaceString } from './toHaveWhitespaceString';
export { default as toHaveWholeNumber } from './toHaveWholeNumber';
export { default as toStartWith } from './toStartWith';
export { default as toThrowAnyError } from './toThrowAnyError';
export { default as toThrowErrorOfType } from './toThrowErrorOfType';
export { toBeAfter } from './toBeAfter';
export { toBeArray } from './toBeArray';
export { toBeArrayOfBooleans } from './toBeArrayOfBooleans';
export { toBeArrayOfNumbers } from './toBeArrayOfNumbers';
export { toBeArrayOfObjects } from './toBeArrayOfObjects';
export { toBeArrayOfSize } from './toBeArrayOfSize';
export { toBeArrayOfStrings } from './toBeArrayOfStrings';
export { toBeBefore } from './toBeBefore';
export { toBeBoolean } from './toBeBoolean';
export { toBeCalculable } from './toBeCalculable';
export { toBeDate } from './toBeDate';
export { toBeEmptyArray } from './toBeEmptyArray';
export { toBeEmptyObject } from './toBeEmptyObject';
export { toBeEmptyString } from './toBeEmptyString';
export { toBeEvenNumber } from './toBeEvenNumber';
export { toBeFalse } from './toBeFalse';
export { toBeFunction } from './toBeFunction';
export { toBeGreaterThanOrEqualTo } from './toBeGreaterThanOrEqualTo';
export { toBeHtmlString } from './toBeHtmlString';
export { toBeIso8601 } from './toBeIso8601';
export { toBeJsonString } from './toBeJsonString';
export { toBeLessThanOrEqualTo } from './toBeLessThanOrEqualTo';
export { toBeLongerThan } from './toBeLongerThan';
export { toBeNear } from './toBeNear';
export { toBeNonEmptyArray } from './toBeNonEmptyArray';
export { toBeNonEmptyObject } from './toBeNonEmptyObject';
export { toBeNonEmptyString } from './toBeNonEmptyString';
export { toBeNumber } from './toBeNumber';
export { toBeObject } from './toBeObject';
export { toBeOddNumber } from './toBeOddNumber';
export { toBeRegExp } from './toBeRegExp';
export { toBeSameLengthAs } from './toBeSameLengthAs';
export { toBeShorterThan } from './toBeShorterThan';
export { toBeString } from './toBeString';
export { toBeTrue } from './toBeTrue';
export { toBeValidDate } from './toBeValidDate';
export { toBeWhitespace } from './toBeWhitespace';
export { toBeWholeNumber } from './toBeWholeNumber';
export { toBeWithinRange } from './toBeWithinRange';
export { toEndWith } from './toEndWith';
export { toHaveArray } from './toHaveArray';
export { toHaveArrayOfBooleans } from './toHaveArrayOfBooleans';
export { toHaveArrayOfNumbers } from './toHaveArrayOfNumbers';
export { toHaveArrayOfObjects } from './toHaveArrayOfObjects';
export { toHaveArrayOfSize } from './toHaveArrayOfSize';
export { toHaveArrayOfStrings } from './toHaveArrayOfStrings';
export { toHaveBoolean } from './toHaveBoolean';
export { toHaveCalculable } from './toHaveCalculable';
export { toHaveDate } from './toHaveDate';
export { toHaveDateAfter } from './toHaveDateAfter';
export { toHaveDateBefore } from './toHaveDateBefore';
export { toHaveEmptyArray } from './toHaveEmptyArray';
export { toHaveEmptyObject } from './toHaveEmptyObject';
export { toHaveEmptyString } from './toHaveEmptyString';
export { toHaveEvenNumber } from './toHaveEvenNumber';
export { toHaveFalse } from './toHaveFalse';
export { toHaveHtmlString } from './toHaveHtmlString';
export { toHaveIso8601 } from './toHaveIso8601';
export { toHaveJsonString } from './toHaveJsonString';
export { toHaveMember } from './toHaveMember';
export { toHaveMethod } from './toHaveMethod';
export { toHaveNonEmptyArray } from './toHaveNonEmptyArray';
export { toHaveNonEmptyObject } from './toHaveNonEmptyObject';
export { toHaveNonEmptyString } from './toHaveNonEmptyString';
export { toHaveNumber } from './toHaveNumber';
export { toHaveNumberWithinRange } from './toHaveNumberWithinRange';
export { toHaveObject } from './toHaveObject';
export { toHaveOddNumber } from './toHaveOddNumber';
export { toHaveString } from './toHaveString';
export { toHaveStringLongerThan } from './toHaveStringLongerThan';
export { toHaveStringSameLengthAs } from './toHaveStringSameLengthAs';
export { toHaveStringShorterThan } from './toHaveStringShorterThan';
export { toHaveTrue } from './toHaveTrue';
export { toHaveUndefined } from './toHaveUndefined';
export { toHaveWhitespaceString } from './toHaveWhitespaceString';
export { toHaveWholeNumber } from './toHaveWholeNumber';
export { toStartWith } from './toStartWith';
export { toThrowAnyError } from './toThrowAnyError';
export { toThrowErrorOfType } from './toThrowErrorOfType';
4 changes: 2 additions & 2 deletions src/toBeAfter.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import toBeBefore from './toBeBefore';
export default (otherDate, actual) => toBeBefore(actual, otherDate);
import { toBeBefore } from './toBeBefore';
export const toBeAfter = (otherDate, actual) => toBeBefore(actual, otherDate);
4 changes: 2 additions & 2 deletions src/toBeArray.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import is from './lib/is';
export default is.Array;
import { is } from './lib/is';
export const toBeArray = is.Array;
9 changes: 5 additions & 4 deletions src/toBeArrayOfBooleans.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import every from './lib/every';
import toBeArray from './toBeArray';
import toBeBoolean from './toBeBoolean';
export default (actual) => toBeArray(actual) && every(actual, toBeBoolean);
import { every } from './lib/every';
import { toBeArray } from './toBeArray';
import { toBeBoolean } from './toBeBoolean';
export const toBeArrayOfBooleans = (actual) =>
toBeArray(actual) && every(actual, toBeBoolean);
9 changes: 5 additions & 4 deletions src/toBeArrayOfNumbers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import every from './lib/every';
import toBeArray from './toBeArray';
import toBeNumber from './toBeNumber';
export default (actual) => toBeArray(actual) && every(actual, toBeNumber);
import { every } from './lib/every';
import { toBeArray } from './toBeArray';
import { toBeNumber } from './toBeNumber';
export const toBeArrayOfNumbers = (actual) =>
toBeArray(actual) && every(actual, toBeNumber);
9 changes: 5 additions & 4 deletions src/toBeArrayOfObjects.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import every from './lib/every';
import toBeArray from './toBeArray';
import toBeObject from './toBeObject';
export default (actual) => toBeArray(actual) && every(actual, toBeObject);
import { every } from './lib/every';
import { toBeArray } from './toBeArray';
import { toBeObject } from './toBeObject';
export const toBeArrayOfObjects = (actual) =>
toBeArray(actual) && every(actual, toBeObject);
5 changes: 3 additions & 2 deletions src/toBeArrayOfSize.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import toBeArray from './toBeArray';
export default (size, actual) => toBeArray(actual) && actual.length === size;
import { toBeArray } from './toBeArray';
export const toBeArrayOfSize = (size, actual) =>
toBeArray(actual) && actual.length === size;
9 changes: 5 additions & 4 deletions src/toBeArrayOfStrings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import every from './lib/every';
import toBeArray from './toBeArray';
import toBeString from './toBeString';
export default (actual) => toBeArray(actual) && every(actual, toBeString);
import { every } from './lib/every';
import { toBeArray } from './toBeArray';
import { toBeString } from './toBeString';
export const toBeArrayOfStrings = (actual) =>
toBeArray(actual) && every(actual, toBeString);
4 changes: 2 additions & 2 deletions src/toBeBefore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import toBeDate from './toBeDate';
import { toBeDate } from './toBeDate';

export default (otherDate, actual) =>
export const toBeBefore = (otherDate, actual) =>
toBeDate(actual) &&
toBeDate(otherDate) &&
actual.getTime() < otherDate.getTime();
4 changes: 2 additions & 2 deletions src/toBeBoolean.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import is from './lib/is';
export default is.Boolean;
import { is } from './lib/is';
export const toBeBoolean = is.Boolean;
6 changes: 1 addition & 5 deletions src/toBeCalculable.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export default toBeCalculable;

// Assert subject can be used in Mathemetic calculations despite not being a
// Number, for example `"1" * "2" === 2` whereas `"wut?" * 2 === NaN`.
function toBeCalculable(actual) {
export function toBeCalculable(actual) {
return !isNaN(actual * 2);
}
4 changes: 2 additions & 2 deletions src/toBeDate.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import is from './lib/is';
export default is.Date;
import { is } from './lib/is';
export const toBeDate = is.Date;
4 changes: 2 additions & 2 deletions src/toBeEmptyArray.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import toBeArrayOfSize from './toBeArrayOfSize';
export default (actual) => toBeArrayOfSize(0, actual);
import { toBeArrayOfSize } from './toBeArrayOfSize';
export const toBeEmptyArray = (actual) => toBeArrayOfSize(0, actual);
7 changes: 4 additions & 3 deletions src/toBeEmptyObject.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import is from './lib/is';
import keys from './lib/keys';
export default (actual) => is.Object(actual) && keys(actual).length === 0;
import { is } from './lib/is';
import { keys } from './lib/keys';
export const toBeEmptyObject = (actual) =>
is.Object(actual) && keys(actual).length === 0;
2 changes: 1 addition & 1 deletion src/toBeEmptyString.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default (actual) => actual === '';
export const toBeEmptyString = (actual) => actual === '';
5 changes: 3 additions & 2 deletions src/toBeEvenNumber.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import toBeNumber from './toBeNumber';
export default (actual) => toBeNumber(actual) && actual % 2 === 0;
import { toBeNumber } from './toBeNumber';
export const toBeEvenNumber = (actual) =>
toBeNumber(actual) && actual % 2 === 0;
4 changes: 2 additions & 2 deletions src/toBeFalse.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import is from './lib/is';
export default (actual) => actual === false || is.False(actual); // eslint-disable-line new-cap
import { is } from './lib/is';
export const toBeFalse = (actual) => actual === false || is.False(actual);
4 changes: 2 additions & 2 deletions src/toBeFunction.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import is from './lib/is';
export default is.Function;
import { is } from './lib/is';
export const toBeFunction = is.Function;
4 changes: 2 additions & 2 deletions src/toBeGreaterThanOrEqualTo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import toBeNumber from './toBeNumber';
import { toBeNumber } from './toBeNumber';

export default (otherNumber, actual) =>
export const toBeGreaterThanOrEqualTo = (otherNumber, actual) =>
toBeNumber(actual) && actual >= otherNumber;
Loading

0 comments on commit 4817738

Please sign in to comment.