File tree Expand file tree Collapse file tree 14 files changed +289
-24
lines changed
Expand file tree Collapse file tree 14 files changed +289
-24
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
3+ var hasSymbols = require ( 'has-symbols' ) ( ) ;
4+ var callBound = require ( '../helpers/callBound.js' ) ;
5+
6+ var $toStr = callBound ( '%Object.prototype.toString%' ) ;
7+
38// http://www.ecma-international.org/ecma-262/5.1/#sec-9.11
49
5- module . exports = require ( 'is-callable' ) ;
10+ module . exports = function IsCallable ( argument ) {
11+ // some older engines say that typeof /abc/ === 'function',
12+ return typeof argument === 'function'
13+ && ( hasSymbols || $toStr ( argument ) !== '[object RegExp]' ) ;
14+ } ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
3+ var GetIntrinsic = require ( '../GetIntrinsic.js' ) ;
4+
5+ var $construct = GetIntrinsic ( '%Reflect.construct%' , true ) ;
6+
7+ var DefinePropertyOrThrow = require ( './DefinePropertyOrThrow' ) ;
8+ try {
9+ DefinePropertyOrThrow ( { } , '' , { '[[Get]]' : function ( ) { } } ) ;
10+ } catch ( e ) {
11+ // Accessor properties aren't supported
12+ DefinePropertyOrThrow = null ;
13+ }
14+
315// https://www.ecma-international.org/ecma-262/6.0/#sec-isconstructor
416
5- module . exports = function IsConstructor ( argument ) {
6- return typeof argument === 'function' && ! ! argument . prototype ; // unfortunately there's no way to truly check this without try/catch `new argument`
7- } ;
17+ if ( DefinePropertyOrThrow && $construct ) {
18+ var isConstructorMarker = { } ;
19+ var badArrayLike = { } ;
20+ DefinePropertyOrThrow ( badArrayLike , 'length' , {
21+ '[[Get]]' : function ( ) {
22+ throw isConstructorMarker ;
23+ } ,
24+ '[[Enumerable]]' : true
25+ } ) ;
26+
27+ module . exports = function IsConstructor ( argument ) {
28+ try {
29+ // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`:
30+ $construct ( argument , badArrayLike ) ;
31+ } catch ( err ) {
32+ return err === isConstructorMarker ;
33+ }
34+ } ;
35+ } else {
36+ module . exports = function IsConstructor ( argument ) {
37+ // unfortunately there's no way to truly check this without try/catch `new argument` in old environments
38+ return typeof argument === 'function' && ! ! argument . prototype ;
39+ } ;
40+ }
Original file line number Diff line number Diff line change 11'use strict' ;
22
3+ var hasSymbols = require ( 'has-symbols' ) ( ) ;
4+ var callBound = require ( '../helpers/callBound.js' ) ;
5+
6+ var $toStr = callBound ( '%Object.prototype.toString%' ) ;
7+
38// http://www.ecma-international.org/ecma-262/5.1/#sec-9.11
49
5- module . exports = require ( 'is-callable' ) ;
10+ module . exports = function IsCallable ( argument ) {
11+ // some older engines say that typeof /abc/ === 'function',
12+ return typeof argument === 'function'
13+ && ( hasSymbols || $toStr ( argument ) !== '[object RegExp]' ) ;
14+ } ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
3+ var GetIntrinsic = require ( '../GetIntrinsic.js' ) ;
4+
5+ var $construct = GetIntrinsic ( '%Reflect.construct%' , true ) ;
6+
7+ var DefinePropertyOrThrow = require ( './DefinePropertyOrThrow' ) ;
8+ try {
9+ DefinePropertyOrThrow ( { } , '' , { '[[Get]]' : function ( ) { } } ) ;
10+ } catch ( e ) {
11+ // Accessor properties aren't supported
12+ DefinePropertyOrThrow = null ;
13+ }
14+
315// https://www.ecma-international.org/ecma-262/6.0/#sec-isconstructor
416
5- module . exports = function IsConstructor ( argument ) {
6- return typeof argument === 'function' && ! ! argument . prototype ; // unfortunately there's no way to truly check this without try/catch `new argument`
7- } ;
17+ if ( DefinePropertyOrThrow && $construct ) {
18+ var isConstructorMarker = { } ;
19+ var badArrayLike = { } ;
20+ DefinePropertyOrThrow ( badArrayLike , 'length' , {
21+ '[[Get]]' : function ( ) {
22+ throw isConstructorMarker ;
23+ } ,
24+ '[[Enumerable]]' : true
25+ } ) ;
26+
27+ module . exports = function IsConstructor ( argument ) {
28+ try {
29+ // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`:
30+ $construct ( argument , badArrayLike ) ;
31+ } catch ( err ) {
32+ return err === isConstructorMarker ;
33+ }
34+ } ;
35+ } else {
36+ module . exports = function IsConstructor ( argument ) {
37+ // unfortunately there's no way to truly check this without try/catch `new argument` in old environments
38+ return typeof argument === 'function' && ! ! argument . prototype ;
39+ } ;
40+ }
Original file line number Diff line number Diff line change 11'use strict' ;
22
3+ var hasSymbols = require ( 'has-symbols' ) ( ) ;
4+ var callBound = require ( '../helpers/callBound.js' ) ;
5+
6+ var $toStr = callBound ( '%Object.prototype.toString%' ) ;
7+
38// http://www.ecma-international.org/ecma-262/5.1/#sec-9.11
49
5- module . exports = require ( 'is-callable' ) ;
10+ module . exports = function IsCallable ( argument ) {
11+ // some older engines say that typeof /abc/ === 'function',
12+ return typeof argument === 'function'
13+ && ( hasSymbols || $toStr ( argument ) !== '[object RegExp]' ) ;
14+ } ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
3+ var GetIntrinsic = require ( '../GetIntrinsic.js' ) ;
4+
5+ var $construct = GetIntrinsic ( '%Reflect.construct%' , true ) ;
6+
7+ var DefinePropertyOrThrow = require ( './DefinePropertyOrThrow' ) ;
8+ try {
9+ DefinePropertyOrThrow ( { } , '' , { '[[Get]]' : function ( ) { } } ) ;
10+ } catch ( e ) {
11+ // Accessor properties aren't supported
12+ DefinePropertyOrThrow = null ;
13+ }
14+
315// https://www.ecma-international.org/ecma-262/6.0/#sec-isconstructor
416
5- module . exports = function IsConstructor ( argument ) {
6- return typeof argument === 'function' && ! ! argument . prototype ; // unfortunately there's no way to truly check this without try/catch `new argument`
7- } ;
17+ if ( DefinePropertyOrThrow && $construct ) {
18+ var isConstructorMarker = { } ;
19+ var badArrayLike = { } ;
20+ DefinePropertyOrThrow ( badArrayLike , 'length' , {
21+ '[[Get]]' : function ( ) {
22+ throw isConstructorMarker ;
23+ } ,
24+ '[[Enumerable]]' : true
25+ } ) ;
26+
27+ module . exports = function IsConstructor ( argument ) {
28+ try {
29+ // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`:
30+ $construct ( argument , badArrayLike ) ;
31+ } catch ( err ) {
32+ return err === isConstructorMarker ;
33+ }
34+ } ;
35+ } else {
36+ module . exports = function IsConstructor ( argument ) {
37+ // unfortunately there's no way to truly check this without try/catch `new argument` in old environments
38+ return typeof argument === 'function' && ! ! argument . prototype ;
39+ } ;
40+ }
Original file line number Diff line number Diff line change 11'use strict' ;
22
3+ var hasSymbols = require ( 'has-symbols' ) ( ) ;
4+ var callBound = require ( '../helpers/callBound.js' ) ;
5+
6+ var $toStr = callBound ( '%Object.prototype.toString%' ) ;
7+
38// http://www.ecma-international.org/ecma-262/5.1/#sec-9.11
49
5- module . exports = require ( 'is-callable' ) ;
10+ module . exports = function IsCallable ( argument ) {
11+ // some older engines say that typeof /abc/ === 'function',
12+ return typeof argument === 'function'
13+ && ( hasSymbols || $toStr ( argument ) !== '[object RegExp]' ) ;
14+ } ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
3+ var GetIntrinsic = require ( '../GetIntrinsic.js' ) ;
4+
5+ var $construct = GetIntrinsic ( '%Reflect.construct%' , true ) ;
6+
7+ var DefinePropertyOrThrow = require ( './DefinePropertyOrThrow' ) ;
8+ try {
9+ DefinePropertyOrThrow ( { } , '' , { '[[Get]]' : function ( ) { } } ) ;
10+ } catch ( e ) {
11+ // Accessor properties aren't supported
12+ DefinePropertyOrThrow = null ;
13+ }
14+
315// https://www.ecma-international.org/ecma-262/6.0/#sec-isconstructor
416
5- module . exports = function IsConstructor ( argument ) {
6- return typeof argument === 'function' && ! ! argument . prototype ; // unfortunately there's no way to truly check this without try/catch `new argument`
7- } ;
17+ if ( DefinePropertyOrThrow && $construct ) {
18+ var isConstructorMarker = { } ;
19+ var badArrayLike = { } ;
20+ DefinePropertyOrThrow ( badArrayLike , 'length' , {
21+ '[[Get]]' : function ( ) {
22+ throw isConstructorMarker ;
23+ } ,
24+ '[[Enumerable]]' : true
25+ } ) ;
26+
27+ module . exports = function IsConstructor ( argument ) {
28+ try {
29+ // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`:
30+ $construct ( argument , badArrayLike ) ;
31+ } catch ( err ) {
32+ return err === isConstructorMarker ;
33+ }
34+ } ;
35+ } else {
36+ module . exports = function IsConstructor ( argument ) {
37+ // unfortunately there's no way to truly check this without try/catch `new argument` in old environments
38+ return typeof argument === 'function' && ! ! argument . prototype ;
39+ } ;
40+ }
Original file line number Diff line number Diff line change 11'use strict' ;
22
3+ var hasSymbols = require ( 'has-symbols' ) ( ) ;
4+ var callBound = require ( '../helpers/callBound.js' ) ;
5+
6+ var $toStr = callBound ( '%Object.prototype.toString%' ) ;
7+
38// http://www.ecma-international.org/ecma-262/5.1/#sec-9.11
49
5- module . exports = require ( 'is-callable' ) ;
10+ module . exports = function IsCallable ( argument ) {
11+ // some older engines say that typeof /abc/ === 'function',
12+ return typeof argument === 'function'
13+ && ( hasSymbols || $toStr ( argument ) !== '[object RegExp]' ) ;
14+ } ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
3+ var GetIntrinsic = require ( '../GetIntrinsic.js' ) ;
4+
5+ var $construct = GetIntrinsic ( '%Reflect.construct%' , true ) ;
6+
7+ var DefinePropertyOrThrow = require ( './DefinePropertyOrThrow' ) ;
8+ try {
9+ DefinePropertyOrThrow ( { } , '' , { '[[Get]]' : function ( ) { } } ) ;
10+ } catch ( e ) {
11+ // Accessor properties aren't supported
12+ DefinePropertyOrThrow = null ;
13+ }
14+
315// https://www.ecma-international.org/ecma-262/6.0/#sec-isconstructor
416
5- module . exports = function IsConstructor ( argument ) {
6- return typeof argument === 'function' && ! ! argument . prototype ; // unfortunately there's no way to truly check this without try/catch `new argument`
7- } ;
17+ if ( DefinePropertyOrThrow && $construct ) {
18+ var isConstructorMarker = { } ;
19+ var badArrayLike = { } ;
20+ DefinePropertyOrThrow ( badArrayLike , 'length' , {
21+ '[[Get]]' : function ( ) {
22+ throw isConstructorMarker ;
23+ } ,
24+ '[[Enumerable]]' : true
25+ } ) ;
26+
27+ module . exports = function IsConstructor ( argument ) {
28+ try {
29+ // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`:
30+ $construct ( argument , badArrayLike ) ;
31+ } catch ( err ) {
32+ return err === isConstructorMarker ;
33+ }
34+ } ;
35+ } else {
36+ module . exports = function IsConstructor ( argument ) {
37+ // unfortunately there's no way to truly check this without try/catch `new argument` in old environments
38+ return typeof argument === 'function' && ! ! argument . prototype ;
39+ } ;
40+ }
You can’t perform that action at this time.
0 commit comments