
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
interface-decorators
Advanced tools
Interface decorators for JavaScript
You'll need babel in your project, see notes.
// 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(),
]
}]
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
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
I have no idea if they'll work in typescript or not i'm a js dev, not a ts one.
FAQs
Interface decorators for JavaScript
The npm package interface-decorators receives a total of 0 weekly downloads. As such, interface-decorators popularity was classified as not popular.
We found that interface-decorators 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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.