Socket
Socket
Sign inDemoInstall

staack

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

staack

A library to create type-safe opaque stacks


Version published
Weekly downloads
7
decreased by-12.5%
Maintainers
1
Weekly downloads
 
Created
Source

🏯 Staack

A library to create type-safe opaque stacks

Example

// TODO

Installation

npm install staack
# or
yarn add staack

Extending Staack

You can create your own Staack:

class CustomStaack extends Staack {
  // You need to override the `with` method to return a new instance of your CustomStaack
  with(...keys: Array<KeyProvider<any>>): CustomStaack {
    // Use the static `applyKeys` method to apply keys to the current instance
    return Staack.applyKeys<CustomStaack>(this, keys, (internal) => new CustomStaack(internal));
  }
}

const custom = new CustomStaack();
expect(custom instanceof CustomStaack).toBe(true);
expect(custom instanceof Staack).toBe(true);

If you want to pass custom arguments to yout CustomStaack:

class ParamsStaack extends Staack {
  // You can pass your own parameters to the constructor
  constructor(public readonly param: string, internal: StaackInternal<ParamsStaack> | null = null) {
    super(internal);
  }

  with(...keys: Array<KeyProvider<any>>): ParamsStaack {
    return Staack.applyKeys<ParamsStaack>(this, keys, (internal) => new ParamsStaack(this.param, internal));
  }
}

const custom = new ParamsStaack('some value');
expect(custom.param).toBe('some value');
expect(custom instanceof ParamsStaack).toBe(true);
expect(custom instanceof Staack).toBe(true);

Keywords

FAQs

Package last updated on 12 Jun 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc