Skip to content

Commit

Permalink
Move utils to lib/utils
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Jul 21, 2018
1 parent cc2e3e9 commit 4a53a44
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 37 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
'use strict';

// Imports
const snakeToCamel = require('./snakeToCamel'),
isObject = require('./isObject');
const {isObject, snakeToCamel} = require('./utils');

// Constants
const PLUGIN_PREFIX = '_pluginPrefix';
Expand Down
17 changes: 0 additions & 17 deletions lib/isObject.js

This file was deleted.

18 changes: 0 additions & 18 deletions lib/snakeToCamel.js

This file was deleted.

29 changes: 29 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -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';
}
};

0 comments on commit 4a53a44

Please sign in to comment.