Skip to content

Commit

Permalink
Continue to wire-up inlined overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Oct 18, 2024
1 parent 6c3bbd4 commit e279756
Show file tree
Hide file tree
Showing 16 changed files with 274 additions and 35 deletions.
6 changes: 5 additions & 1 deletion packages/npm/assert/overrides/call-bind/callBound.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
declare function callBoundIntrinsic(
name: 'RegExp.prototype.test',
allowMissing?: boolean
): (regex: RegExp, str: string) => boolean
): (regex: RegExp, str: string) => ReturnType<typeof RegExp.prototype.test>
declare function callBoundIntrinsic(
name: string,
allowMissing?: boolean
): undefined
export = callBoundIntrinsic
5 changes: 4 additions & 1 deletion packages/npm/assert/overrides/call-bind/callBound.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
'use strict'

const { apply: ReflectApply } = Reflect
const { test: RegExpProtoTest } = RegExp.prototype

function regExpProtoTest(regex, str) {
return regex.test(str)
return ReflectApply(RegExpProtoTest, regex, [str])
}

module.exports = function callBoundIntrinsic(name, _allowMissing) {
Expand Down
2 changes: 1 addition & 1 deletion packages/npm/assert/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"files": [
"*.d.ts",
"**/*.js",
"!overrides/**/{*.d.ts,index.js}"
"!overrides/call-bind/{*.d.ts,index.js}"
],
"socket": {
"categories": [
Expand Down
21 changes: 21 additions & 0 deletions packages/npm/deep-equal/overrides/call-bind/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Socket Inc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
21 changes: 21 additions & 0 deletions packages/npm/deep-equal/overrides/call-bind/LICENSE.original
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Jordan Harband

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
45 changes: 45 additions & 0 deletions packages/npm/deep-equal/overrides/call-bind/callBound.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
declare function callBoundIntrinsic(
name: 'Date.prototype.getTime',
allowMissing?: boolean
): (date: Date) => ReturnType<typeof Date.prototype.getTime>
declare function callBoundIntrinsic(
name: 'Map.prototype.get',
allowMissing?: boolean
): (map: Map<any, any>, key: any) => ReturnType<typeof Map.prototype.get>
declare function callBoundIntrinsic(
name: 'Map.prototype.has',
allowMissing?: boolean
): (map: Map<any, any>, key: any) => ReturnType<typeof Map.prototype.has>
declare function callBoundIntrinsic(
name: 'Map.prototype.size',
allowMissing?: boolean
): (map: Map<any, any>) => typeof Map.prototype.size
declare function callBoundIntrinsic(
name: 'Object.prototype.toString',
allowMissing?: boolean
): (obj: any) => ReturnType<typeof Object.prototype.toString>
declare function callBoundIntrinsic(
name: 'Set.prototype.add',
allowMissing?: boolean
): (set: Set<any>, value: any) => ReturnType<typeof Set.prototype.add>
declare function callBoundIntrinsic(
name: 'Set.prototype.delete',
allowMissing?: boolean
): (set: Set<any>, value: any) => ReturnType<typeof Set.prototype.delete>
declare function callBoundIntrinsic(
name: 'Set.prototype.has',
allowMissing?: boolean
): (set: Set<any>, value: any) => ReturnType<typeof Set.prototype.has>
declare function callBoundIntrinsic(
name: 'Set.prototype.size',
allowMissing?: boolean
): (set: Set<any>) => typeof Set.prototype.size
declare function callBoundIntrinsic(
name: 'SharedArrayBuffer.prototype.byteLength',
allowMissing?: boolean
): (sab: SharedArrayBuffer) => typeof SharedArrayBuffer.prototype.byteLength
declare function callBoundIntrinsic(
name: string,
allowMissing?: boolean
): undefined
export = callBoundIntrinsic
72 changes: 45 additions & 27 deletions packages/npm/deep-equal/overrides/call-bind/callBound.js
Original file line number Diff line number Diff line change
@@ -1,63 +1,81 @@
'use strict'

const { getTime: DateProtoGetTime } = Date.prototype
const { get: MapProtoGet, has: MapProtoHas } = Map.prototype
const MapProtoSizeGetter = Map.prototype.__lookupGetter__('size')
const { toString: objToStr } = Object.prototype

function noop() {}
const { apply: ReflectApply } = Reflect
const {
add: SetProtoAdd,
delete: SetProtoDelete,
has: SetProtoHas
} = Set.prototype
const SetProtoSizeGetter = Set.prototype.__lookupGetter__('size')
const SharedArrayBufferByteLengthGetter =
SharedArrayBuffer.prototype.__lookupGetter__('byteLength')

function dateProtoGetTime(date) {
return date.getTime()
}

function mapOrSetProtoDelete(mos, key) {
return mos.delete(key)
return ReflectApply(DateProtoGetTime, date, [])
}

function mapOrSetProtoHas(mos, key) {
return mos.has(key)
function mapProtoGet(map, key) {
return ReflectApply(MapProtoGet, map, [key])
}

function mapOrSetProtoGet(mos, key) {
return mos.get(key)
function mapProtoHas(map, key) {
return ReflectApply(MapProtoHas, map, [key])
}

function mapOrSetProtoSize(mos) {
return mos.size
function mapProtoSize(map) {
return ReflectApply(MapProtoSizeGetter, map, [])
}

function objectProtoToString(object) {
return objToStr.call(object)
return ReflectApply(objToStr, object, [])
}

function sabProtoByteLength(sab) {
return sab.byteLength
function sharedArrayBufferProtoByteLength(sab) {
return ReflectApply(SharedArrayBufferByteLengthGetter, sab, [])
}

function setProtoAdd(set, value) {
return set.add(value)
return ReflectApply(SetProtoAdd, set, [value])
}

function setProtoDelete(set, key) {
return ReflectApply(SetProtoDelete, set, [key])
}

function setProtoHas(set, key) {
return ReflectApply(SetProtoHas, set, [key])
}

function setProtoSize(set) {
return ReflectApply(SetProtoSizeGetter, set, [])
}

module.exports = function callBoundIntrinsic(name, _allowMissing) {
switch (name) {
case 'Date.prototype.getTime':
return dateProtoGetTime
case 'Map.prototype.has':
return mapOrSetProtoHas
case 'Map.prototype.get':
return mapOrSetProtoGet
return mapProtoGet
case 'Map.prototype.has':
return mapProtoHas
case 'Map.prototype.size':
return mapOrSetProtoSize
return mapProtoSize
case 'Object.prototype.toString':
return objectProtoToString
case 'SharedArrayBuffer.prototype.byteLength':
return sabProtoByteLength
case 'Set.prototype.add':
return setProtoAdd
case 'Set.prototype.delete':
return mapOrSetProtoDelete
return setProtoDelete
case 'Set.prototype.has':
return mapOrSetProtoHas
return setProtoHas
case 'Set.prototype.size':
return mapOrSetProtoSize
return setProtoSize
case 'SharedArrayBuffer.prototype.byteLength':
return sharedArrayBufferProtoByteLength
}
return noop
return undefined
}
1 change: 1 addition & 0 deletions packages/npm/deep-equal/overrides/call-bind/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* empty */
1 change: 1 addition & 0 deletions packages/npm/deep-equal/overrides/call-bind/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* empty */
39 changes: 39 additions & 0 deletions packages/npm/deep-equal/overrides/call-bind/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "@socketregistry/deep-equal",
"version": "1.0.3-overrides-call-bind",
"license": "MIT",
"description": "Socket.dev optimized package override for deep-equal/call-bind",
"keywords": [
"Socket.dev",
"package-overrides"
],
"repository": {
"type": "git",
"url": "git+https://github.com/SocketDev/socket-registry-js.git",
"directory": "packages/npm/deep-equal/overrides/call-bind"
},
"exports": {
".": {
"types": "./index.d.ts",
"default": "./index.js"
},
"./callBound": {
"types": "./callBound.d.ts",
"default": "./callBound.js"
},
"./package.json": "./package.json"
},
"sideEffects": false,
"engines": {
"node": ">=18.20.4"
},
"files": [
"*.d.ts",
"*.js"
],
"socket": {
"categories": [
"cleanup"
]
}
}
21 changes: 21 additions & 0 deletions packages/npm/deep-equal/overrides/get-intrinsic/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Socket Inc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
21 changes: 21 additions & 0 deletions packages/npm/deep-equal/overrides/get-intrinsic/LICENSE.original
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Jordan Harband

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 5 additions & 0 deletions packages/npm/deep-equal/overrides/get-intrinsic/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare function GetIntrinsic(
name: '%Set%',
allowMissing?: boolean
): SetConstructor
declare function GetIntrinsic(name: string, allowMissing?: boolean): undefined
4 changes: 3 additions & 1 deletion packages/npm/deep-equal/overrides/get-intrinsic/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict'

const SetCtor = Set

module.exports = function GetIntrinsic(name, _allowMissing) {
return name === '%Set%' ? Set : undefined
return name === '%Set%' ? SetCtor : undefined
}
35 changes: 35 additions & 0 deletions packages/npm/deep-equal/overrides/get-intrinsic/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@socketregistry/deep-equal",
"version": "1.0.3-overrides-get-intrinsic",
"license": "MIT",
"description": "Socket.dev optimized package override for deep-equal/get-intrinsic",
"keywords": [
"Socket.dev",
"package-overrides"
],
"repository": {
"type": "git",
"url": "git+https://github.com/SocketDev/socket-registry-js.git",
"directory": "packages/npm/deep-equal/overrides/get-intrinsic"
},
"exports": {
".": {
"types": "./index.d.ts",
"default": "./index.js"
},
"./package.json": "./package.json"
},
"sideEffects": false,
"engines": {
"node": ">=18.20.4"
},
"files": [
"*.d.ts",
"*.js"
],
"socket": {
"categories": [
"cleanup"
]
}
}
Loading

0 comments on commit e279756

Please sign in to comment.