This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Module: function.bind.with-exotic-object-slots | |
* | |
* TypeScript declaration for a custom override of `Function.prototype.bind` | |
* that stores ECMAScript-like internal slot metadata as Symbol-based properties | |
* on bound functions. | |
* | |
* Inspired by ECMAScript internal slots: | |
* - `[[BoundTargetFunction]]` | |
* - `[[BoundThis]]` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Symbol.fnDirectives = Symbol.for('fnDirectives'); | |
// const directivesSymbol = Symbol.fnDirectives; | |
// console.log(Symbol.for(Symbol.keyFor(directivesSymbol)) === Symbol.fnDirectives); // true | |
const functionPrototype = Function.prototype; | |
const toFunctionString = functionPrototype.toString; | |
function parseBodyFromFctString(fctString) { | |
const [ head ] = fctString |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const defaultDescriptorOptions = { enumerable: false, writable: true, configurable: true }; | |
const sealedDescriptorOptions = { enumerable: false, configurable: false }; | |
/** | |
* Returns the internal `[[Class]]` tag of a value, like `[object String]` or returns `undefined` | |
* if no argument was passed. | |
* | |
* @param {...any} args | |
* A variadic argument list. The first argument (`args[0]`) is the optional `value` parameter. | |
* Its **presence** is detected via `args.length`, allowing the function to distinguish between |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
// https://stackoverflow.com/questions/78105670/cutom-elements-cant-extend-from-button-illegal-constructor/78106993 | |
//--> | |
<script> | |
(function (globalThis) { | |
// scope of `dom-safari` or `custom-element-safari` module | |
'use strict'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
// BEGIN :: module scope | |
'use strict'; | |
/* function type specifc detection helpers */ | |
/** | |
* Detects whether a passed function type features a truly `writable` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
// BEGIN :: module scope | |
'use strict'; | |
/* function type specifc detection helpers */ | |
/** | |
* Detects whether a passed function type features a truly `writable` | |
* `prototype` property. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a strictly educational deep clone attempt/approach. | |
function exposeInternalyType(value) { | |
return Object.prototype.toString.call(value); | |
} | |
function isRegExp(value) { | |
return exposeInternalyType(value) === '[object RegExp]'; | |
} | |
function isDate(value) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* - include core-js for enabling/implementing the new `Set` methods | |
* | |
* <script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/3.36.0/minified.js"></script> | |
* | |
* - for related tasks, like splitting any given keypath most generically into key-partials, | |
* have a look at ... [https://regex101.com/r/tew8gr/3] ... and its regular expression ... | |
* | |
* possible usage: | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PausedStateSignal extends EventTarget { | |
// shared protected/private state. | |
#state; | |
constructor(connect) { | |
super(); | |
this.#state = { | |
isPaused: false, | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// utility/helper functions. | |
function getFunctionName(value) { | |
return Object.getOwnPropertyDescriptor(value, 'name').value; | |
// return value.name; | |
} | |
function getFunctionSignature(value) { | |
return Function.prototype.toString.call(value).trim(); | |
} |
NewerOlder