Skip to content

Commit

Permalink
Re-enable Array#groupToMap shim
Browse files Browse the repository at this point in the history
  • Loading branch information
darrylyeo committed May 26, 2023
1 parent 443c4f6 commit 474959f
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/routes/+layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ globalThis.process = process
// Shims

// import shimArrayPrototypeGroup from 'array.prototype.group'
// import shimArrayPrototypeGroupToMap from 'array.prototype.grouptomap'
import shimArrayPrototypeGroupToMap from 'array.prototype.grouptomap'

// shimArrayPrototypeGroup.shim()
// shimArrayPrototypeGroupToMap.shim()

Array.prototype.groupToMap ||= function(callbackFn, _this = this){
const map = new Map()
for (const item of _this) {
const key = callbackFn(item)
const group = map.get(key) || []
group.push(item)
map.set(key, group)
}
return map
}
shimArrayPrototypeGroupToMap.shim()

// Array.prototype.groupToMap ||= function(callbackFn, _this = this){
// const map = new Map()
// for (const item of _this) {
// const key = callbackFn(item)
// const group = map.get(key) || []
// group.push(item)
// map.set(key, group)
// }
// return map
// }


// SvelteKit
Expand Down

0 comments on commit 474959f

Please sign in to comment.