Erster Docker-Stand
This commit is contained in:
3
_node_modules/@chevrotain/utils/src/api.ts
generated
Normal file
3
_node_modules/@chevrotain/utils/src/api.ts
generated
Normal file
@@ -0,0 +1,3 @@
|
||||
export { PRINT_WARNING, PRINT_ERROR } from "./print"
|
||||
export { timer } from "./timer"
|
||||
export { toFastProperties } from "./to-fast-properties"
|
||||
14
_node_modules/@chevrotain/utils/src/print.ts
generated
Normal file
14
_node_modules/@chevrotain/utils/src/print.ts
generated
Normal file
@@ -0,0 +1,14 @@
|
||||
export function PRINT_ERROR(msg: string) {
|
||||
/* istanbul ignore else - can't override global.console in node.js */
|
||||
if (console && console.error) {
|
||||
console.error(`Error: ${msg}`)
|
||||
}
|
||||
}
|
||||
|
||||
export function PRINT_WARNING(msg: string) {
|
||||
/* istanbul ignore else - can't override global.console in node.js*/
|
||||
if (console && console.warn) {
|
||||
// TODO: modify docs accordingly
|
||||
console.warn(`Warning: ${msg}`)
|
||||
}
|
||||
}
|
||||
7
_node_modules/@chevrotain/utils/src/timer.ts
generated
Normal file
7
_node_modules/@chevrotain/utils/src/timer.ts
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
export function timer<T>(func: () => T): { time: number; value: T } {
|
||||
const start = new Date().getTime()
|
||||
const val = func()
|
||||
const end = new Date().getTime()
|
||||
const total = end - start
|
||||
return { time: total, value: val }
|
||||
}
|
||||
26
_node_modules/@chevrotain/utils/src/to-fast-properties.ts
generated
Normal file
26
_node_modules/@chevrotain/utils/src/to-fast-properties.ts
generated
Normal file
@@ -0,0 +1,26 @@
|
||||
// based on: https://github.com/petkaantonov/bluebird/blob/b97c0d2d487e8c5076e8bd897e0dcd4622d31846/src/util.js#L201-L216
|
||||
export function toFastProperties(toBecomeFast: any) {
|
||||
function FakeConstructor() {}
|
||||
|
||||
// If our object is used as a constructor it would receive
|
||||
FakeConstructor.prototype = toBecomeFast
|
||||
const fakeInstance = new (FakeConstructor as any)()
|
||||
|
||||
function fakeAccess() {
|
||||
return typeof fakeInstance.bar
|
||||
}
|
||||
|
||||
// help V8 understand this is a "real" prototype by actually using
|
||||
// the fake instance.
|
||||
fakeAccess()
|
||||
fakeAccess()
|
||||
|
||||
// Always true condition to suppress the Firefox warning of unreachable
|
||||
// code after a return statement.
|
||||
if (1) return toBecomeFast
|
||||
|
||||
// Eval prevents optimization of this method (even though this is dead code)
|
||||
/* istanbul ignore next */
|
||||
// tslint:disable-next-line
|
||||
eval(toBecomeFast)
|
||||
}
|
||||
Reference in New Issue
Block a user