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

logform

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logform - npm Package Compare versions

Comparing version 1.9.1 to 1.10.0

.babelrc

7

CHANGELOG.md
# CHANGELOG
### 1.10.0
**2018/09/17**
- [#52] Add types field in package.json.
- [#46], [#49] Changes for splat when there are no tokens present and no splat present.
- [#47], [#53] Expose transpiled code for Browser-only scenarios.
### 1.9.1

@@ -4,0 +11,0 @@ **2018/06/26**

18

package.json
{
"name": "logform",
"version": "1.9.1",
"version": "1.10.0",
"description": "An mutable object-based log format designed for chaining & objectMode streams.",
"main": "index.js",
"browser": "browser.js",
"browser": "dist/browser.js",
"scripts": {
"lint": "populist *.js test/*.js examples/*.js",
"pretest": "npm run lint",
"test": "nyc mocha test/*.test.js"
"pretest": "npm run lint && npm run build",
"test": "nyc mocha test/*.test.js",
"build": "rimraf dist && babel *.js -d ./dist",
"prepublishOnly": "npm run build"
},

@@ -37,6 +39,10 @@ "repository": {

"assume": "^2.0.1",
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"eslint-config-populist": "^4.1.0",
"mocha": "^5.1.1",
"nyc": "^11.7.1"
}
"nyc": "^11.7.1",
"rimraf": "^2.6.2"
},
"types": "./index.d.ts"
}

@@ -26,13 +26,13 @@ 'use strict';

/**
* Check to see if tokens <= splat.length, assign { splat, meta } into the
* `info` accordingly, and write to this instance.
*
* @param {Info} info Logform info message.
* @param {String[]} tokens Set of string interpolation tokens.
* @returns {Info} Modified info message
* @private
*/
* Check to see if tokens <= splat.length, assign { splat, meta } into the
* `info` accordingly, and write to this instance.
*
* @param {Info} info Logform info message.
* @param {String[]} tokens Set of string interpolation tokens.
* @returns {Info} Modified info message
* @private
*/
_splat(info, tokens) {
const msg = info.message;
const splat = info[SPLAT] || [];
const splat = info[SPLAT] || info.splat || [];
const percents = msg.match(escapedPercent);

@@ -74,18 +74,37 @@ const escapes = percents && percents.length || 0;

/**
* Transforms the `info` message by using `util.format` to complete
* any `info.message` provided it has string interpolation tokens.
* If no tokens exist then `info` is immutable.
*
* @param {Info} info Logform info message.
* @param {Object} opts Options for this instance.
* @returns {Info} Modified info message
*/
* Transforms the `info` message by using `util.format` to complete
* any `info.message` provided it has string interpolation tokens.
* If no tokens exist then `info` is immutable.
*
* @param {Info} info Logform info message.
* @param {Object} opts Options for this instance.
* @returns {Info} Modified info message
*/
transform(info) {
const msg = info.message;
const splat = info[SPLAT];
const splat = info[SPLAT] || info.splat;
// Evaluate if the message has any interpolation tokens. If not,
// then let evaluation continue.
// No need to process anything if splat is undefined
if (!splat || !splat.length) {
return info;
}
// Extract tokens, if none available default to empty array to
// ensure consistancy in expected results
const tokens = msg && msg.match && msg.match(formatRegExp);
if (!tokens && (!splat || !splat.length)) {
// This condition will take care of inputs with info[SPLAT]
// but no tokens present
if (!tokens && (splat || splat.length)) {
const metas = splat.length > 1
? splat.splice(0)
: splat;
// Now that { splat } has been separated from any potential { meta }. we
// can assign this to the `info` object and write it to our format stream.
if (metas.length === 1) {
info.meta = metas[0];
} else if (metas.length) {
info.meta = metas;
}
return info;

@@ -92,0 +111,0 @@ }

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