Skip to content

Instantly share code, notes, and snippets.

@indongyoo
Last active April 3, 2018 12:12
Show Gist options
  • Select an option

  • Save indongyoo/abbfd5437c13ff75b9ca22593560a29c to your computer and use it in GitHub Desktop.

Select an option

Save indongyoo/abbfd5437c13ff75b9ca22593560a29c to your computer and use it in GitHub Desktop.
const { isMatch } = Functional;
console.log( isMatch({ a: 1 }, { a: 1, b: 2 }) ); // true
console.log( isMatch([2], [1, 2, 3]) ); // true
console.log( isMatch(5, 5) ); // true
console.log( isMatch("a", "a") ); // true
console.log( isMatch({ a: 1, b: 3 }, { a: 1, b: 2 }) ); // false
console.log( isMatch(5, 50) ); // false
console.log( isMatch("a", "aaa") ); // false
console.log( isMatch(b => b.includes("a"), "aaa") ); // true
match ({ a: 1, b: 2 })
.case({ a: 2 }) (_=> console.log('여기 아니고 1'))
.case({ b: 3 }) (_=> console.log('여기 아니고 2'))
.case([2]) (_=> console.log('여기 아니고 3'))
.case(2) (_=> console.log('여기 아니고 4'))
.case({ b: 2 }) (_=> console.log('여기'))
.else (_=> console.log('여기 아니고 5'));
// 여기
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment