1
0
mirror of synced 2025-12-12 09:41:28 +08:00

Fix: getObjType

This commit is contained in:
surunzi
2017-01-14 12:12:22 +08:00
parent 086761124b
commit 2dedb58e10
2 changed files with 31 additions and 29 deletions

View File

@@ -1,6 +1,8 @@
_('upperFirst');
function exports(obj)
{
if (obj.constructor && obj.constructor.name) return obj.constructor.name;
return util.upperFirst(({}).toString.call(obj).replace(/(\[object )|]/g, ''));
}
return upperFirst(({}).toString.call(obj).replace(/(\[object )|]/g, ''));
}

View File

@@ -597,6 +597,32 @@ module.exports = (function ()
return exports;
})();
/* ------------------------------ upperFirst ------------------------------ */
var upperFirst = _.upperFirst = (function ()
{
/* Convert the first character of string to upper case.
*
* |Name |Type |Desc |
* |------|------|-----------------|
* |str |string|String to convert|
* |return|string|Converted string |
*
* ```javascript
* upperFirst('red'); // -> Red
* ```
*/
function exports(str)
{
if (str.length < 1) return str;
return str[0].toUpperCase() + str.slice(1);
}
return exports;
})();
/* ------------------------------ getObjType ------------------------------ */
var getObjType = _.getObjType = (function ()
@@ -605,7 +631,7 @@ module.exports = (function ()
{
if (obj.constructor && obj.constructor.name) return obj.constructor.name;
return util.upperFirst(({}).toString.call(obj).replace(/(\[object )|]/g, ''));
return upperFirst(({}).toString.call(obj).replace(/(\[object )|]/g, ''));
}
return exports;
@@ -4022,32 +4048,6 @@ module.exports = (function ()
return exports;
})();
/* ------------------------------ upperFirst ------------------------------ */
var upperFirst = _.upperFirst = (function ()
{
/* Convert the first character of string to upper case.
*
* |Name |Type |Desc |
* |------|------|-----------------|
* |str |string|String to convert|
* |return|string|Converted string |
*
* ```javascript
* upperFirst('red'); // -> Red
* ```
*/
function exports(str)
{
if (str.length < 1) return str;
return str[0].toUpperCase() + str.slice(1);
}
return exports;
})();
/* ------------------------------ wrap ------------------------------ */
var wrap = _.wrap = (function ()