UNPKG

@feugene/mu

Version:

Helpful TS utilities without dependencies

30 lines (23 loc) 887 B
import root from '~/internal/root' /** Detect free variable `exports`. */ const freeExports = typeof exports === 'object' && exports && !exports.nodeType && exports /** Detect free variable `module`. */ const freeModule = freeExports && typeof module == 'object' && module && !('nodeType' in module) && module /** Detect the popular CommonJS extension `module.exports`. */ const moduleExports = freeModule && freeModule.exports === freeExports /** Built-in value references. */ const Buffer = moduleExports ? root.Buffer : undefined /* Built-in method references for those with the same name as other `lodash` methods. */ const nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined /** * Checks if `value` is a buffer. * * @example * * isBuffer(new Buffer(2)); * // => true * * isBuffer(new Uint8Array(2)); * // => false */ export default nativeIsBuffer || (() => false)