UNPKG

sugar

Version:

A Javascript utility library for working with native objects.

15 lines (12 loc) 451 B
'use strict'; var isPrimitive = require('./isPrimitive'); function assertWritable(obj) { if (isPrimitive(obj)) { // If strict mode is active then primitives will throw an // error when attempting to write properties. We can't be // sure if strict mode is available, so pre-emptively // throw an error here to ensure consistent behavior. throw new TypeError('Property cannot be written'); } } module.exports = assertWritable;