@locker/is-module
Advanced tools
Comparing version 0.13.8 to 0.13.9
@@ -1,2 +0,2 @@ | ||
/** | ||
/*! | ||
* Copyright (C) 2020 salesforce.com, inc. | ||
@@ -7,40 +7,49 @@ */ | ||
var compiler = require('@locker/compiler'); | ||
var shared = require('@locker/shared'); | ||
const FOUND = {}; | ||
function throwFound(func, args) { | ||
shared.ReflectApply(func, this, args); | ||
// eslint-disable-next-line @typescript-eslint/no-throw-literal | ||
throw FOUND; | ||
shared.ReflectApply(func, this, args); // eslint-disable-next-line @typescript-eslint/no-throw-literal | ||
throw FOUND; | ||
} | ||
function parseBlock() { | ||
// Tokenize inner block statements, including function bodies, but don't | ||
// create the AST. | ||
const node = this.startNode(); | ||
const { length } = this.context; | ||
do { | ||
this.next(); | ||
} while (this.context.length >= length); | ||
// Tokenize inner block statements, including function bodies, but don't | ||
// create the AST. | ||
const node = this.startNode(); | ||
const { | ||
length | ||
} = this.context; | ||
do { | ||
this.next(); | ||
node.body = []; | ||
return this.finishNode(node, 'BlockStatement'); | ||
} while (this.context.length >= length); | ||
this.next(); | ||
node.body = []; | ||
return this.finishNode(node, 'BlockStatement'); | ||
} | ||
function isModule(code) { | ||
const parser = compiler.Parser.create(code); | ||
parser.parseBlock = parseBlock; | ||
parser.parseExport = shared.wrap(parser.parseExport, throwFound); | ||
parser.parseImport = shared.wrap(parser.parseImport, throwFound); | ||
parser.parseImportMeta = shared.wrap(parser.parseImportMeta, throwFound); | ||
try { | ||
parser.parse(); | ||
const parser = compiler.Parser.create(code); | ||
parser.parseBlock = parseBlock; | ||
parser.parseExport = shared.wrap(parser.parseExport, throwFound); | ||
parser.parseImport = shared.wrap(parser.parseImport, throwFound); | ||
parser.parseImportMeta = shared.wrap(parser.parseImportMeta, throwFound); | ||
try { | ||
parser.parse(); | ||
} catch (e) { | ||
if (e === FOUND) { | ||
return true; | ||
} | ||
catch (e) { | ||
if (e === FOUND) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
return false; | ||
} | ||
module.exports = isModule; | ||
/** version: 0.13.8 */ | ||
/*! version: 0.13.9 */ |
@@ -1,2 +0,2 @@ | ||
/** | ||
/*! | ||
* Copyright (C) 2020 salesforce.com, inc. | ||
@@ -6,39 +6,46 @@ */ | ||
import { wrap, ReflectApply } from '@locker/shared'; | ||
const FOUND = {}; | ||
const FOUND = {}; | ||
function throwFound(func, args) { | ||
ReflectApply(func, this, args); | ||
// eslint-disable-next-line @typescript-eslint/no-throw-literal | ||
throw FOUND; | ||
ReflectApply(func, this, args); // eslint-disable-next-line @typescript-eslint/no-throw-literal | ||
throw FOUND; | ||
} | ||
function parseBlock() { | ||
// Tokenize inner block statements, including function bodies, but don't | ||
// create the AST. | ||
const node = this.startNode(); | ||
const { length } = this.context; | ||
do { | ||
this.next(); | ||
} while (this.context.length >= length); | ||
// Tokenize inner block statements, including function bodies, but don't | ||
// create the AST. | ||
const node = this.startNode(); | ||
const { | ||
length | ||
} = this.context; | ||
do { | ||
this.next(); | ||
node.body = []; | ||
return this.finishNode(node, 'BlockStatement'); | ||
} while (this.context.length >= length); | ||
this.next(); | ||
node.body = []; | ||
return this.finishNode(node, 'BlockStatement'); | ||
} | ||
function isModule(code) { | ||
const parser = Parser.create(code); | ||
parser.parseBlock = parseBlock; | ||
parser.parseExport = wrap(parser.parseExport, throwFound); | ||
parser.parseImport = wrap(parser.parseImport, throwFound); | ||
parser.parseImportMeta = wrap(parser.parseImportMeta, throwFound); | ||
try { | ||
parser.parse(); | ||
const parser = Parser.create(code); | ||
parser.parseBlock = parseBlock; | ||
parser.parseExport = wrap(parser.parseExport, throwFound); | ||
parser.parseImport = wrap(parser.parseImport, throwFound); | ||
parser.parseImportMeta = wrap(parser.parseImportMeta, throwFound); | ||
try { | ||
parser.parse(); | ||
} catch (e) { | ||
if (e === FOUND) { | ||
return true; | ||
} | ||
catch (e) { | ||
if (e === FOUND) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
return false; | ||
} | ||
export default isModule; | ||
/** version: 0.13.8 */ | ||
/*! version: 0.13.9 */ |
{ | ||
"name": "@locker/is-module", | ||
"version": "0.13.8", | ||
"version": "0.13.9", | ||
"license": "Salesforce Developer Agreement", | ||
@@ -19,4 +19,4 @@ "author": "Salesforce UI Security Team", | ||
"dependencies": { | ||
"@locker/compiler": "0.13.8", | ||
"@locker/shared": "0.13.8" | ||
"@locker/compiler": "0.13.9", | ||
"@locker/shared": "0.13.9" | ||
}, | ||
@@ -30,3 +30,3 @@ "devDependencies": { | ||
], | ||
"gitHead": "7ae9538a6db0e03856a2786175adab87f227853e" | ||
"gitHead": "73a9746ea42f15ee9c1f8c61c9a2135100c96b2c" | ||
} |
5984
+ Added@locker/ast-lib-maker@0.13.9(transitive)
+ Added@locker/compiler@0.13.9(transitive)
+ Added@locker/instrumentation@0.13.9(transitive)
+ Added@locker/shared@0.13.9(transitive)
- Removed@locker/ast-lib-maker@0.13.8(transitive)
- Removed@locker/compiler@0.13.8(transitive)
- Removed@locker/instrumentation@0.13.8(transitive)
- Removed@locker/shared@0.13.8(transitive)
Updated@locker/compiler@0.13.9
Updated@locker/shared@0.13.9