Skip to content
This repository was archived by the owner on Feb 4, 2018. It is now read-only.

Commit 3d2ea28

Browse files
author
blond
committed
refactor(deprecation): add deprecate util
1 parent aa08471 commit 3d2ea28

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/deprecate.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const util = require('util');
2+
3+
const deprecate = require('depd')(require('../package.json').name);
4+
5+
/**
6+
* Logs deprecation messages.
7+
*
8+
* @param {object} obj
9+
* @param {string} deprecateName
10+
* @param {string} newName
11+
*/
12+
module.exports = (obj, deprecateName, newName) => {
13+
const objStr = util.inspect(obj, { depth: 1 });
14+
const message = [
15+
`\`${deprecateName}\` is kept just for compatibility and can be dropped in the future.`,
16+
`Use \`${newName}\` instead in \`${objStr}\` at`
17+
].join(' ');
18+
19+
deprecate(message);
20+
};

0 commit comments

Comments
 (0)