Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stamp/required

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stamp/required

Insist on a method/property/staticProperty/configuration presence

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@stamp/required

Insist on a method/property/staticProperty/configuration presence

This stamp (aka behavior) will throw if a method (property, staticProperty, configuration, etc) is missing at object creation.

Usage

import Required from '@stamp/required'

const InsistOnRedrawMethod = Required.required({methods: {redraw: Required}})

Or if you don't want to import the stamp you can import only the method:

import {required} from '@stamp/required'
const InsistOnRedrawMethod = required({methods: {redraw: required}})

API

Static methods

required

Setup which things are required stamp.required({METATYPE: {KEY: required}}) -> Stamp

Example

import stampit from '@stamp/it'
import Required, {required} from '@stamp/required'

const requiredConfigurationDifficulty = required({configuration: {difficulty: required}})
const requiredMethodMove = required({methods: {move: Required}})
const requiredPropertyGuild = Required.required({properties: {guild: required}})

let Paladin = stampit({
  props: {
    mana: 50,
    strength: 50,
    health: 100
  }
})

const paladin = Paladin() // ok

Paladin = Paladin.compose(
  requiredConfigurationDifficulty, 
  requiredMethodMove, 
  requiredPropertyGuild
)

const paladin = Paladin() // THROWS - Required: There must be difficulty in this stamp configuration

Paladin = Paladin.conf({ difficulty: 5 })

const paladin = Paladin() // THROWS - Required: There must be move in this stamp methods

Paladin = Paladin.methods({
  move(x, y) {
    // ... implementation
  }
})

const paladin = Paladin() // THROWS - Required: There must be guild in this stamp properties

Paladin = Paladin.props({ guild: 'Warriors of Light' })

const paladin = Paladin() // ok

FAQs

Package last updated on 23 Oct 2017

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