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

caterpillar-browser

Package Overview
Dependencies
Maintainers
2
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

caterpillar-browser - npm Package Compare versions

Comparing version 4.5.0 to 5.0.0-next.1585174269.832d3a153d8de2abd5184756e529da872daeac8b

357

edition-browsers/index.js
// @ts-check
/* eslint class-methods-use-this:0 */
'use strict'; // Imports
'use strict' // Imports
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _typeof(obj) {
'@babel/helpers - typeof'
if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') {
_typeof = function _typeof(obj) {
return typeof obj
}
} else {
_typeof = function _typeof(obj) {
return obj &&
typeof Symbol === 'function' &&
obj.constructor === Symbol &&
obj !== Symbol.prototype
? 'symbol'
: typeof obj
}
}
return _typeof(obj)
}
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _toConsumableArray(arr) {
return (
_arrayWithoutHoles(arr) ||
_iterableToArray(arr) ||
_unsupportedIterableToArray(arr) ||
_nonIterableSpread()
)
}
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _nonIterableSpread() {
throw new TypeError(
'Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'
)
}
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _unsupportedIterableToArray(o, minLen) {
if (!o) return
if (typeof o === 'string') return _arrayLikeToArray(o, minLen)
var n = Object.prototype.toString.call(o).slice(8, -1)
if (n === 'Object' && o.constructor) n = o.constructor.name
if (n === 'Map' || n === 'Set') return Array.from(n)
if (n === 'Arguments' || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
return _arrayLikeToArray(o, minLen)
}
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _iterableToArray(iter) {
if (typeof Symbol !== 'undefined' && Symbol.iterator in Object(iter))
return Array.from(iter)
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr)
}
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length
for (var i = 0, arr2 = new Array(len); i < len; i++) {
arr2[i] = arr[i]
}
return arr2
}
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function')
}
}
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i]
descriptor.enumerable = descriptor.enumerable || false
descriptor.configurable = true
if ('value' in descriptor) descriptor.writable = true
Object.defineProperty(target, descriptor.key, descriptor)
}
}
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps)
if (staticProps) _defineProperties(Constructor, staticProps)
return Constructor
}
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _createSuper(Derived) {
return function () {
var Super = _getPrototypeOf(Derived),
result
if (_isNativeReflectConstruct()) {
var NewTarget = _getPrototypeOf(this).constructor
result = Reflect.construct(Super, arguments, NewTarget)
} else {
result = Super.apply(this, arguments)
}
return _possibleConstructorReturn(this, result)
}
}
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _possibleConstructorReturn(self, call) {
if (call && (_typeof(call) === 'object' || typeof call === 'function')) {
return call
}
return _assertThisInitialized(self)
}
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError(
"this hasn't been initialised - super() hasn't been called"
)
}
return self
}
function _isNativeReflectConstruct() {
if (typeof Reflect === 'undefined' || !Reflect.construct) return false
if (Reflect.construct.sham) return false
if (typeof Proxy === 'function') return true
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}))
return true
} catch (e) {
return false
}
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf
? Object.getPrototypeOf
: function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o)
}
return _getPrototypeOf(o)
}
function _inherits(subClass, superClass) {
if (typeof superClass !== 'function' && superClass !== null) {
throw new TypeError('Super expression must either be null or a function')
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: { value: subClass, writable: true, configurable: true },
})
if (superClass) _setPrototypeOf(subClass, superClass)
}
function _setPrototypeOf(o, p) {
_setPrototypeOf =
Object.setPrototypeOf ||
function _setPrototypeOf(o, p) {
o.__proto__ = p
return o
}
return _setPrototypeOf(o, p)
}
var _require = require('caterpillar'),
Transform = _require.Transform;
Transform = _require.Transform
/**

@@ -43,65 +171,65 @@ Convert human readable Caterpillar entries into browser compatible entries

var Browser = /*#__PURE__*/ (function (_Transform) {
_inherits(Browser, _Transform)
var Browser =
/*#__PURE__*/
function (_Transform) {
_inherits(Browser, _Transform);
var _super = _createSuper(Browser)
function Browser() {
_classCallCheck(this, Browser);
function Browser() {
_classCallCheck(this, Browser)
return _possibleConstructorReturn(this, _getPrototypeOf(Browser).apply(this, arguments));
}
return _super.apply(this, arguments)
}
_createClass(Browser, [{
key: "getInitialConfig",
_createClass(Browser, [
{
key: 'getInitialConfig',
/**
/**
Get the initial configuration.
@returns {Object}
*/
value: function getInitialConfig() {
return {
color: true,
write: true,
styles: {
red: {
start: 31,
end: 39,
value: 'color:red'
},
yellow: {
start: 33,
end: 39,
value: 'color:orange'
},
green: {
start: 32,
end: 39,
value: 'color:green'
},
bright: {
start: 1,
end: 22,
value: 'font-weight:bold'
},
dim: {
start: 2,
end: 22,
value: 'color:lightGray'
},
italic: {
start: 3,
end: 23,
value: 'font-style:italic'
},
underline: {
start: 4,
end: 24,
value: 'text-decoration:underline'
}
}
};
}
/**
value: function getInitialConfig() {
return {
color: true,
write: true,
styles: {
red: {
start: 31,
end: 39,
value: 'color:red',
},
yellow: {
start: 33,
end: 39,
value: 'color:orange',
},
green: {
start: 32,
end: 39,
value: 'color:green',
},
bright: {
start: 1,
end: 22,
value: 'font-weight:bold',
},
dim: {
start: 2,
end: 22,
value: 'color:lightGray',
},
italic: {
start: 3,
end: 23,
value: 'font-style:italic',
},
underline: {
start: 4,
end: 24,
value: 'text-decoration:underline',
},
},
}
},
/**
Convert a human readable Caterpillar entry into a format that browser consoles can understand.

@@ -112,56 +240,61 @@ And if the `write` config property is `true` (it is by default), write the result to the browser console.

*/
},
{
key: 'format',
value: function format(message) {
var _console
}, {
key: "format",
value: function format(message) {
var _console;
// Prepare
var _this$getConfig = this.getConfig(),
color = _this$getConfig.color,
styles = _this$getConfig.styles,
write = _this$getConfig.write // Replace caterpillar-human formatted entry
// Prepare
var _this$getConfig = this.getConfig(),
color = _this$getConfig.color,
styles = _this$getConfig.styles,
write = _this$getConfig.write; // Replace caterpillar-human formatted entry
var args = []
/* eslint no-control-regex:0 */
var result = message.replace(
/\u001b\[([0-9]+)m(.+?)\u001b\[([0-9]+)m/g,
function (match, start, content, end) {
// Check
if (color === false) return content // Prepare
var args = [];
/* eslint no-control-regex:0 */
var matchedStyle, style // Find the matcing style for this combination
var result = message.replace(/\u001b\[([0-9]+)m(.+?)\u001b\[([0-9]+)m/g, function (match, start, content, end) {
// Check
if (color === false) return content; // Prepare
for (var key in styles) {
if (styles.hasOwnProperty(key)) {
style = styles[key]
var matchedStyle, style; // Find the matcing style for this combination
if (
String(style.start) === String(start) &&
String(style.end) === String(end)
) {
matchedStyle = style
break
}
}
} // Check
for (var key in styles) {
if (styles.hasOwnProperty(key)) {
style = styles[key];
if (!matchedStyle) return content // Push the style
if (String(style.start) === String(start) && String(style.end) === String(end)) {
matchedStyle = style;
break;
}
}
} // Check
args.push(style.value)
args.push(content)
args.push('color:default; font:default; text-decoration:default')
return '%c%s%c'
}
) // Final format
var parts = [result.trim()].concat(args) // Write
if (!matchedStyle) return content; // Push the style
if (write)
(_console = console).log.apply(_console, _toConsumableArray(parts)) // Return
args.push(style.value);
args.push(content);
args.push('color:default; font:default; text-decoration:default');
return '%c%s%c';
}); // Final format
return parts
},
},
])
var parts = [result.trim()].concat(args); // Write
return Browser
})(Transform) // Export
if (write) (_console = console).log.apply(_console, _toConsumableArray(parts)); // Return
return parts;
}
}]);
return Browser;
}(Transform); // Export
module.exports = Browser;
module.exports = Browser
# History
## v5.0.0 2020 March 26
- Updated dependencies, [base files](https://github.com/bevry/base), and [editions](https://editions.bevry.me) using [boundation](https://github.com/bevry/boundation)
- Minimum required node version changed from `node: >=8` to `node: >=10` to keep up with mandatory ecosystem changes
## v4.5.0 2019 December 9

@@ -4,0 +9,0 @@

{
"title": "Browser Transform for [Caterpillar](https://github.com/bevry/caterpillar)",
"name": "caterpillar-browser",
"version": "4.5.0",
"version": "5.0.0-next.1585174269.832d3a153d8de2abd5184756e529da872daeac8b",
"description": "Use Caterpillar within Web Browsers! (even includes support for colors!)",

@@ -9,13 +9,15 @@ "homepage": "https://github.com/bevry/caterpillar-browser",

"keywords": [
"browser",
"caterpillar",
"caterpillar-transform",
"console",
"console.log",
"debug",
"log",
"logger",
"logging",
"debug",
"stream",
"transform",
"browser",
"console.log"
"typed",
"types"
],

@@ -59,4 +61,3 @@ "badges": {

"contributors": [
"Benjamin Lupton <b@lupton.cc> (http://balupton.com)",
"dependabot-preview[bot] (http://github.com/apps/dependabot-preview)"
"Benjamin Lupton <b@lupton.cc> (http://balupton.com)"
],

@@ -71,7 +72,7 @@ "bugs": {

"engines": {
"node": ">=8"
"node": ">=10"
},
"editions": [
{
"description": "esnext source code with require for modules",
"description": "ESNext source code for Node.js with Require for modules",
"directory": "source",

@@ -85,3 +86,3 @@ "entry": "index.js",

"engines": {
"node": "8 || 10 || 12",
"node": "10 || 12",
"browsers": false

@@ -91,3 +92,3 @@ }

{
"description": "esnext compiled for browsers with require for modules",
"description": "ESNext compiled for web browsers with Require for modules",
"directory": "edition-browsers",

@@ -109,25 +110,25 @@ "entry": "index.js",

"devDependencies": {
"@babel/cli": "^7.7.5",
"@babel/core": "^7.7.5",
"@babel/plugin-proposal-object-rest-spread": "^7.7.4",
"@babel/preset-env": "^7.7.6",
"assert-helpers": "^5.8.0",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/plugin-proposal-object-rest-spread": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"assert-helpers": "^6.0.0",
"caterpillar": "^4.0.0",
"caterpillar-human": "^4.4.0",
"eslint": "^6.7.2",
"eslint-config-bevry": "^2.2.0",
"eslint-config-prettier": "^6.7.0",
"caterpillar-human": "^4.5.0",
"eslint": "^6.8.0",
"eslint-config-bevry": "^2.3.0",
"eslint-config-prettier": "^6.10.1",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-prettier": "^3.1.2",
"jsdoc": "^3.6.3",
"kava": "^4.3.0",
"kava": "^4.4.0",
"minami": "^1.2.3",
"prettier": "^1.19.1",
"projectz": "^1.15.0",
"prettier": "^2.0.2",
"projectz": "^1.19.0",
"surge": "^0.21.3",
"valid-directory": "^1.5.0"
"valid-directory": "^1.6.0"
},
"peerDependencies": {
"caterpillar": "^4.0.0",
"caterpillar-human": "^4.4.0"
"caterpillar-human": "^4.5.0"
},

@@ -153,5 +154,5 @@ "scripts": {

"our:verify": "npm run our:verify:directory && npm run our:verify:eslint && npm run our:verify:prettier",
"our:verify:directory": "npx valid-directory",
"our:verify:directory": "valid-directory",
"our:verify:eslint": "eslint --fix --ignore-pattern '**/*.d.ts' --ignore-pattern '**/vendor/' --ignore-pattern '**/node_modules/' --ext .mjs,.js,.jsx,.ts,.tsx ./source",
"our:verify:prettier": "prettier --write ./source/**",
"our:verify:prettier": "prettier --write .",
"test": "node ./source/test.js"

@@ -176,3 +177,6 @@ },

{
"targets": "defaults",
"targets": {
"esmodules": false,
"browsers": "defaults"
},
"modules": false

@@ -179,0 +183,0 @@ }

@@ -36,2 +36,10 @@ <!-- TITLE/ -->

## Usage
[Complete API Documentation.](http://master.caterpillar-browser.bevry.surge.sh/docs/)
[Example.](https://github.com/bevry/caterpillar-examples/blob/master/all.js)
[Run the example in your web browser.](http://rawgit.com/bevry/caterpillar-examples/master/index.html)
<!-- INSTALL/ -->

@@ -44,3 +52,4 @@

<li>Install: <code>npm install --save caterpillar-browser</code></li>
<li>Require: <code>require('caterpillar-browser')</code></li>
<li>Import: <code>import * as pkg from ('caterpillar-browser')</code></li>
<li>Require: <code>const pkg = require('caterpillar-browser')</code></li>
</ul>

@@ -52,3 +61,3 @@

<script type="module">
import * as pkg from '//dev.jspm.io/caterpillar-browser'
import * as pkg from '//dev.jspm.io/caterpillar-browser@5.0.0'
</script>

@@ -62,4 +71,4 @@ ```

<ul><li><code>caterpillar-browser</code> aliases <code>caterpillar-browser/source/index.js</code></li>
<li><code>caterpillar-browser/source/index.js</code> is esnext source code with require for modules</li>
<li><code>caterpillar-browser/edition-browsers/index.js</code> is esnext compiled for browsers with require for modules</li></ul>
<li><code>caterpillar-browser/source/index.js</code> is <a href="https://en.wikipedia.org/wiki/ECMAScript#ES.Next" title="ECMAScript Next">ESNext</a> source code for <a href="https://nodejs.org" title="Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine">Node.js</a> with <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a> for modules</li>
<li><code>caterpillar-browser/edition-browsers/index.js</code> is <a href="https://en.wikipedia.org/wiki/ECMAScript#ES.Next" title="ECMAScript Next">ESNext</a> compiled for web browsers with <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a> for modules</li></ul>

@@ -81,10 +90,2 @@ <h3><a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a></h3>

## Usage
[API Documentation.](http://master.caterpillar-browser.bevry.surge.sh/docs/)
[Example.](https://github.com/bevry/caterpillar-examples/blob/master/all.js)
[Run the example in your web browser.](http://rawgit.com/bevry/caterpillar-examples/master/index.html)
<!-- HISTORY/ -->

@@ -107,3 +108,3 @@

<ul><li><a href="http://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/caterpillar-browser/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/caterpillar-browser">view contributions</a></li></ul>
<ul><li><a href="http://balupton.com">Benjamin Lupton</a></li></ul>

@@ -128,4 +129,3 @@ <h3>Sponsors</h3>

<ul><li><a href="http://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/caterpillar-browser/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/caterpillar-browser">view contributions</a></li>
<li><a href="http://github.com/apps/dependabot-preview">dependabot-preview[bot]</a> — <a href="https://github.com/bevry/caterpillar-browser/commits?author=dependabot-preview[bot]" title="View the GitHub contributions of dependabot-preview[bot] on repository bevry/caterpillar-browser">view contributions</a></li></ul>
<ul><li><a href="http://balupton.com">Benjamin Lupton</a></li></ul>

@@ -132,0 +132,0 @@ <a href="https://github.com/bevry/caterpillar-browser/blob/master/CONTRIBUTING.md#files">Discover how you can contribute by heading on over to the <code>CONTRIBUTING.md</code> file.</a>

@@ -29,3 +29,3 @@ // @ts-check

end: 39,
value: 'color:red'
value: 'color:red',
},

@@ -35,3 +35,3 @@ yellow: {

end: 39,
value: 'color:orange'
value: 'color:orange',
},

@@ -41,3 +41,3 @@ green: {

end: 39,
value: 'color:green'
value: 'color:green',
},

@@ -47,3 +47,3 @@ bright: {

end: 22,
value: 'font-weight:bold'
value: 'font-weight:bold',
},

@@ -53,3 +53,3 @@ dim: {

end: 22,
value: 'color:lightGray'
value: 'color:lightGray',
},

@@ -59,3 +59,3 @@ italic: {

end: 23,
value: 'font-style:italic'
value: 'font-style:italic',
},

@@ -65,5 +65,5 @@ underline: {

end: 24,
value: 'text-decoration:underline'
}
}
value: 'text-decoration:underline',
},
},
}

@@ -87,3 +87,3 @@ }

/\u001b\[([0-9]+)m(.+?)\u001b\[([0-9]+)m/g,
function(match, start, content, end) {
function (match, start, content, end) {
// Check

@@ -90,0 +90,0 @@ if (color === false) return content

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