Sha256: 95c1ba37fea988d3e81ee6de266a12c90bd90acf3a36f21f098fd7513d9b802d

Contents?: true

Size: 1.56 KB

Versions: 27

Compression:

Stored size: 1.56 KB

Contents

'use strict';

var GetIntrinsic = require('get-intrinsic');
var has = require('has');
var channel = require('side-channel')();

var $TypeError = GetIntrinsic('%TypeError%');

var SLOT = {
	assert: function (O, slot) {
		if (!O || (typeof O !== 'object' && typeof O !== 'function')) {
			throw new $TypeError('`O` is not an object');
		}
		if (typeof slot !== 'string') {
			throw new $TypeError('`slot` must be a string');
		}
		channel.assert(O);
		if (!SLOT.has(O, slot)) {
			throw new $TypeError('`' + slot + '` is not present on `O`');
		}
	},
	get: function (O, slot) {
		if (!O || (typeof O !== 'object' && typeof O !== 'function')) {
			throw new $TypeError('`O` is not an object');
		}
		if (typeof slot !== 'string') {
			throw new $TypeError('`slot` must be a string');
		}
		var slots = channel.get(O);
		return slots && slots['$' + slot];
	},
	has: function (O, slot) {
		if (!O || (typeof O !== 'object' && typeof O !== 'function')) {
			throw new $TypeError('`O` is not an object');
		}
		if (typeof slot !== 'string') {
			throw new $TypeError('`slot` must be a string');
		}
		var slots = channel.get(O);
		return !!slots && has(slots, '$' + slot);
	},
	set: function (O, slot, V) {
		if (!O || (typeof O !== 'object' && typeof O !== 'function')) {
			throw new $TypeError('`O` is not an object');
		}
		if (typeof slot !== 'string') {
			throw new $TypeError('`slot` must be a string');
		}
		var slots = channel.get(O);
		if (!slots) {
			slots = {};
			channel.set(O, slots);
		}
		slots['$' + slot] = V;
	}
};

if (Object.freeze) {
	Object.freeze(SLOT);
}

module.exports = SLOT;

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
immosquare-cleaner-0.1.32 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.31 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.30 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.29 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.28 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.27 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.26 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.25 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.24 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.23 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.22 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.21 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.20 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.19 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.18 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.17 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.16 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.14 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.13 node_modules/internal-slot/index.js
immosquare-cleaner-0.1.12 node_modules/internal-slot/index.js