save code
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
max_line_length = 150
|
||||
|
||||
[CHANGELOG.md]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.json]
|
||||
max_line_length = off
|
||||
|
||||
[Makefile]
|
||||
max_line_length = off
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"root": true,
|
||||
|
||||
"extends": "@ljharb",
|
||||
|
||||
"rules": {
|
||||
"max-params": [2, 3],
|
||||
"new-cap": [2, { "capIsNewExceptions": ["GetIntrinsic"] }],
|
||||
"no-magic-numbers": 0,
|
||||
},
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"all": true,
|
||||
"check-coverage": false,
|
||||
"reporter": ["text-summary", "text", "html", "json"],
|
||||
"exclude": [
|
||||
"coverage",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Jordan Harband
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
'use strict';
|
||||
|
||||
/** @typedef {`$${import('.').InternalSlot}`} SaltedInternalSlot */
|
||||
/** @typedef {{ [k in SaltedInternalSlot]?: unknown }} SlotsObject */
|
||||
|
||||
var hasOwn = require('hasown');
|
||||
/** @type {import('side-channel').Channel<object, SlotsObject>} */
|
||||
var channel = require('side-channel')();
|
||||
|
||||
var $TypeError = require('es-errors/type');
|
||||
|
||||
/** @type {import('.')} */
|
||||
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);
|
||||
// eslint-disable-next-line no-extra-parens
|
||||
return slots && slots[/** @type {SaltedInternalSlot} */ ('$' + 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);
|
||||
// eslint-disable-next-line no-extra-parens
|
||||
return !!slots && hasOwn(slots, /** @type {SaltedInternalSlot} */ ('$' + 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);
|
||||
}
|
||||
// eslint-disable-next-line no-extra-parens
|
||||
slots[/** @type {SaltedInternalSlot} */ ('$' + slot)] = V;
|
||||
}
|
||||
};
|
||||
|
||||
if (Object.freeze) {
|
||||
Object.freeze(SLOT);
|
||||
}
|
||||
|
||||
module.exports = SLOT;
|
||||
Reference in New Issue
Block a user