| 1 | # Is Module
|
|---|
| 2 |
|
|---|
| 3 | Check whether a source string looks like an ES6 module.
|
|---|
| 4 | This doesn't actually execute the code,
|
|---|
| 5 | and doesn't check other module types.
|
|---|
| 6 | So source strings without any module loaders returns `false`.
|
|---|
| 7 |
|
|---|
| 8 | This is just what I need from https://github.com/yahoo/js-module-formats, which actually executes the sauce string in a subcontext.
|
|---|
| 9 |
|
|---|
| 10 | ## API
|
|---|
| 11 |
|
|---|
| 12 | ```js
|
|---|
| 13 | var isES6Module = require('is-module');
|
|---|
| 14 |
|
|---|
| 15 | console.log(isES6Module('import * from "emitter";')) // => true
|
|---|
| 16 | ```
|
|---|
| 17 |
|
|---|
| 18 | ## License
|
|---|
| 19 |
|
|---|
| 20 | (The MIT License)
|
|---|
| 21 |
|
|---|
| 22 | Copyright (c) 2014 segmentio <team@segment.io>
|
|---|
| 23 |
|
|---|
| 24 | Permission is hereby granted, free of charge, to any person obtaining
|
|---|
| 25 | a copy of this software and associated documentation files (the
|
|---|
| 26 | 'Software'), to deal in the Software without restriction, including
|
|---|
| 27 | without limitation the rights to use, copy, modify, merge, publish,
|
|---|
| 28 | distribute, sublicense, and/or sell copies of the Software, and to
|
|---|
| 29 | permit persons to whom the Software is furnished to do so, subject to
|
|---|
| 30 | the following conditions:
|
|---|
| 31 |
|
|---|
| 32 | The above copyright notice and this permission notice shall be
|
|---|
| 33 | included in all copies or substantial portions of the Software.
|
|---|
| 34 |
|
|---|
| 35 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|---|
| 36 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|---|
| 37 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|---|
| 38 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|---|
| 39 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|---|
| 40 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|---|
| 41 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|---|