💾 Archived View for gmi.noulin.net › gitRepositories › git-off › file › node_modules › chai › lib › … captured on 2023-01-29 at 11:38:24. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
flag.js (807B)
1 /*! 2 * Chai - flag utility 3 * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com> 4 * MIT Licensed 5 */ 6 7 /** 8 * ### flag(object, key, [value]) 9 * 10 * Get or set a flag value on an object. If a 11 * value is provided it will be set, else it will 12 * return the currently set value or `undefined` if 13 * the value is not set. 14 * 15 * utils.flag(this, 'foo', 'bar'); // setter 16 * utils.flag(this, 'foo'); // getter, returns `bar` 17 * 18 * @param {Object} object constructed Assertion 19 * @param {String} key 20 * @param {Mixed} value (optional) 21 * @namespace Utils 22 * @name flag 23 * @api private 24 */ 25 26 module.exports = function (obj, key, value) { 27 var flags = obj.__flags || (obj.__flags = Object.create(null)); 28 if (arguments.length === 3) { 29 flags[key] = value; 30 } else { 31 return flags[key]; 32 } 33 };