mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-28 16:45:10 +08:00
24 lines
576 B
TypeScript
24 lines
576 B
TypeScript
import * as shimmer from 'shimmer';
|
|
|
|
const isWrapped: boolean = [].forEach.__wrapped || false;
|
|
|
|
shimmer.wrap(Array.prototype, 'forEach', (forEach) => {
|
|
return (...args: any[]) => {
|
|
forEach(...args);
|
|
};
|
|
});
|
|
|
|
shimmer.unwrap(Array.prototype, 'forEach');
|
|
|
|
shimmer.massWrap([Map.prototype, Set.prototype], ['clear', 'forEach'], (fn) => {
|
|
return (...args: any[]) => {
|
|
const result = fn(...args);
|
|
if (result) {
|
|
throw new Error();
|
|
}
|
|
return result;
|
|
};
|
|
});
|
|
|
|
shimmer.massUnwrap([Map.prototype, Set.prototype], ['clear', 'forEach']);
|