diff --git a/changelog.md b/changelog.md index d5639fa..a76471a 100644 --- a/changelog.md +++ b/changelog.md @@ -8,4 +8,5 @@ * `.plugin` calls plugin function with `(app, options)` [semver-major] * Plugin function return value conform to object [semver-major] +* Move utils to `lib/utils` * Fix changelog diff --git a/lib/index.js b/lib/index.js index 15d16e0..f8fcdd6 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5,8 +5,7 @@ 'use strict'; // Imports -const snakeToCamel = require('./snakeToCamel'), - isObject = require('./isObject'); +const {isObject, snakeToCamel} = require('./utils'); // Constants const PLUGIN_PREFIX = '_pluginPrefix'; diff --git a/lib/isObject.js b/lib/isObject.js deleted file mode 100644 index 381b8e1..0000000 --- a/lib/isObject.js +++ /dev/null @@ -1,17 +0,0 @@ -/* -------------------- - * pluggi module - * isObject() function - * ------------------*/ - -'use strict'; - -// Exports - -/** - * Return true if input is an object - * @param {*} obj - Input - * @returns {boolean} - `true` if is an object, `false` if not - */ -module.exports = function(obj) { - return obj !== null && typeof obj == 'object'; -}; diff --git a/lib/snakeToCamel.js b/lib/snakeToCamel.js deleted file mode 100644 index 22ccade..0000000 --- a/lib/snakeToCamel.js +++ /dev/null @@ -1,18 +0,0 @@ -/* -------------------- - * pluggi module - * snakeToCamel() function - * ------------------*/ - -'use strict'; - -// Exports - -/** - * Convert snake case to camel case - * e.g. 'my-module-name' -> 'myModuleName' - * @param {string} str - Snake case string - * @returns {string} - Camel case string - */ -module.exports = function(str) { - return str.replace(/-(.)/g, (m, c) => c.toUpperCase()); // jshint ignore:line -}; diff --git a/lib/utils.js b/lib/utils.js new file mode 100644 index 0000000..e85716d --- /dev/null +++ b/lib/utils.js @@ -0,0 +1,29 @@ +/* -------------------- + * pluggi module + * utils + * ------------------*/ + +'use strict'; + +// Exports + +module.exports = { + /** + * Convert snake case to camel case + * e.g. 'my-module-name' -> 'myModuleName' + * @param {string} str - Snake case string + * @returns {string} - Camel case string + */ + snakeToCamel: function(str) { + return str.replace(/-(.)/g, (m, c) => c.toUpperCase()); // jshint ignore:line + }, + + /** + * Identify if input is an object + * @param {*} obj - Input + * @returns {boolean} - `true` if is an object, `false` if not + */ + isObject: function(obj) { + return obj !== null && typeof obj == 'object'; + } +};