New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

interface-decorators

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

interface-decorators

Interface decorators for JavaScript

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Interface decorators

Interface decorators for JavaScript

Usage

You'll need babel in your project, see notes.

Example rollup config:

// rollup.config.js
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import babel from '@rollup/plugin-babel'

export default [{
  input: 'src/index.js',
  output: {
    file: 'public/index.js',
    format: 'esm',
    name: 'core'
  },
  plugins: [
    babel({ 
      sourceMap: true,
      include: ['src/**/*'],
      extensions: ['.js'],
      plugins: [
        '@babel/plugin-proposal-class-properties', 
        ['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: false }]
      ]
    }),
    resolve(),
    commonjs(),
  ]
}]

Example

import { Interface, implement, isImplementing } from 'interface-decorators'

@Interface
class Serializable {
  serialize () {}
  static deserialize () {}
}

@Interface
class Entity {
  distanceTo () {}
}

@implement(Serializable, Entity)
class Player {
  // has to implement serialize, distanceTo and static deserialize
}

const player = new Player()

isImplementing(Player, Entity) // true
isImplementing(player.constructor, Serializable, Entity) // true

Notes

JavaScript

Well, decorators are not part of the official spec and may never be. By the time of writing this readme they are in stage-2 proposal

TypeScript

I have no idea if they'll work in typescript or not i'm a js dev, not a ts one.

FAQs

Package last updated on 19 Jun 2020

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