npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

veil-objects

v1.0.6

Published

The JS/TS implementation of Veil objects approach from EO oriented programming

Readme

Tests

VeilObjects

The JS/TS implementation of Veil objects approach from EO oriented programming

Notice that the package is under active development currently.

Objectives

See original paper which this package idea is based upon - https://www.yegor256.com/2020/05/19/veil-objects.html

The objective is to use the EO oriented programming, so called: "Veil objects" approach in JS/TS


Contributing

See all you need here: https://gadzhievislam.org/Programming/Contributing

Issues

You're welcome to submit any issues related to existing issues tags, and start to work on existing.


Usage

The veil object wraps a target object with provided presets object and when trying to access the provided presets methods on the veil object - it passes them through, until the veil object is pierced, meaning some methods were invoked that are not listed in the provided preset object.

See the example below (in TypeScript for type illustration purposes):

// Create a Project class with dynamic methods

type TDBFetcher = (field: string, id: number) => string;

class Project {
  constructor(
    private readonly dataFetcher: TDBFetcher,
    private readonly id: number
  ) {
    this.dataFetcher = dataFetcher;
    this.id = id;
  }

  name(): string {
    return this.dataFetcher("name", this.id);
  }

  author(): string {
    return this.dataFetcher("author", this.id);
  }

  description(): string {
    return this.dataFetcher("description", this.id);
  }
};

Now let's try to use our Veil object:

JavaScript

const veiledProject = new Veil(
  new Project(fetchData, 1),
  { name: 'project-1', author: 'Alex' },
);

// Call methods on the veiled object
console.log( veiledProject.name() ); // Outputs: "project-1" (preset value)
console.log( veiledProject.author() ); // Outputs: "Alex" (preset value)

// Accessing a non-preset method pierces the Veil
console.log( veiledProject.description() ); // Pierces the veil and fetches from `project`

// Now fetches via target object native method: `project.name()`, no longer uses preset
// Outputs: "project.name()", wher `project` is `new Project()` from the Veil target
console.log( veiledProject.name() );

TypeScript

const veiledProject = new Veil(
  new Project(fetchData, 1),
  { name: 'project-1', author: 'Alex' },
) as unknown as Project;

// As you might've witnessed a nuance for using with TypeScript:
// The only way to infer the target object types from the dynamic nature of Veil class for TypeScript
// is to use type casting with - `as unkown as <targetType>`.
//
// That's why it's strongly recommended to either:
// - Use the Veil only in JS code
// - Find some workarounds for TS

Tests

Test cases, Test results