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

telejson

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

telejson - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

69

dist/index.js

@@ -20,2 +20,4 @@ "use strict";

var _memoizerific = _interopRequireDefault(require("memoizerific"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -38,34 +40,38 @@

for (var i = 0; i < code.length; i += 1) {
if (!inQuoteChar && !inBlockComment && !inLineComment && !inRegexLiteral) {
if (code[i] === '"' || code[i] === "'" || code[i] === '`') {
inQuoteChar = code[i];
} else if (code[i] === '/' && code[i + 1] === '*') {
inBlockComment = true;
} else if (code[i] === '/' && code[i + 1] === '/') {
inLineComment = true;
} else if (code[i] === '/' && code[i + 1] !== '/') {
inRegexLiteral = true;
}
} else {
if (inQuoteChar && (code[i] === inQuoteChar && code[i - 1] !== '\\' || code[i] === '\n' && inQuoteChar !== '`')) {
inQuoteChar = null;
}
if (code.indexOf('//') >= 0 || code.indexOf('/*') >= 0) {
for (var i = 0; i < code.length; i += 1) {
if (!inQuoteChar && !inBlockComment && !inLineComment && !inRegexLiteral) {
if (code[i] === '"' || code[i] === "'" || code[i] === '`') {
inQuoteChar = code[i];
} else if (code[i] === '/' && code[i + 1] === '*') {
inBlockComment = true;
} else if (code[i] === '/' && code[i + 1] === '/') {
inLineComment = true;
} else if (code[i] === '/' && code[i + 1] !== '/') {
inRegexLiteral = true;
}
} else {
if (inQuoteChar && (code[i] === inQuoteChar && code[i - 1] !== '\\' || code[i] === '\n' && inQuoteChar !== '`')) {
inQuoteChar = null;
}
if (inRegexLiteral && (code[i] === '/' && code[i - 1] !== '\\' || code[i] === '\n')) {
inRegexLiteral = false;
}
if (inRegexLiteral && (code[i] === '/' && code[i - 1] !== '\\' || code[i] === '\n')) {
inRegexLiteral = false;
}
if (inBlockComment && code[i - 1] === '/' && code[i - 2] === '*') {
inBlockComment = false;
if (inBlockComment && code[i - 1] === '/' && code[i - 2] === '*') {
inBlockComment = false;
}
if (inLineComment && code[i] === '\n') {
inLineComment = false;
}
}
if (inLineComment && code[i] === '\n') {
inLineComment = false;
if (!inBlockComment && !inLineComment) {
newCode += code[i];
}
}
if (!inBlockComment && !inLineComment) {
newCode += code[i];
}
} else {
newCode = code;
}

@@ -76,7 +82,6 @@

var cleanCode = function cleanCode(code) {
var cleanCode = (0, _memoizerific.default)(10000)(function (code) {
return removeCodeComments(code).replace(/\n\s*/g, '') // remove indents & newlines
.trim();
};
});
var dateFormat = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z$/;

@@ -114,6 +119,6 @@

var name = value.name;
var stringified = cleanCode(value.toString());
var stringified = value.toString();
if (!stringified.match(/(\[native code\]|WEBPACK_IMPORTED_MODULE)/)) {
return "_function_".concat(name, "|").concat(stringified);
if (!stringified.match(/(\[native code\]|WEBPACK_IMPORTED_MODULE|__webpack_exports__|__webpack_require__)/)) {
return "_function_".concat(name, "|").concat(cleanCode(stringified));
}

@@ -120,0 +125,0 @@

{
"name": "telejson",
"version": "2.0.0",
"version": "2.1.0",
"description": "",

@@ -40,2 +40,3 @@ "keywords": [

"lodash.get": "^4.4.2",
"memoizerific": "^1.11.3",
"safe-eval": "^0.4.1"

@@ -42,0 +43,0 @@ },

@@ -7,4 +7,4 @@ import { window, document } from 'global';

import isObject from 'isobject';
import get from 'lodash.get';
import memoize from 'memoizerific';

@@ -18,42 +18,47 @@ const removeCodeComments = code => {

for (let i = 0; i < code.length; i += 1) {
if (!inQuoteChar && !inBlockComment && !inLineComment && !inRegexLiteral) {
if (code[i] === '"' || code[i] === "'" || code[i] === '`') {
inQuoteChar = code[i];
} else if (code[i] === '/' && code[i + 1] === '*') {
inBlockComment = true;
} else if (code[i] === '/' && code[i + 1] === '/') {
inLineComment = true;
} else if (code[i] === '/' && code[i + 1] !== '/') {
inRegexLiteral = true;
if (code.indexOf('//') >= 0 || code.indexOf('/*') >= 0) {
for (let i = 0; i < code.length; i += 1) {
if (!inQuoteChar && !inBlockComment && !inLineComment && !inRegexLiteral) {
if (code[i] === '"' || code[i] === "'" || code[i] === '`') {
inQuoteChar = code[i];
} else if (code[i] === '/' && code[i + 1] === '*') {
inBlockComment = true;
} else if (code[i] === '/' && code[i + 1] === '/') {
inLineComment = true;
} else if (code[i] === '/' && code[i + 1] !== '/') {
inRegexLiteral = true;
}
} else {
if (
inQuoteChar &&
((code[i] === inQuoteChar && code[i - 1] !== '\\') ||
(code[i] === '\n' && inQuoteChar !== '`'))
) {
inQuoteChar = null;
}
if (inRegexLiteral && ((code[i] === '/' && code[i - 1] !== '\\') || code[i] === '\n')) {
inRegexLiteral = false;
}
if (inBlockComment && code[i - 1] === '/' && code[i - 2] === '*') {
inBlockComment = false;
}
if (inLineComment && code[i] === '\n') {
inLineComment = false;
}
}
} else {
if (
inQuoteChar &&
((code[i] === inQuoteChar && code[i - 1] !== '\\') ||
(code[i] === '\n' && inQuoteChar !== '`'))
) {
inQuoteChar = null;
if (!inBlockComment && !inLineComment) {
newCode += code[i];
}
if (inRegexLiteral && ((code[i] === '/' && code[i - 1] !== '\\') || code[i] === '\n')) {
inRegexLiteral = false;
}
if (inBlockComment && code[i - 1] === '/' && code[i - 2] === '*') {
inBlockComment = false;
}
if (inLineComment && code[i] === '\n') {
inLineComment = false;
}
}
if (!inBlockComment && !inLineComment) {
newCode += code[i];
}
} else {
newCode = code;
}
return newCode;
};
const cleanCode = code =>
const cleanCode = memoize(10000)(code =>
removeCodeComments(code)
.replace(/\n\s*/g, '') // remove indents & newlines
.trim();
.trim());

@@ -89,6 +94,6 @@ const dateFormat = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z$/;

const { name } = value;
const stringified = cleanCode(value.toString());
if (!stringified.match(/(\[native code\]|WEBPACK_IMPORTED_MODULE)/)) {
return `_function_${name}|${stringified}`;
const stringified = value.toString();
if (!stringified.match(/(\[native code\]|WEBPACK_IMPORTED_MODULE|__webpack_exports__|__webpack_require__)/)) {
return `_function_${name}|${cleanCode(stringified)}`;
}

@@ -95,0 +100,0 @@ return `_function_${name}|${(() => {}).toString()}`;

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