[Pkg-javascript-commits] [node-tap] 15/186: more => immediates, less function decls
Bastien Roucariès
rouca at moszumanska.debian.org
Fri Dec 1 16:40:39 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-tap.
commit 9fc8be35d6e417b26d0bdd30ca2fbebf0a1559b7
Author: isaacs <i at izs.me>
Date: Sat Aug 12 20:38:06 2017 -0700
more => immediates, less function decls
---
lib/clean-yaml-object.js | 16 +++++++---------
lib/obj-to-yaml.js | 20 +++++++-------------
2 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/lib/clean-yaml-object.js b/lib/clean-yaml-object.js
index 8d25364..d123e1e 100644
--- a/lib/clean-yaml-object.js
+++ b/lib/clean-yaml-object.js
@@ -7,13 +7,10 @@ const binpath = path.resolve(__dirname, '../bin')
const stack = require('./stack.js')
const Domain = require('domain').Domain
-function hasOwn (obj, key) {
- return Object.prototype.hasOwnProperty.call(obj, key)
-}
-
-module.exports = cleanTapYamlObject
+const hasOwn = (obj, key) =>
+ Object.prototype.hasOwnProperty.call(obj, key)
-function cleanTapYamlObject (object) {
+const cleanTapYamlObject = object => {
if (hasOwn(object, 'stack') && !hasOwn(object, 'at'))
object.at = stack.parseLine(object.stack.split('\n')[0])
@@ -37,8 +34,8 @@ function cleanTapYamlObject (object) {
return cleanYamlObject(object, yamlFilter)
}
-function yamlFilter (propertyName, isRoot, source, target) {
- return source instanceof Domain ? false
+const yamlFilter = (propertyName, isRoot, source, target) =>
+ source instanceof Domain ? false
: !isRoot ? true
: propertyName === 'stack' ? (
(source.stack ? target.stack = source.stack : false), false)
@@ -62,4 +59,5 @@ function yamlFilter (propertyName, isRoot, source, target) {
propertyName === 'domainThrew' ||
propertyName === 'domain' ||
(propertyName === 'at' && !source.at))
-}
+
+module.exports = cleanTapYamlObject
diff --git a/lib/obj-to-yaml.js b/lib/obj-to-yaml.js
index 4f51ec4..018f8a0 100644
--- a/lib/obj-to-yaml.js
+++ b/lib/obj-to-yaml.js
@@ -1,18 +1,12 @@
'use strict'
-module.exports = objToYaml
const cleanYamlObject = require('./clean-yaml-object.js')
const yaml = require('js-yaml')
-function objToYaml (obj) {
- obj = cleanYamlObject(obj)
- let ret = ''
- if (obj && typeof obj === 'object' && Object.keys(obj).length) {
- const y = yaml.safeDump(obj).split('\n').map(function (l) {
- return l.trim() ? ' ' + l : l.trim()
- }).join('\n')
- ret = ' ---\n' + y + ' ...\n'
- }
-
- return ret
-}
+module.exports = obj => (clean =>
+ (clean && typeof clean === 'object' && Object.keys(clean).length) ?
+ ' ---\n' + (yaml.safeDump(clean).split('\n').map(
+ l => l.trim() ? ' ' + l : l.trim()
+ ).join('\n')) + ' ...\n'
+ : ''
+)(cleanYamlObject(obj))
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-tap.git
More information about the Pkg-javascript-commits
mailing list