Socket
Socket
Sign inDemoInstall

espurify

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

espurify - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

52

build/espurify.js

@@ -59,3 +59,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.espurify = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw (f.code="MODULE_NOT_FOUND", f)}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){

for (key in obj) {
if (key.lastIndexOf('__', 0) === 0) {
if (key.lastIndexOf('_', 0) === 0) {
continue;

@@ -86,44 +86,60 @@ }

module.exports = {
AssignmentExpression: ['type', 'operator', 'left', 'right'],
ArrayExpression: ['type', 'elements'],
ArrayPattern: ['type', 'elements'],
// ArrowFunctionExpression: ['type', 'params', 'defaults', 'rest', 'body', 'generator', 'expression'],
ArrowFunctionExpression: ['type', 'id', 'params', 'body', 'generator', 'expression'],
AssignmentExpression: ['type', 'operator', 'left', 'right'],
AssignmentPattern: ['type', 'left', 'right'],
BinaryExpression: ['type', 'operator', 'left', 'right'],
BlockStatement: ['type', 'body'],
BinaryExpression: ['type', 'operator', 'left', 'right'],
BreakStatement: ['type', 'label'],
CallExpression: ['type', 'callee', 'arguments'],
CatchClause: ['type', 'param', 'guard', 'body'],
// ClassBody: ['type', 'body'],
// ClassDeclaration: ['type', 'id', 'body', 'superClass'],
// ClassExpression: ['type', 'id', 'body', 'superClass'],
ConditionalExpression: ['type', 'test', 'consequent', 'alternate'],
ClassBody: ['type', 'body'],
ClassDeclaration: ['type', 'id', 'superClass', 'body'],
ClassExpression: ['type', 'id', 'superClass', 'body'],
ConditionalExpression: ['type', 'test', 'alternate', 'consequent'],
ContinueStatement: ['type', 'label'],
DebuggerStatement: ['type'],
// DirectiveStatement: ['type'],
DoWhileStatement: ['type', 'body', 'test'],
EmptyStatement: ['type'],
ExportAllDeclaration: ['type', 'source'],
ExportDefaultDeclaration: ['type', 'declaration'],
ExportNamedDeclaration: ['type', 'declaration', 'specifiers', 'source'],
ExportSpecifier: ['type', 'exported', 'local'],
ExpressionStatement: ['type', 'expression'],
ForInStatement: ['type', 'left', 'right', 'body'],
ForOfStatement: ['type', 'left', 'right', 'body'],
ForStatement: ['type', 'init', 'test', 'update', 'body'],
ForInStatement: ['type', 'left', 'right', 'body', 'each'],
FunctionDeclaration: ['type', 'id', 'params', 'defaults', 'rest', 'body', 'generator', 'expression'],
FunctionExpression: ['type', 'id', 'params', 'defaults', 'rest', 'body', 'generator', 'expression'],
FunctionDeclaration: ['type', 'id', 'params', 'body', 'generator'],
FunctionExpression: ['type', 'id', 'params', 'body', 'generator'],
Identifier: ['type', 'name'],
IfStatement: ['type', 'test', 'consequent', 'alternate'],
Literal: ['type', 'value'],
ImportDeclaration: ['type', 'specifiers', 'source'],
ImportDefaultSpecifier: ['type', 'local'],
ImportNamespaceSpecifier: ['type', 'local'],
ImportSpecifier: ['type', 'imported', 'local'],
LabeledStatement: ['type', 'label', 'body'],
Literal: ['type', 'value', 'regex'],
LogicalExpression: ['type', 'operator', 'left', 'right'],
MemberExpression: ['type', 'object', 'property', 'computed'],
// MethodDefinition: ['type', 'key', 'value'],
MetaProperty: ['type', 'meta', 'property'],
MethodDefinition: ['type', 'key', 'value', 'kind', 'computed', 'static'],
NewExpression: ['type', 'callee', 'arguments'],
ObjectExpression: ['type', 'properties'],
ObjectPattern: ['type', 'properties'],
Program: ['type', 'body'],
Property: ['type', 'key', 'value', 'kind'],
Program: ['type', 'body', 'sourceType'],
Property: ['type', 'key', 'value', 'kind', 'method', 'shorthand', 'computed'],
RestElement: ['type', 'argument'],
ReturnStatement: ['type', 'argument'],
SequenceExpression: ['type', 'expressions'],
SpreadElement: ['type', 'argument'],
Super: ['type'],
SwitchCase: ['type', 'test', 'consequent'],
SwitchStatement: ['type', 'discriminant', 'cases', 'lexical'],
SwitchCase: ['type', 'test', 'consequent'],
TaggedTemplateExpression: ['type', 'tag', 'quasi'],
TemplateElement: ['type', 'tail', 'value'],
TemplateLiteral: ['type', 'quasis', 'expressions'],
ThisExpression: ['type'],
ThrowStatement: ['type', 'argument'],
TryStatement: ['type', 'block', 'handlers', 'handler', 'guardedHandlers', 'finalizer'],
TryStatement: ['type', 'block', 'handler', 'finalizer'],
UnaryExpression: ['type', 'operator', 'prefix', 'argument'],

@@ -130,0 +146,0 @@ UpdateExpression: ['type', 'operator', 'argument', 'prefix'],

@@ -1,4 +0,17 @@

### [1.0.1](https://github.com/twada/espurify/releases/tag/v1.0.1) (2015-03-06)
## [1.1.0](https://github.com/estools/espurify/releases/tag/v1.1.0) (2015-04-12)
#### Features
* switch to The ESTree Spec to support ES6 ([b9ca486e](https://github.com/estools/espurify/commit/b9ca486ed94f149e1f957ff7890899f171add03b))
#### Bug Fixes
* avoid cloning private (maybe recursive) props ([501b12bf](https://github.com/estools/espurify/commit/501b12bf86816ded4f5183a075a9d08da0ef22bf))
### [1.0.1](https://github.com/estools/espurify/releases/tag/v1.0.1) (2015-03-06)
* replace Array#indexOf with [indexof module](https://www.npmjs.com/package/indexof) to deal with older browsers ([4ba0bd51](https://github.com/estools/espurify/commit/4ba0bd5155ad657e4beb3338dfcd79e443e40d10))

@@ -14,3 +27,3 @@ * ship browser build with npm module too ([47e0cc85](https://github.com/estools/espurify/commit/47e0cc85a5d5b92b281ed80216d6908bed591515))

### [1.0.0](https://github.com/twada/espurify/releases/tag/v1.0.0) (2014-11-01)
### [1.0.0](https://github.com/estools/espurify/releases/tag/v1.0.0) (2014-11-01)

@@ -21,14 +34,14 @@

### [0.1.3](https://github.com/twada/espurify/releases/tag/v0.1.3) (2014-08-01)
### [0.1.3](https://github.com/estools/espurify/releases/tag/v0.1.3) (2014-08-01)
### [0.1.2](https://github.com/twada/espurify/releases/tag/v0.1.2) (2014-07-22)
### [0.1.2](https://github.com/estools/espurify/releases/tag/v0.1.2) (2014-07-22)
### [0.1.1](https://github.com/twada/espurify/releases/tag/v0.1.1) (2014-07-22)
### [0.1.1](https://github.com/estools/espurify/releases/tag/v0.1.1) (2014-07-22)
### [0.1.0](https://github.com/twada/espurify/releases/tag/v0.1.0) (2014-07-22)
### [0.1.0](https://github.com/estools/espurify/releases/tag/v0.1.0) (2014-07-22)
The first release.

@@ -15,3 +15,3 @@ /**

for (key in obj) {
if (key.lastIndexOf('__', 0) === 0) {
if (key.lastIndexOf('_', 0) === 0) {
continue;

@@ -18,0 +18,0 @@ }

module.exports = {
AssignmentExpression: ['type', 'operator', 'left', 'right'],
ArrayExpression: ['type', 'elements'],
ArrayPattern: ['type', 'elements'],
// ArrowFunctionExpression: ['type', 'params', 'defaults', 'rest', 'body', 'generator', 'expression'],
ArrowFunctionExpression: ['type', 'id', 'params', 'body', 'generator', 'expression'],
AssignmentExpression: ['type', 'operator', 'left', 'right'],
AssignmentPattern: ['type', 'left', 'right'],
BinaryExpression: ['type', 'operator', 'left', 'right'],
BlockStatement: ['type', 'body'],
BinaryExpression: ['type', 'operator', 'left', 'right'],
BreakStatement: ['type', 'label'],
CallExpression: ['type', 'callee', 'arguments'],
CatchClause: ['type', 'param', 'guard', 'body'],
// ClassBody: ['type', 'body'],
// ClassDeclaration: ['type', 'id', 'body', 'superClass'],
// ClassExpression: ['type', 'id', 'body', 'superClass'],
ConditionalExpression: ['type', 'test', 'consequent', 'alternate'],
ClassBody: ['type', 'body'],
ClassDeclaration: ['type', 'id', 'superClass', 'body'],
ClassExpression: ['type', 'id', 'superClass', 'body'],
ConditionalExpression: ['type', 'test', 'alternate', 'consequent'],
ContinueStatement: ['type', 'label'],
DebuggerStatement: ['type'],
// DirectiveStatement: ['type'],
DoWhileStatement: ['type', 'body', 'test'],
EmptyStatement: ['type'],
ExportAllDeclaration: ['type', 'source'],
ExportDefaultDeclaration: ['type', 'declaration'],
ExportNamedDeclaration: ['type', 'declaration', 'specifiers', 'source'],
ExportSpecifier: ['type', 'exported', 'local'],
ExpressionStatement: ['type', 'expression'],
ForInStatement: ['type', 'left', 'right', 'body'],
ForOfStatement: ['type', 'left', 'right', 'body'],
ForStatement: ['type', 'init', 'test', 'update', 'body'],
ForInStatement: ['type', 'left', 'right', 'body', 'each'],
FunctionDeclaration: ['type', 'id', 'params', 'defaults', 'rest', 'body', 'generator', 'expression'],
FunctionExpression: ['type', 'id', 'params', 'defaults', 'rest', 'body', 'generator', 'expression'],
FunctionDeclaration: ['type', 'id', 'params', 'body', 'generator'],
FunctionExpression: ['type', 'id', 'params', 'body', 'generator'],
Identifier: ['type', 'name'],
IfStatement: ['type', 'test', 'consequent', 'alternate'],
Literal: ['type', 'value'],
ImportDeclaration: ['type', 'specifiers', 'source'],
ImportDefaultSpecifier: ['type', 'local'],
ImportNamespaceSpecifier: ['type', 'local'],
ImportSpecifier: ['type', 'imported', 'local'],
LabeledStatement: ['type', 'label', 'body'],
Literal: ['type', 'value', 'regex'],
LogicalExpression: ['type', 'operator', 'left', 'right'],
MemberExpression: ['type', 'object', 'property', 'computed'],
// MethodDefinition: ['type', 'key', 'value'],
MetaProperty: ['type', 'meta', 'property'],
MethodDefinition: ['type', 'key', 'value', 'kind', 'computed', 'static'],
NewExpression: ['type', 'callee', 'arguments'],
ObjectExpression: ['type', 'properties'],
ObjectPattern: ['type', 'properties'],
Program: ['type', 'body'],
Property: ['type', 'key', 'value', 'kind'],
Program: ['type', 'body', 'sourceType'],
Property: ['type', 'key', 'value', 'kind', 'method', 'shorthand', 'computed'],
RestElement: ['type', 'argument'],
ReturnStatement: ['type', 'argument'],
SequenceExpression: ['type', 'expressions'],
SpreadElement: ['type', 'argument'],
Super: ['type'],
SwitchCase: ['type', 'test', 'consequent'],
SwitchStatement: ['type', 'discriminant', 'cases', 'lexical'],
SwitchCase: ['type', 'test', 'consequent'],
TaggedTemplateExpression: ['type', 'tag', 'quasi'],
TemplateElement: ['type', 'tail', 'value'],
TemplateLiteral: ['type', 'quasis', 'expressions'],
ThisExpression: ['type'],
ThrowStatement: ['type', 'argument'],
TryStatement: ['type', 'block', 'handlers', 'handler', 'guardedHandlers', 'finalizer'],
TryStatement: ['type', 'block', 'handler', 'finalizer'],
UnaryExpression: ['type', 'operator', 'prefix', 'argument'],

@@ -45,0 +61,0 @@ UpdateExpression: ['type', 'operator', 'argument', 'prefix'],

{
"name": "espurify",
"description": "Clone new AST without extra properties",
"version": "1.0.1",
"version": "1.1.0",
"author": {

@@ -16,6 +16,6 @@ "name": "Takuto Wada",

"devDependencies": {
"esprima": "^1.0.0",
"estraverse": "^1.0.0",
"jshint": "^2.5.11",
"mocha": "^2.0.1"
"esprima": "^2.1.0",
"estraverse": "^3.1.0",
"jshint": "^2.7.0",
"mocha": "^2.2.4"
},

@@ -35,3 +35,5 @@ "files": [

"ast",
"estree",
"ecmascript",
"es6",
"esprima"

@@ -38,0 +40,0 @@ ],

@@ -18,5 +18,7 @@ espurify

Leave properties defined in [Mozilla JavaScript AST spec](https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API) only (Note: location informations are eliminated too).
Leaves properties defined in [The ESTree Spec](https://github.com/estree/estree) (formerly known as [Mozilla SpiderMonkey Parser API](https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API)) only. Also note that location informations (such as `loc` and `range`) are eliminated too.
`espurify` supports [ES5](https://github.com/estree/estree/blob/master/spec.md) and [ES6](https://github.com/estree/estree/blob/master/es6.md) properties.
EXAMPLE

@@ -23,0 +25,0 @@ ---------------------------------------

@@ -270,1 +270,90 @@ var espurify = require('..'),

});
it('RexExpLiteral', function () {
var ast = esprima.parse('var re = /^foo$/im', {tolerant: true, tokens: true, range: true, raw: true});
var expected = {
type: 'Program',
body: [
{
type: 'VariableDeclaration',
declarations: [
{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 're'
},
init: {
type: 'Literal',
value: {},
regex: {
pattern: '^foo$',
flags: 'im'
}
}
}
],
kind: 'var'
}
]
};
var purified = espurify(ast);
assert.deepEqual(purified, expected);
});
it('ES6 features', function () {
var ast = esprima.parse('evens.map(v => v + 1);', {tolerant: true, tokens: true, range: true, raw: true});
var expected = {
type: 'Program',
body: [
{
type: 'ExpressionStatement',
expression: {
type: 'CallExpression',
callee: {
type: 'MemberExpression',
computed: false,
object: {
type: 'Identifier',
name: 'evens'
},
property: {
type: 'Identifier',
name: 'map'
}
},
arguments: [
{
type: 'ArrowFunctionExpression',
id: null,
params: [
{
type: 'Identifier',
name: 'v'
}
],
body: {
type: 'BinaryExpression',
operator: '+',
left: {
type: 'Identifier',
name: 'v'
},
right: {
type: 'Literal',
value: 1
}
},
generator: false,
expression: true
}
]
}
}
]
};
var purified = espurify(ast);
assert.deepEqual(purified, expected);
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc