fix: console stringify

This commit is contained in:
redhoodsu
2019-08-04 18:18:13 +08:00
parent d5f2b5d303
commit 2cc7e386e1
3 changed files with 51 additions and 3 deletions

View File

@@ -1740,6 +1740,19 @@ loadJs('main.js', function (isLoaded) {
});
```
## lowerCase
Convert string to lower case.
|Name |Type |Desc |
|------|------|------------------|
|str |string|String to convert |
|return|string|Lower cased string|
```javascript
lowerCase('TEST'); // -> 'test'
```
## lpad
Pad string on the left side if it's shorter than length.

View File

@@ -15,7 +15,8 @@ import {
isNum,
isBool,
keys,
trim
trim,
lowerCase
} from './util'
export default class JsonViewer {
@@ -83,11 +84,15 @@ export default class JsonViewer {
if (val === null) {
return `<li>${wrapKey(key)}<span class="eruda-null">null</span></li>`
} else if (type === 'Number' || isNum(val) || isBool(val)) {
} else if (val.type === 'Number' || isNum(val) || isBool(val)) {
return `<li>${wrapKey(key)}<span class="eruda-${typeof val}">${encode(
val
)}</span></li>`
} else if (type === 'Undefined' || val === 'Symbol' || val === '(...)') {
} else if (val.type === 'Undefined' || val.type === 'Symbol') {
return `<li>${wrapKey(key)}<span class="eruda-special">${lowerCase(
val.type
)}</span></li>`
} else if (val === '(...)') {
return `<li>${wrapKey(key)}<span class="eruda-special">${val}</span></li>`
} else if (isObj(val)) {
id = val.id

View File

@@ -2734,6 +2734,36 @@ export var loadJs = _.loadJs = (function (exports) {
return exports;
})({});
/* ------------------------------ lowerCase ------------------------------ */
export var lowerCase = _.lowerCase = (function (exports) {
/* Convert string to lower case.
*
* |Name |Type |Desc |
* |------|------|------------------|
* |str |string|String to convert |
* |return|string|Lower cased string|
*/
/* example
* lowerCase('TEST'); // -> 'test'
*/
/* typescript
* export declare function lowerCase(str: string): string;
*/
/* dependencies
* toStr
*/
exports = function exports(str) {
return toStr(str).toLocaleLowerCase();
};
return exports;
})({});
/* ------------------------------ repeat ------------------------------ */
export var repeat = _.repeat = (function (exports) {