@magnetarjs/utils
Advanced tools
Comparing version 0.16.15 to 0.16.16
@@ -31,4 +31,10 @@ import { Clauses, EventFnSuccess } from '@magnetarjs/types'; | ||
declare function logWithFlair(message: string, ...args: any[]): void; | ||
/** | ||
* Logs to the console with `console.groupCollapsed` and colors. | ||
*/ | ||
declare function logWithFlairGroup(title: string, nestedMessage: string, options?: { | ||
preventLogFor: number; | ||
}): void; | ||
declare const logger: EventFnSuccess; | ||
export { arrStr, countCharacter, filterDataPerClauses, isCollectionModule, isDocModule, isEven, isOdd, logWithFlair, logger, parseValueForFilters }; | ||
export { arrStr, countCharacter, filterDataPerClauses, isCollectionModule, isDocModule, isEven, isOdd, logWithFlair, logWithFlairGroup, logger, parseValueForFilters }; |
@@ -31,2 +31,3 @@ "use strict"; | ||
logWithFlair: () => logWithFlair, | ||
logWithFlairGroup: () => logWithFlairGroup, | ||
logger: () => logger, | ||
@@ -180,9 +181,24 @@ parseValueForFilters: () => parseValueForFilters | ||
var import_is_what3 = require("is-what"); | ||
var LOGGER_STYLE = "background: #0e0f15; color: #af98e6; border-radius: 4px; padding: 6px 10px; line-height: 2;"; | ||
function logWithFlair(message, ...args) { | ||
console.info( | ||
`%c\u{1F4AB} [magnetar] ${message}`, | ||
"background: #0e0f15; color: #af98e6; border-radius: 4px; padding: 6px 10px;", | ||
...args | ||
); | ||
console.info(`%c\u{1F4AB} [magnetar] ${message}`, LOGGER_STYLE, ...args); | ||
} | ||
var lastGroupLogTime = 0; | ||
var lastGroupParams = null; | ||
function shouldLog(params, preventLogFor) { | ||
const now = Date.now(); | ||
if (now - lastGroupLogTime < preventLogFor && JSON.stringify(params) === JSON.stringify(lastGroupParams)) { | ||
return false; | ||
} | ||
lastGroupLogTime = now; | ||
lastGroupParams = params; | ||
return true; | ||
} | ||
function logWithFlairGroup(title, nestedMessage, options) { | ||
if (options && !shouldLog([title, nestedMessage], options.preventLogFor)) | ||
return; | ||
console.groupCollapsed(`%c\u{1F4AB} [magnetar] ${title}`, LOGGER_STYLE); | ||
console.log(nestedMessage); | ||
console.groupEnd(); | ||
} | ||
function stringifyQueryClause(q) { | ||
@@ -231,4 +247,5 @@ return "or" in q ? `or(${q.or.map( | ||
logWithFlair, | ||
logWithFlairGroup, | ||
logger, | ||
parseValueForFilters | ||
}); |
{ | ||
"name": "@magnetarjs/utils", | ||
"version": "0.16.15", | ||
"version": "0.16.16", | ||
"sideEffects": false, | ||
@@ -25,3 +25,3 @@ "description": "Magnetar utils like a logger for easier development", | ||
"path-to-prop": "^2.0.4", | ||
"@magnetarjs/types": "0.16.15" | ||
"@magnetarjs/types": "0.16.16" | ||
}, | ||
@@ -28,0 +28,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19656
477
+ Added@magnetarjs/types@0.16.16(transitive)
- Removed@magnetarjs/types@0.16.15(transitive)
Updated@magnetarjs/types@0.16.16