Skip to content

Instantly share code, notes, and snippets.

@al6x
Created May 12, 2025 04:46
Show Gist options
  • Save al6x/21e37189c8274e728e78fdfa0a60d642 to your computer and use it in GitHub Desktop.
Save al6x/21e37189c8274e728e78fdfa0a60d642 to your computer and use it in GitHub Desktop.
import './base'
p_([1, 2, 2].empty7()) // => false
p_([[2], [1]].sort_()) // => [[1], [2]]
p_([[1], [1]].uniq_()) // => [[1]]
p_(equal7([1], [1])) // => true
p_([1, 2, 3].median_()) // => 2
p_([1, 2, 3].min_()) // => 1
p_("a b c".match7(/b/)) // => true
p_("a".upcase_()) // => "A"
p_(1.001.round_()) // => 1
p_(aqual7(1, 1.0001)) // => true
p_(aqual7([1], [1.0001])) // => true
// Various collection methods
p_(['a1', 'a2', 'b1'].group_by_(s => s[0])) // => Hash({ a: ['a1', 'a2'], b: ['b1'] })
// No `new` keyword needed and constructors improved
const s = Set('a', 'b') // vs `new Set(['a', 'b'])`
const m = Map({ a: 1, b: 2 }) // vs `new Map([['a', 1], ['b', 2]])`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment