« Bugzilla Issues Index
#3299 — Function to determine if an object is an exotic namespace object
- bug_id:
3299
- creation_ts:
2014-10-27 07:10:00 -0700
- short_desc:
Function to determine if an object is an exotic namespace object
- delta_ts:
2014-10-27 07:20:14 -0700
- product:
Draft for 6th Edition
- component:
Modules
- version:
Rev 28: October 14, 2014 Draft
- rep_platform:
All
- op_sys:
All
- bug_status:
RESOLVED
- resolution:
FIXED
- priority:
Normal
- bug_severity:
normal
- everconfirmed:
true
- reporter:
Guy Bedford
- assigned_to:
Allen Wirfs-Brock
- cc:
["dherman", "jorendorff", "samth"]
- commentid:
10538
- comment_count:
0
- who:
Guy Bedford
- bug_when:
2014-10-27 07:10:39 -0700
As mentioned on es-discuss, it is useful to have a function to determine whether a given object is an exotic module namespace object.
This arises in interop scenarios when loading ES6 through CommonJS, as we want to know and treat ES6 modules differently in compiled ES6 to CommonJS.
It may also arise in other scenarios as well.
The alternative becomes adding a flag to module namespace objects, which isn't ideal.
- commentid:
10539
- comment_count:
1
- who:
Guy Bedford
- bug_when:
2014-10-27 07:20:14 -0700
Reading further, it seems that something like:
function isModule(module) {
return typeof module === 'object' && module.toString() === 'Module';
}
will effectively be able to handle this. Do let me know if there's a better pattern though.