Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-literal-to-ast

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-literal-to-ast - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

32

dist/index.js

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,22 +6,13 @@ Object.defineProperty(exports, "__esModule", {

});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.default = astify;
var _babelTypes = require('babel-types');
var t = _interopRequireWildcard(require("@babel/types"));
var t = _interopRequireWildcard(_babelTypes);
var babylon = _interopRequireWildcard(require("babylon"));
var _babylon = require('babylon');
var _traverse = _interopRequireDefault(require("@babel/traverse"));
var babylon = _interopRequireWildcard(_babylon);
var _babelTraverse = require('babel-traverse');
var _babelTraverse2 = _interopRequireDefault(_babelTraverse);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }

@@ -32,3 +23,4 @@ function astify(literal) {

}
switch (typeof literal === 'undefined' ? 'undefined' : _typeof(literal)) {
switch (typeof literal) {
case 'function':

@@ -39,11 +31,16 @@ var ast = babylon.parse(literal.toString(), {

});
return _babelTraverse2.default.removeProperties(ast);
return _traverse.default.removeProperties(ast);
case 'number':
return t.numericLiteral(literal);
case 'string':
return t.stringLiteral(literal);
case 'boolean':
return t.booleanLiteral(literal);
case 'undefined':
return t.unaryExpression('void', t.numericLiteral(0), true);
default:

@@ -53,2 +50,3 @@ if (Array.isArray(literal)) {

}
return t.objectExpression(Object.keys(literal).filter(function (k) {

@@ -61,2 +59,2 @@ return typeof literal[k] !== 'undefined';

}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJhc3RpZnkiLCJ0IiwiYmFieWxvbiIsImxpdGVyYWwiLCJudWxsTGl0ZXJhbCIsImFzdCIsInBhcnNlIiwidG9TdHJpbmciLCJhbGxvd1JldHVybk91dHNpZGVGdW5jdGlvbiIsImFsbG93U3VwZXJPdXRzaWRlTWV0aG9kIiwicmVtb3ZlUHJvcGVydGllcyIsIm51bWVyaWNMaXRlcmFsIiwic3RyaW5nTGl0ZXJhbCIsImJvb2xlYW5MaXRlcmFsIiwidW5hcnlFeHByZXNzaW9uIiwiQXJyYXkiLCJpc0FycmF5IiwiYXJyYXlFeHByZXNzaW9uIiwibWFwIiwib2JqZWN0RXhwcmVzc2lvbiIsIk9iamVjdCIsImtleXMiLCJmaWx0ZXIiLCJrIiwib2JqZWN0UHJvcGVydHkiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7O2tCQUl3QkEsTTs7QUFKeEI7O0lBQVlDLEM7O0FBQ1o7O0lBQVlDLE87O0FBQ1o7Ozs7Ozs7O0FBRWUsU0FBU0YsTUFBVCxDQUFnQkcsT0FBaEIsRUFBeUI7QUFDdEMsTUFBSUEsWUFBWSxJQUFoQixFQUFzQjtBQUNwQixXQUFPRixFQUFFRyxXQUFGLEVBQVA7QUFDRDtBQUNELGlCQUFlR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VuYXJ5RXhwcmVzc2lvbigndm9pZCcsIHQubnVtZXJpY0xpdGVyYWwoMCksIHRydWUpO1xuICBkZWZhdWx0OlxuICAgIGlmIChBcnJheS5pc0FycmF5KGxpdGVyYWwpKSB7XG4gICAgICByZXR1cm4gdC5hcnJheUV4cHJlc3Npb24obGl0ZXJhbC5tYXAoYXN0aWZ5KSk7XG4gICAgfVxuICAgIHJldHVybiB0Lm9iamVjdEV4cHJlc3Npb24oT2JqZWN0LmtleXMobGl0ZXJhbClcbiAgICAgIC5maWx0ZXIoKGspID0+IHtcbiAgICAgICAgcmV0dXJuIHR5cGVvZiBsaXRlcmFsW2tdICE9PSAndW5kZWZpbmVkJztcbiAgICAgIH0pXG4gICAgICAubWFwKChrKSA9PiB7XG4gICAgICAgIHJldHVybiB0Lm9iamVjdFByb3BlcnR5KFxuICAgICAgICAgIHQuc3RyaW5nTGl0ZXJhbChrKSxcbiAgICAgICAgICBhc3RpZnkobGl0ZXJhbFtrXSlcbiAgICAgICAgKTtcbiAgICAgIH0pKTtcbiAgfVxufVxuIl19
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJhc3RpZnkiLCJsaXRlcmFsIiwidCIsIm51bGxMaXRlcmFsIiwiYXN0IiwiYmFieWxvbiIsInBhcnNlIiwidG9TdHJpbmciLCJhbGxvd1JldHVybk91dHNpZGVGdW5jdGlvbiIsImFsbG93U3VwZXJPdXRzaWRlTWV0aG9kIiwicmVtb3ZlUHJvcGVydGllcyIsIm51bWVyaWNMaXRlcmFsIiwic3RyaW5nTGl0ZXJhbCIsImJvb2xlYW5MaXRlcmFsIiwidW5hcnlFeHByZXNzaW9uIiwiQXJyYXkiLCJpc0FycmF5IiwiYXJyYXlFeHByZXNzaW9uIiwibWFwIiwib2JqZWN0RXhwcmVzc2lvbiIsIk9iamVjdCIsImtleXMiLCJmaWx0ZXIiL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uIHQubnVtZXJpY0xpdGVyYWwobGl0ZXJhbCk7XG4gIGNhc2UgJ3N0cmluZyc6XG4gICAgcmV0dXJuIHQuc3RyaW5nTGl0ZXJhbChsaXRlcmFsKTtcbiAgY2FzZSAnYm9vbGVhbic6XG4gICAgcmV0dXJuIHQuYm9vbGVhbkxpdGVyYWwobGl0ZXJhbCk7XG4gIGNhc2UgJ3VuZGVmaW5lZCc6XG4gICAgcmV0dXJuIHQudW5hcnlFeHByZXNzaW9uKCd2b2lkJywgdC5udW1lcmljTGl0ZXJhbCgwKSwgdHJ1ZSk7XG4gIGRlZmF1bHQ6XG4gICAgaWYgKEFycmF5LmlzQXJyYXkobGl0ZXJhbCkpIHtcbiAgICAgIHJldHVybiB0LmFycmF5RXhwcmVzc2lvbihsaXRlcmFsLm1hcChhc3RpZnkpKTtcbiAgICB9XG4gICAgcmV0dXJuIHQub2JqZWN0RXhwcmVzc2lvbihPYmplY3Qua2V5cyhsaXRlcmFsKVxuICAgICAgLmZpbHRlcigoaykgPT4ge1xuICAgICAgICByZXR1cm4gdHlwZW9mIGxpdGVyYWxba10gIT09ICd1bmRlZmluZWQnO1xuICAgICAgfSlcbiAgICAgIC5tYXAoKGspID0+IHtcbiAgICAgICAgcmV0dXJuIHQub2JqZWN0UHJvcGVydHkoXG4gICAgICAgICAgdC5zdHJpbmdMaXRlcmFsKGspLFxuICAgICAgICAgIGFzdGlmeShsaXRlcmFsW2tdKVxuICAgICAgICApO1xuICAgICAgfSkpO1xuICB9XG59XG4iXX0=
{
"name": "babel-literal-to-ast",
"version": "1.0.0",
"version": "2.0.0",
"author": "Izaak Schroeder <izaak.schroeder@gmail.com>",

@@ -14,15 +14,16 @@ "main": "index.js",

"devDependencies": {
"babel-cli": "^6.0.2",
"babel-preset-es2015": "^6.0.11",
"@babel/cli": "^7.0.0-beta.37",
"@babel/core": "^7.0.0-beta.37",
"@babel/preset-env": "^7.0.0-beta.37",
"eslint": "^4.6.1",
"eslint-config-metalab": "^7.0.1"
"eslint-config-metalab": "^8.0.0"
},
"peerDependencies": {
"babel-core": ">=6.0.20"
"@babel/core": "^7.0.0-beta.37"
},
"dependencies": {
"babel-traverse": "^6.26.0",
"babel-types": "^6.26.0",
"babylon": "^6.18.0"
"@babel/traverse": "^7.0.0-beta.37",
"@babel/types": "^7.0.0-beta.37",
"babylon": "^7.0.0-beta.37"
}
}

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

import * as t from 'babel-types';
import * as t from '@babel/types';
import * as babylon from 'babylon';
import traverse from 'babel-traverse';
import traverse from '@babel/traverse';

@@ -5,0 +5,0 @@ export default function astify(literal) {

Sorry, the diff of this file is not supported yet

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