/
githubmirror
/
yarn
Обзор
Документация
Войти
/
githubmirror
/
yarn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/util/map.js
22 строки
515 B
Simon Vocella
add prettier and prettying everything (#3401)
16 май 2017, 21:12
16 май 2017, 21:12
25890c8
Код
Авторство
О чём код?
/* @flow */ type Return<T> = T | Object; export default function nullify<T>(obj?: Return<T> = {}): Return<T> { if (Array.isArray(obj)) { for (const item of obj) { nullify(item); } } else if ((obj !== null && typeof obj === 'object') || typeof obj === 'function') { Object.setPrototypeOf(obj, null); // for..in can only be applied to 'object', not 'function' if (typeof obj === 'object') { for (const key in obj) { nullify(obj[key]); } } } return obj; }