import { IDynamicPropertyWriter } from '../interfaces/IDynamicPropertyWriter'; /** * @exports */ export default { /** * @description Returns whether the given type is a global object or a class * @param {string} type * @returns {boolean} */ isClass: (type: string): boolean => [ 'Int8Array', 'Uint8Array', 'Uint8ClampedArray', 'Int16Array', 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', 'Float64Array', 'DataView', 'ArrayBuffer', 'WeakMap' ].indexOf(type) === -1, /** * @description Returns the byte length of a string * @param {string} str * @returns {number} */ byteLength: (str: string): number => new TextEncoder().encode(str).length, /** * @description Returns whether the given class is a dynamic property writer * @param {object} klass * @returns {boolean} */ isDynamicPropertyWriterClass: (klass: object): klass is IDynamicPropertyWriter => ('writeDynamicProperties' in klass) }