Skip to content

Commit

Permalink
Rename keepFuncName to keepProps
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Aug 22, 2018
1 parent fb09149 commit 37a51c3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/errors/handler.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict'

const { keepFuncName } = require('../utils')
const { keepProps } = require('../utils')

// Wrap a function with a error handler
// Allow passing an empty error handler, i.e. ignoring any error thrown
const addErrorHandler = function(func, errorHandler = () => {}) {
return errorHandledFunc.bind(null, func, errorHandler)
}

const kAddErrorHandler = keepFuncName(addErrorHandler)
const kAddErrorHandler = keepProps(addErrorHandler)

const errorHandledFunc = function(func, errorHandler, ...args) {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
...require('./types'),
...require('./promise'),
...require('./reduce'),
...require('./func_name'),
...require('./keep_props'),
...require('./sort'),
...require('./location'),
...require('./simple_schema'),
Expand Down
4 changes: 2 additions & 2 deletions src/utils/func_name.js → src/utils/keep_props.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

// Wraps a functor so it does not modify a function `name`, `length`, etc.
const keepFuncName = function(functor) {
const keepProps = function(functor) {
return (originalFunc, ...args) => {
const wrappedFunc = functor(originalFunc, ...args)

Expand All @@ -23,5 +23,5 @@ const copyProperty = function({ originalFunc, wrappedFunc, propName }) {
}

module.exports = {
keepFuncName,
keepProps,
}

0 comments on commit 37a51c3

Please sign in to comment.