Comparing version 1.9.1 to 1.10.0
# 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** |
{ | ||
"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" | ||
} |
61
splat.js
@@ -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 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74400
56
1830
7
2