Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Things
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:123.0) Gecko/20100101 Firefox/123.0
Browser:
Firefox 123
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
keys
387335.2 Ops/sec
entries
356759.6 Ops/sec
copy
248573.2 Ops/sec
Tests:
keys
const NULL_VALUES = [null, undefined, ''] const input = { bool: true, date: '01-01-1994', duration: '1d', formatted: '123.00', arr: [{ str: 'string', arr: [{ date: '01-01-1994', }, ], duration: '1d', obj: { formatted: '123.00', }, }, ], obj: { date: '01-01-1994', arr: [ '1d', { formatted: '123.00', }, ], }, } function extractCustomType(result, refs = new Set()) { if (NULL_VALUES.includes(result) || ['number', 'string', 'boolean'].includes(typeof result)) return result const proto = Object.getPrototypeOf(result) if (!proto) return result if (refs.has(result)) return result refs.add(result) if (['escape', 'literal'].includes(proto.constructor.name)) return extractCustomType(result.params[0], refs) // it is Formula if (result.toObject instanceof Function) return result.toObject() if (Array.isArray(result)) return result.map(each => extractCustomType(each, refs)) if (proto.constructor.name === 'Object') { return Object.keys(result).reduce((acc, key) => { if (!(result[key] instanceof Function)) acc[key] = extractCustomType(result[key], refs) return acc }, {}) } return result } extractCustomType(input)
entries
const NULL_VALUES = [null, undefined, ''] const input = { bool: true, date: '01-01-1994', duration: '1d', formatted: '123.00', arr: [{ str: 'string', arr: [{ date: '01-01-1994', }, ], duration: '1d', obj: { formatted: '123.00', }, }, ], obj: { date: '01-01-1994', arr: [ '1d', { formatted: '123.00', }, ], }, } function extractCustomType(result, refs = new Set()) { if (NULL_VALUES.includes(result) || ['number', 'string', 'boolean'].includes(typeof result)) return result const proto = Object.getPrototypeOf(result) if (!proto) return result if (refs.has(result)) return result refs.add(result) if (['escape', 'literal'].includes(proto.constructor.name)) return extractCustomType(result.params[0], refs) // it is Formula if (result.toObject instanceof Function) return result.toObject() if (Array.isArray(result)) return result.map(each => extractCustomType(each, refs)) if (proto.constructor.name === 'Object') { return Object.entries(result).reduce((acc, [key, value]) => { if (!(value instanceof Function)) acc[key] = extractCustomType(value, refs) return acc }, {}) } return result } extractCustomType(input)
copy
const NULL_VALUES = [null, undefined, ''] const input = { bool: true, date: '01-01-1994', duration: '1d', formatted: '123.00', arr: [{ str: 'string', arr: [{ date: '01-01-1994', }, ], duration: '1d', obj: { formatted: '123.00', }, }, ], obj: { date: '01-01-1994', arr: [ '1d', { formatted: '123.00', }, ], }, } function extractCustomType(result, refs = new Set()) { if (NULL_VALUES.includes(result) || ['number', 'string', 'boolean'].includes(typeof result)) return result const proto = Object.getPrototypeOf(result) if (!proto) return result if (refs.has(result)) return result refs.add(result) if (['escape', 'literal'].includes(proto.constructor.name)) return extractCustomType(result.params[0], refs) // it is Formula if (result.toObject instanceof Function) return result.toObject() if (Array.isArray(result)) return result.map(each => extractCustomType(each, refs)) if (proto.constructor.name === 'Object') { return Object.entries(result).reduce((acc, [key, value]) => { if (value instanceof Function) return acc return { ...acc, [key]: extractCustomType(value, refs) } }, {}) } return result } extractCustomType(input)