log-ocd
Version:
the best node.js logger
61 lines (53 loc) • 1.55 kB
JavaScript
/**
* -----------------------------------------------------------------------------
* LOG-OCD: STYLE VALUES HELPERS - NEW-THEME-PROP
* -----------------------------------------------------------------------------
* @version 1.0.0-beta.11
* @see [log-ocd]{@link https://github.com/imaginate/log-ocd}
*
* @author Adam Smith <imagineadamsmith@gmail.com> (https://github.com/imaginate)
* @copyright 2022 Adam A Smith <imagineadamsmith@gmail.com> (https://github.com/imaginate)
*
* Supporting Libraries:
* @see [chalk]{@link https://github.com/chalk/chalk}
* @see [vitals]{@link https://github.com/imaginate/vitals}
*
* Annotations:
* @see [JSDoc3]{@link http://usejsdoc.org/}
* @see [Closure Compiler specific JSDoc]{@link https://developers.google.com/closure/compiler/docs/js-for-compiler}
*/
;
var is = require('../../../../helpers').is;
/**
* @typedef {!{
* type: string,
* val: (?string|boolean),
* make: boolean,
* props: Object
* }} ThemeProp
*/
/**
* @private
* @param {(string|boolean|Object)} val - If object the val is considered props.
* @return {!ThemeProp}
*/
module.exports = function newThemeProp(val) {
/** @type {!Object} */
var prop;
/** @type {boolean} */
var make;
/** @type {string} */
var type;
type = is.str(val)
? 'string'
: is.bool(val)
? 'boolean'
: '!object';
make = type === '!object';
prop = {};
prop.type = type;
prop.make = make;
prop.props = make ? val : null;
prop.val = make ? null : val;
return prop;
};