![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
object-catalog
Advanced tools
Catalog the execution context object
function(options)
Creates a catalog of all members of the execution context (this
) and all visible members of all the objects along it's prototype chain.
By visible members we mean only those members not shadowed by a member of the same name in a descending object in the prototype chain.
The resultant "catalog" is a plain javascript object. For each member of the catalog:
To keep things simple:
- The resultant object has no prototype
- The catalog excludes:
- Members that reference the catalog function itself (e.g., as a result of having been mixed in)
- Members of
Object.prototype
options.own
If truthy, the resultant catalog is restricted to the execution context object only (excluding the prototype chain).
options.greylist
See greylist
for more details, but basically:
options.greylist.white
A whitelist. Only listed object members are cataloged can pass. If undefined
, all members are included. If an empty array, all members are excluded.
options.greylist.black
A blacklist. Listed strings are blocked. If undefined
or an empty array, all members are included.
When no options are specified:
function MyAPI() { this.b = 0; this.c = 3; }
MyAPI.prototype = { a:1, b:2, catalog:catalog };
var myAPI = new MyAPI;
myAPI.catalog(); // { a:MyAPI.prototype, b:myAPI, c:myAPI }
Object.getPrototypeOf(myAPI).catalog(); // { a:MyAPI.prototype, b:MyAPI.prototype }
own
behaviorProceeding from Example A:
var options = { own: true };
myAPI.catalog(options); // { b:myAPI, c:myAPI }
greylist
behaviorProceeding from the Example A:
var options = { greylist: { white: ['a', 'c'] } };
myAPI.catalog(options); // { a:MyAPI.prototype, c:myAPI }
options = { greylist: { black: ['a', 'c'] } };
myAPI.catalog(options); // { b:myAPI }
var options = { greylist: { white: ['a', 'c'], black: 'a' } };
myAPI.catalog(options); // { c:myAPI }
The catalog
function does not care where the object (and it's prototype) came from. You will get the same results regardless of whether the object is a "class" instance (i.e., was instanced from a constructor) or was simply created. Compare the following to Example A:
var myAPI = Object.create({ a:1, b:2, catalog:require('object-catalog') }};
Object.assign(myAPI, { b:0, c:3 });
myAPI.catalog(); // { a:ancestor, b:myAPI, c:myAPI }
Object.getPrototypeOf(myAPI).catalog(); // { a:ancestor, b:ancestor }
Notice that if the catalog function is mixed into the object, it is nonetheless excluded from the output. This exclusion is by reference and is regardless of the name of the key. You do not of course need to mix the function in if you're willing to use call
. Compare the following to Example D:
var myAPI = Object.create({ a:1, b:2 }};
Object.assign(myAPI, { b:0, c:3 });
var catalog = require('object-catalog');
catalog.call(myAPI); // { a:ancestor, b:myAPI, c:myAPI }
Object.getPrototypeOf(myAPI).catalog(); // { a:ancestor, b:ancestor }
FAQs
Catalog the execution context object
The npm package object-catalog receives a total of 3 weekly downloads. As such, object-catalog popularity was classified as not popular.
We found that object-catalog demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.