construct-new 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +3 -1
  2. package/index.js +6 -3
  3. package/package.json +3 -2
package/index.d.ts CHANGED
@@ -5,4 +5,6 @@ type ConstructOptions = {
5
5
  callback: () => void
6
6
  }
7
7
 
8
- export default function construct(options: ConstructOptions): any
8
+ function construct(options: ConstructOptions): any
9
+
10
+ export = construct
package/index.js CHANGED
@@ -7,9 +7,12 @@ var isConstructable = require('is-constructable').isConstructable
7
7
  var isArray = require('isarray')
8
8
  var isArguments = require('is-arguments')
9
9
  var isFunction = require('is-function')
10
- var t = require('true')
10
+ var t = require('true-value')
11
11
  var myTrueValue = t()
12
12
  var _return = require('@_immo/return')
13
+ var intrinsic = require('get-intrinsic')
14
+ var reflectconstruct = intrinsic('%Reflect.construct%')
15
+ var objcreate = intrinsic('%Object.create%')
13
16
 
14
17
  function construct({
15
18
  target,
@@ -37,9 +40,9 @@ function construct({
37
40
  }
38
41
  var result
39
42
  if (isES2015 === myTrueValue) {
40
- result = Reflect.construct(target, args, newTarget)
43
+ result = reflectconstruct(target, args, newTarget)
41
44
  } else {
42
- result = target.apply(Object.create(target.prototype), args)
45
+ result = target.apply(objcreate(target.prototype), args)
43
46
  }
44
47
  callback(result)
45
48
  return _return(result)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "construct-new",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Like the new operator, but a function.",
5
5
  "main": "index.js",
6
6
  "scripts": {},
@@ -18,6 +18,7 @@
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
20
  "@_immo/return": "^1.1.1",
21
+ "get-intrinsic": "^1.3.1",
21
22
  "immediate-error": "^6.3.0",
22
23
  "is-arguments": "^1.1.1",
23
24
  "is-constructable": "^1.0.0",
@@ -26,7 +27,7 @@
26
27
  "is-nil": "^1.0.1",
27
28
  "isarray": "^2.0.5",
28
29
  "noop6": "^1.0.9",
29
- "true": "^0.0.4"
30
+ "true-value": "^2.0.5"
30
31
  },
31
32
  "devDependencies": {
32
33
  "@types/node": "^22.5.5"