Skip to content

Commit

Permalink
Merge pull request #22 from TomokiMiyauci/beta
Browse files Browse the repository at this point in the history
Beta
  • Loading branch information
TomokiMiyauci authored Jun 2, 2021
2 parents 34e67ce + d991024 commit df7d350
Show file tree
Hide file tree
Showing 11 changed files with 221 additions and 92 deletions.
39 changes: 18 additions & 21 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
{
// IntelliSense を使用して利用可能な属性を学べます。
// 既存の属性の説明をホバーして表示します。
// 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Deno",
"request": "launch",
"type": "pwa-node",
"program": "${file}",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": [
"run",
"--unstable",
"--inspect",
"--allow-all"
],
"attachSimplePort": 9229
}
]
"version": "0.2.0",
"configurations": [
{
"name": "Deno",
"request": "launch",
"type": "pwa-node",
"program": "${file}",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": [
"run",
"--unstable",
"--inspect",
"--allow-all"
],
"attachSimplePort": 9229
}
]
}
145 changes: 111 additions & 34 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,118 +1,195 @@
# [v1.4.1-beta.1](https://github.com/TomokiMiyauci/equal/compare/v1.4.0...v1.4.1-beta.1) (2021-06-02)

## 🐛 Bug Fixes
- [`e614a09`](https://github.com/TomokiMiyauci/equal/commit/e614a09) Improve performance to break on the way

# [v1.4.0-beta.3](https://github.com/TomokiMiyauci/equal/compare/v1.4.0-beta.2...v1.4.0-beta.3) (2021-06-02)

## 🐛 Bug Fixes

- [`e614a09`](https://github.com/TomokiMiyauci/equal/commit/e614a09) Improve
performance to break on the way

# [v1.4.0](https://github.com/TomokiMiyauci/equal/compare/v1.3.0...v1.4.0) (2021-06-01)

## ✨ New Features
- [`ffe286c`](https://github.com/TomokiMiyauci/equal/commit/ffe286c) Add equality of Int8Array (Issues: [`#16`](https://github.com/TomokiMiyauci/equal/issues/16))
- [`abbc99a`](https://github.com/TomokiMiyauci/equal/commit/abbc99a) Add equality of UIint8Array (Issues: [`#17`](https://github.com/TomokiMiyauci/equal/issues/17))
- [`495666e`](https://github.com/TomokiMiyauci/equal/commit/495666e) Add equality of Uint8ClampedArray (Issues: [`#18`](https://github.com/TomokiMiyauci/equal/issues/18))
- [`439993b`](https://github.com/TomokiMiyauci/equal/commit/439993b) Add equality of TypedArray (Issues: [`#19`](https://github.com/TomokiMiyauci/equal/issues/19))
- [`dfb37b4`](https://github.com/TomokiMiyauci/equal/commit/dfb37b4) Add equality of ArrayBuffer (Issues: [`#20`](https://github.com/TomokiMiyauci/equal/issues/20))

- [`ffe286c`](https://github.com/TomokiMiyauci/equal/commit/ffe286c) Add
equality of Int8Array (Issues:
[`#16`](https://github.com/TomokiMiyauci/equal/issues/16))
- [`abbc99a`](https://github.com/TomokiMiyauci/equal/commit/abbc99a) Add
equality of UIint8Array (Issues:
[`#17`](https://github.com/TomokiMiyauci/equal/issues/17))
- [`495666e`](https://github.com/TomokiMiyauci/equal/commit/495666e) Add
equality of Uint8ClampedArray (Issues:
[`#18`](https://github.com/TomokiMiyauci/equal/issues/18))
- [`439993b`](https://github.com/TomokiMiyauci/equal/commit/439993b) Add
equality of TypedArray (Issues:
[`#19`](https://github.com/TomokiMiyauci/equal/issues/19))
- [`dfb37b4`](https://github.com/TomokiMiyauci/equal/commit/dfb37b4) Add
equality of ArrayBuffer (Issues:
[`#20`](https://github.com/TomokiMiyauci/equal/issues/20))

# [v1.4.0-beta.2](https://github.com/TomokiMiyauci/equal/compare/v1.4.0-beta.1...v1.4.0-beta.2) (2021-05-31)

## ✨ New Features
- [`dfb37b4`](https://github.com/TomokiMiyauci/equal/commit/dfb37b4) Add equality of ArrayBuffer (Issues: [`#20`](https://github.com/TomokiMiyauci/equal/issues/20))

- [`dfb37b4`](https://github.com/TomokiMiyauci/equal/commit/dfb37b4) Add
equality of ArrayBuffer (Issues:
[`#20`](https://github.com/TomokiMiyauci/equal/issues/20))

# [v1.4.0-beta.1](https://github.com/TomokiMiyauci/equal/compare/v1.3.0...v1.4.0-beta.1) (2021-05-31)

## ✨ New Features
- [`ffe286c`](https://github.com/TomokiMiyauci/equal/commit/ffe286c) Add equality of Int8Array (Issues: [`#16`](https://github.com/TomokiMiyauci/equal/issues/16))
- [`abbc99a`](https://github.com/TomokiMiyauci/equal/commit/abbc99a) Add equality of UIint8Array (Issues: [`#17`](https://github.com/TomokiMiyauci/equal/issues/17))
- [`495666e`](https://github.com/TomokiMiyauci/equal/commit/495666e) Add equality of Uint8ClampedArray (Issues: [`#18`](https://github.com/TomokiMiyauci/equal/issues/18))
- [`439993b`](https://github.com/TomokiMiyauci/equal/commit/439993b) Add equality of TypedArray (Issues: [`#19`](https://github.com/TomokiMiyauci/equal/issues/19))

- [`ffe286c`](https://github.com/TomokiMiyauci/equal/commit/ffe286c) Add
equality of Int8Array (Issues:
[`#16`](https://github.com/TomokiMiyauci/equal/issues/16))
- [`abbc99a`](https://github.com/TomokiMiyauci/equal/commit/abbc99a) Add
equality of UIint8Array (Issues:
[`#17`](https://github.com/TomokiMiyauci/equal/issues/17))
- [`495666e`](https://github.com/TomokiMiyauci/equal/commit/495666e) Add
equality of Uint8ClampedArray (Issues:
[`#18`](https://github.com/TomokiMiyauci/equal/issues/18))
- [`439993b`](https://github.com/TomokiMiyauci/equal/commit/439993b) Add
equality of TypedArray (Issues:
[`#19`](https://github.com/TomokiMiyauci/equal/issues/19))

# [v1.3.0](https://github.com/TomokiMiyauci/equal/compare/v1.2.0...v1.3.0) (2021-05-31)

## ✨ New Features
- [`90c2572`](https://github.com/TomokiMiyauci/equal/commit/90c2572) No bundle external dependency for bundle size, change outputs
- [`7e59ff1`](https://github.com/TomokiMiyauci/equal/commit/7e59ff1) Add equality of URL object
- [`fd81dc6`](https://github.com/TomokiMiyauci/equal/commit/fd81dc6) Add equality of URLSearchParams

- [`90c2572`](https://github.com/TomokiMiyauci/equal/commit/90c2572) No bundle
external dependency for bundle size, change outputs
- [`7e59ff1`](https://github.com/TomokiMiyauci/equal/commit/7e59ff1) Add
equality of URL object
- [`fd81dc6`](https://github.com/TomokiMiyauci/equal/commit/fd81dc6) Add
equality of URLSearchParams

# [v1.3.0-beta.2](https://github.com/TomokiMiyauci/equal/compare/v1.3.0-beta.1...v1.3.0-beta.2) (2021-05-31)

## ✨ New Features
- [`7e59ff1`](https://github.com/TomokiMiyauci/equal/commit/7e59ff1) Add equality of URL object
- [`fd81dc6`](https://github.com/TomokiMiyauci/equal/commit/fd81dc6) Add equality of URLSearchParams

- [`7e59ff1`](https://github.com/TomokiMiyauci/equal/commit/7e59ff1) Add
equality of URL object
- [`fd81dc6`](https://github.com/TomokiMiyauci/equal/commit/fd81dc6) Add
equality of URLSearchParams

# [v1.3.0-beta.1](https://github.com/TomokiMiyauci/equal/compare/v1.2.0...v1.3.0-beta.1) (2021-05-30)

## ✨ New Features
- [`90c2572`](https://github.com/TomokiMiyauci/equal/commit/90c2572) No bundle external dependency for bundle size, change outputs

- [`90c2572`](https://github.com/TomokiMiyauci/equal/commit/90c2572) No bundle
external dependency for bundle size, change outputs

# [v1.2.0](https://github.com/TomokiMiyauci/equal/compare/v1.1.0...v1.2.0) (2021-05-25)

## ✨ New Features
- [`60874d1`](https://github.com/TomokiMiyauci/equal/commit/60874d1) Add a feature of judge Set object correctly (Issues: [`#8`](https://github.com/TomokiMiyauci/equal/issues/8))
- [`6f6a490`](https://github.com/TomokiMiyauci/equal/commit/6f6a490) Add feature of equality all built-in Errors (Issues: [`#9`](https://github.com/TomokiMiyauci/equal/issues/9))
- [`db6f997`](https://github.com/TomokiMiyauci/equal/commit/db6f997) Add equality of AggregateError (Issues: [`#9`](https://github.com/TomokiMiyauci/equal/issues/9))

- [`60874d1`](https://github.com/TomokiMiyauci/equal/commit/60874d1) Add a
feature of judge Set object correctly (Issues:
[`#8`](https://github.com/TomokiMiyauci/equal/issues/8))
- [`6f6a490`](https://github.com/TomokiMiyauci/equal/commit/6f6a490) Add feature
of equality all built-in Errors (Issues:
[`#9`](https://github.com/TomokiMiyauci/equal/issues/9))
- [`db6f997`](https://github.com/TomokiMiyauci/equal/commit/db6f997) Add
equality of AggregateError (Issues:
[`#9`](https://github.com/TomokiMiyauci/equal/issues/9))

# [v1.2.0-beta.3](https://github.com/TomokiMiyauci/equal/compare/v1.2.0-beta.2...v1.2.0-beta.3) (2021-05-25)

## ✨ New Features
- [`db6f997`](https://github.com/TomokiMiyauci/equal/commit/db6f997) Add equality of AggregateError (Issues: [`#9`](https://github.com/TomokiMiyauci/equal/issues/9))

- [`db6f997`](https://github.com/TomokiMiyauci/equal/commit/db6f997) Add
equality of AggregateError (Issues:
[`#9`](https://github.com/TomokiMiyauci/equal/issues/9))

# [v1.2.0-beta.2](https://github.com/TomokiMiyauci/equal/compare/v1.2.0-beta.1...v1.2.0-beta.2) (2021-05-25)

## ✨ New Features
- [`6f6a490`](https://github.com/TomokiMiyauci/equal/commit/6f6a490) Add feature of equality all built-in Errors (Issues: [`#9`](https://github.com/TomokiMiyauci/equal/issues/9))

- [`6f6a490`](https://github.com/TomokiMiyauci/equal/commit/6f6a490) Add feature
of equality all built-in Errors (Issues:
[`#9`](https://github.com/TomokiMiyauci/equal/issues/9))

# [v1.2.0-beta.1](https://github.com/TomokiMiyauci/equal/compare/v1.1.0...v1.2.0-beta.1) (2021-05-25)

## ✨ New Features
- [`60874d1`](https://github.com/TomokiMiyauci/equal/commit/60874d1) Add a feature of judge Set object correctly (Issues: [`#8`](https://github.com/TomokiMiyauci/equal/issues/8))

- [`60874d1`](https://github.com/TomokiMiyauci/equal/commit/60874d1) Add a
feature of judge Set object correctly (Issues:
[`#8`](https://github.com/TomokiMiyauci/equal/issues/8))

# [v1.1.0](https://github.com/TomokiMiyauci/equal/compare/v1.0.2...v1.1.0) (2021-05-24)

## ✨ New Features
- [`c321ef6`](https://github.com/TomokiMiyauci/equal/commit/c321ef6) Add equality of Map does not use Object for key
- [`0a54101`](https://github.com/TomokiMiyauci/equal/commit/0a54101) Changed to work with Object key in Map

- [`c321ef6`](https://github.com/TomokiMiyauci/equal/commit/c321ef6) Add
equality of Map does not use Object for key
- [`0a54101`](https://github.com/TomokiMiyauci/equal/commit/0a54101) Changed to
work with Object key in Map

# [v1.1.0-beta.2](https://github.com/TomokiMiyauci/equal/compare/v1.1.0-beta.1...v1.1.0-beta.2) (2021-05-24)

## ✨ New Features
- [`0a54101`](https://github.com/TomokiMiyauci/equal/commit/0a54101) Changed to work with Object key in Map

- [`0a54101`](https://github.com/TomokiMiyauci/equal/commit/0a54101) Changed to
work with Object key in Map

# [v1.1.0-beta.1](https://github.com/TomokiMiyauci/equal/compare/v1.0.2...v1.1.0-beta.1) (2021-05-24)

## ✨ New Features
- [`c321ef6`](https://github.com/TomokiMiyauci/equal/commit/c321ef6) Add equality of Map does not use Object for key

- [`c321ef6`](https://github.com/TomokiMiyauci/equal/commit/c321ef6) Add
equality of Map does not use Object for key

# [v1.0.2](https://github.com/TomokiMiyauci/equal/compare/v1.0.1...v1.0.2) (2021-05-14)

## 🐛 Bug Fixes
- [`7f45fd5`](https://github.com/TomokiMiyauci/equal/commit/7f45fd5) Optimize bundle size with ES modules

- [`7f45fd5`](https://github.com/TomokiMiyauci/equal/commit/7f45fd5) Optimize
bundle size with ES modules

# [v1.0.2-beta.1](https://github.com/TomokiMiyauci/equal/compare/v1.0.1...v1.0.2-beta.1) (2021-05-14)

## 🐛 Bug Fixes
- [`7f45fd5`](https://github.com/TomokiMiyauci/equal/commit/7f45fd5) Optimize bundle size with ES modules

- [`7f45fd5`](https://github.com/TomokiMiyauci/equal/commit/7f45fd5) Optimize
bundle size with ES modules

# [v1.0.1-beta.2](https://github.com/TomokiMiyauci/equal/compare/v1.0.1-beta.1...v1.0.1-beta.2) (2021-05-14)

## 🐛 Bug Fixes

- [`7f45fd5`](https://github.com/TomokiMiyauci/equal/commit/7f45fd5) Optimize bundle size with ES modules
- [`7f45fd5`](https://github.com/TomokiMiyauci/equal/commit/7f45fd5) Optimize
bundle size with ES modules

# [v1.0.1-beta.1](https://github.com/TomokiMiyauci/equal/compare/v1.0.0...v1.0.1-beta.1) (2021-05-14)

## 🐛 Bug Fixes

- [`a1e346e`](https://github.com/TomokiMiyauci/equal/commit/a1e346e) Equal to same value zero
- [`a1e346e`](https://github.com/TomokiMiyauci/equal/commit/a1e346e) Equal to
same value zero

# v1.0.0 (2021-05-14)

## ✨ New Features

- [`1f1ec53`](https://github.com/TomokiMiyauci/equal/commit/1f1ec53) Add equal function with basic test case
- [`f9dedbe`](https://github.com/TomokiMiyauci/equal/commit/f9dedbe) Add feature of asserting Number, String and Boolean object
- [`1f1ec53`](https://github.com/TomokiMiyauci/equal/commit/1f1ec53) Add equal
function with basic test case
- [`f9dedbe`](https://github.com/TomokiMiyauci/equal/commit/f9dedbe) Add feature
of asserting Number, String and Boolean object

# [v1.0.0-beta.2](https://github.com/TomokiMiyauci/equal/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2021-05-14)

## ✨ New Features

- [`f9dedbe`](https://github.com/TomokiMiyauci/equal/commit/f9dedbe) Add feature of asserting Number, String and Boolean object
- [`f9dedbe`](https://github.com/TomokiMiyauci/equal/commit/f9dedbe) Add feature
of asserting Number, String and Boolean object

# v1.0.0-beta.1 (2021-05-13)

## ✨ New Features

- [`1f1ec53`](https://github.com/TomokiMiyauci/equal/commit/1f1ec53) Add equal function with basic test case
- [`1f1ec53`](https://github.com/TomokiMiyauci/equal/commit/1f1ec53) Add equal
function with basic test case
24 changes: 8 additions & 16 deletions _is.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
// Copyright 2021-present the Equal authors. All rights reserved. MIT license.
import {
and,
ifElse,
isArray,
isFunction,
isJSONObject,
isNumber,
isObject,
isPrimitive,
N,
} from "./deps.ts";
import type { AnyFn } from "./deps.ts";

const isTupleFactory = (fn: AnyFn) =>
<T, U extends T>(a: T, b: U) => [fn(a) as boolean, fn(b) as boolean] as const;
const isTupleFactory = (fn: AnyFn<any, boolean>) =>
<T, U extends T>(a: T, b: U): boolean => and(fn(a), () => fn(b));

const isObjectExcludeJSON = (val: unknown): val is Record<string, unknown> =>
and(isObject(val), () => N(isJSONObject(val)));

const instanceofFactory = (obj: Function) =>
<T, U extends T>(a: T, b: U) => [a instanceof obj, b instanceof obj] as const;
<T, U extends T>(a: T, b: U): boolean =>
and(a instanceof obj, () => b instanceof obj);

const isBothNumber = isTupleFactory(isNumber);
const isBothPrimitive = isTupleFactory(isPrimitive);
const isBothArray = isTupleFactory(isArray);
const isBothFunction = isTupleFactory(isFunction);
const isBothJSONObject = isTupleFactory(isJSONObject);
const isBothPrimitive = isTupleFactory(isPrimitive);
const isBothObjectExcludeJSON = isTupleFactory(isObjectExcludeJSON);
const isBothDate = instanceofFactory(Date);
const isBothRegExp = instanceofFactory(RegExp);
Expand All @@ -35,8 +33,8 @@ const isBothSet = instanceofFactory(Set);
const isBothURL = instanceofFactory(URL);
const isBothArrayBuffer = instanceofFactory(ArrayBuffer);
const isBothURLSearchParams = instanceofFactory(URLSearchParams);
const isBothTypedArray = <T, U extends T>(a: T, b: U): [boolean, boolean] => {
const result = [
const isBothTypedArray = <T, U extends T>(a: T, b: U): boolean => {
return [
Int8Array,
Uint8Array,
Uint8ClampedArray,
Expand All @@ -49,12 +47,7 @@ const isBothTypedArray = <T, U extends T>(a: T, b: U): [boolean, boolean] => {
BigInt64Array,
BigUint64Array,
]
.some((obj) => {
const [f1, f2] = instanceofFactory(obj)(a, b);
return and(f1, f2);
});

return ifElse(result, [true, true], [false, false]);
.some((obj) => instanceofFactory(obj)(a, b));
};

export {
Expand All @@ -65,7 +58,6 @@ export {
isBothFunction,
isBothJSONObject,
isBothMap,
isBothNumber,
isBothObjectExcludeJSON,
isBothPrimitive,
isBothRegExp,
Expand Down
10 changes: 8 additions & 2 deletions deps.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2021-present the Equal authors. All rights reserved. MIT license.
export {
and,
constructorName,
entries,
F,
has,
Expand All @@ -10,14 +11,19 @@ export {
isBoolean,
isFunction,
isJSONObject,
isNil,
isNumber,
isObject,
isPrimitive,
isSymbol,
length,
N,
not,
or,
xor,
} from "https://deno.land/x/[email protected].6/mod.ts";
} from "https://deno.land/x/[email protected].7/mod.ts";

export type { AnyFn } from "https://deno.land/x/[email protected]/mod.ts";
export type {
AnyFn,
Primitive,
} from "https://deno.land/x/[email protected]/mod.ts";
1 change: 1 addition & 0 deletions dev_deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export {
assertEquals,
} from "https://deno.land/[email protected]/testing/asserts.ts";
export { isSymbol } from "./deps.ts";
export type { Primitive } from "./deps.ts";
Loading

0 comments on commit df7d350

Please sign in to comment.