@garfish/utils
Advanced tools
Comparing version 0.0.13 to 0.0.15
@@ -462,2 +462,49 @@ 'use strict'; | ||
function filterAndWrapEventListener(type, listener, sourceList) { | ||
const errorHandler = function (e) { | ||
// Conform to the file list type trigger collection of events | ||
if (typeof listener === 'function') { | ||
// Through error stack source file, and the source of the static resources determine whether the current error belongs to the current application | ||
// if belong to the current application environment monitoring error | ||
if (sourceList) { | ||
const res = sourceList.find((item) => { | ||
return item.indexOf(computeErrorUrl(e)) !== -1; | ||
}); | ||
if (res) { | ||
// e.stopPropagation(); | ||
listener(e); | ||
} | ||
} | ||
else { | ||
listener(e); | ||
} | ||
} | ||
}; | ||
const unhandledrejection = function (event) { | ||
event.promise.catch((e) => { | ||
if (e instanceof Error) { | ||
errorHandler(e); | ||
} | ||
else { | ||
if (typeof listener === 'function') | ||
listener(event); | ||
} | ||
}); | ||
}; | ||
const filterError = function (event) { | ||
// Due to the current Garfish rendering process is asynchronous behavior leading to originally 'error' trigger events were 'unhandledrejection' to catch | ||
// Filtering error does not belong to the current application resources, has reached the area target application exception | ||
// Need a sandbox can effectively capture and create resources increase all child application content | ||
if (typeof listener === 'function') { | ||
if (type === 'unhandledrejection') { | ||
unhandledrejection(event); | ||
} | ||
else if (type === 'error') { | ||
errorHandler(event); | ||
} | ||
else { | ||
listener(event); | ||
} | ||
} | ||
}; | ||
return filterError; | ||
} | ||
@@ -464,0 +511,0 @@ |
@@ -454,2 +454,49 @@ 'use strict'; | ||
function filterAndWrapEventListener(type, listener, sourceList) { | ||
const errorHandler = function (e) { | ||
// Conform to the file list type trigger collection of events | ||
if (typeof listener === 'function') { | ||
// Through error stack source file, and the source of the static resources determine whether the current error belongs to the current application | ||
// if belong to the current application environment monitoring error | ||
if (sourceList) { | ||
const res = sourceList.find((item) => { | ||
return item.indexOf(computeErrorUrl(e)) !== -1; | ||
}); | ||
if (res) { | ||
// e.stopPropagation(); | ||
listener(e); | ||
} | ||
} | ||
else { | ||
listener(e); | ||
} | ||
} | ||
}; | ||
const unhandledrejection = function (event) { | ||
event.promise.catch((e) => { | ||
if (e instanceof Error) { | ||
errorHandler(e); | ||
} | ||
else { | ||
if (typeof listener === 'function') | ||
listener(event); | ||
} | ||
}); | ||
}; | ||
const filterError = function (event) { | ||
// Due to the current Garfish rendering process is asynchronous behavior leading to originally 'error' trigger events were 'unhandledrejection' to catch | ||
// Filtering error does not belong to the current application resources, has reached the area target application exception | ||
// Need a sandbox can effectively capture and create resources increase all child application content | ||
if (typeof listener === 'function') { | ||
if (type === 'unhandledrejection') { | ||
unhandledrejection(event); | ||
} | ||
else if (type === 'error') { | ||
errorHandler(event); | ||
} | ||
else { | ||
listener(event); | ||
} | ||
} | ||
}; | ||
return filterError; | ||
} | ||
@@ -456,0 +503,0 @@ |
@@ -458,2 +458,49 @@ const objectToString = Object.prototype.toString; | ||
function filterAndWrapEventListener(type, listener, sourceList) { | ||
const errorHandler = function (e) { | ||
// Conform to the file list type trigger collection of events | ||
if (typeof listener === 'function') { | ||
// Through error stack source file, and the source of the static resources determine whether the current error belongs to the current application | ||
// if belong to the current application environment monitoring error | ||
if (sourceList) { | ||
const res = sourceList.find((item) => { | ||
return item.indexOf(computeErrorUrl(e)) !== -1; | ||
}); | ||
if (res) { | ||
// e.stopPropagation(); | ||
listener(e); | ||
} | ||
} | ||
else { | ||
listener(e); | ||
} | ||
} | ||
}; | ||
const unhandledrejection = function (event) { | ||
event.promise.catch((e) => { | ||
if (e instanceof Error) { | ||
errorHandler(e); | ||
} | ||
else { | ||
if (typeof listener === 'function') | ||
listener(event); | ||
} | ||
}); | ||
}; | ||
const filterError = function (event) { | ||
// Due to the current Garfish rendering process is asynchronous behavior leading to originally 'error' trigger events were 'unhandledrejection' to catch | ||
// Filtering error does not belong to the current application resources, has reached the area target application exception | ||
// Need a sandbox can effectively capture and create resources increase all child application content | ||
if (typeof listener === 'function') { | ||
if (type === 'unhandledrejection') { | ||
unhandledrejection(event); | ||
} | ||
else if (type === 'error') { | ||
errorHandler(event); | ||
} | ||
else { | ||
listener(event); | ||
} | ||
} | ||
}; | ||
return filterError; | ||
} | ||
@@ -460,0 +507,0 @@ |
@@ -464,2 +464,49 @@ (function (global, factory) { | ||
function filterAndWrapEventListener(type, listener, sourceList) { | ||
const errorHandler = function (e) { | ||
// Conform to the file list type trigger collection of events | ||
if (typeof listener === 'function') { | ||
// Through error stack source file, and the source of the static resources determine whether the current error belongs to the current application | ||
// if belong to the current application environment monitoring error | ||
if (sourceList) { | ||
const res = sourceList.find((item) => { | ||
return item.indexOf(computeErrorUrl(e)) !== -1; | ||
}); | ||
if (res) { | ||
// e.stopPropagation(); | ||
listener(e); | ||
} | ||
} | ||
else { | ||
listener(e); | ||
} | ||
} | ||
}; | ||
const unhandledrejection = function (event) { | ||
event.promise.catch((e) => { | ||
if (e instanceof Error) { | ||
errorHandler(e); | ||
} | ||
else { | ||
if (typeof listener === 'function') | ||
listener(event); | ||
} | ||
}); | ||
}; | ||
const filterError = function (event) { | ||
// Due to the current Garfish rendering process is asynchronous behavior leading to originally 'error' trigger events were 'unhandledrejection' to catch | ||
// Filtering error does not belong to the current application resources, has reached the area target application exception | ||
// Need a sandbox can effectively capture and create resources increase all child application content | ||
if (typeof listener === 'function') { | ||
if (type === 'unhandledrejection') { | ||
unhandledrejection(event); | ||
} | ||
else if (type === 'error') { | ||
errorHandler(event); | ||
} | ||
else { | ||
listener(event); | ||
} | ||
} | ||
}; | ||
return filterError; | ||
} | ||
@@ -466,0 +513,0 @@ |
{ | ||
"name": "@garfish/utils", | ||
"version": "0.0.13", | ||
"version": "0.0.15", | ||
"description": "utils module.", | ||
@@ -40,3 +40,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "42a7677eeb438428987f0c66c7803eecc0db70ab" | ||
"gitHead": "789ce877d5e2c83e11230b8cb36f702d90e01e67" | ||
} |
197769
4355