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

collection-decorator

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

collection-decorator - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

4

package.json
{
"name": "collection-decorator",
"version": "0.1.0",
"version": "0.1.1",
"description": "Decorator for adding to collection",

@@ -48,3 +48,3 @@ "main": "dist/index.js",

"collectCoverage": true,
"coverageDirectory": "../coverage",
"coverageDirectory": "./coverage",
"collectCoverageFrom": [

@@ -51,0 +51,0 @@ "src/**/*.ts"

# collection-decorator
Decorator for adding to collection
[![npm](https://img.shields.io/npm/v/collection-decorator)](https://www.npmjs.com/package/collection-decorator)
[![Build status](https://img.shields.io/travis/iamolegga/collection-decorator.svg)](https://travis-ci.org/iamolegga/collection-decorator)
[![Coverage Status](https://coveralls.io/repos/github/iamolegga/collection-decorator/badge.svg?branch=master)](https://coveralls.io/github/iamolegga/collection-decorator?branch=master)
![David](https://img.shields.io/david/iamolegga/collection-decorator)
Typical usecase for this library:
```ts
// HasFoo.ts
import { createCollectionDecorator } from 'collection-decorator';
interface ClassType {
foo: number;
}
const { collection, decorator } =
createCollectionDecorator<ClassType>();
export function fooSum() {
let sum = 0;
for (let value of collection.values()) {
sum += value.foo
}
return sum;
}
export const HasFoo = decorator;
```
```ts
// A.ts
import { HasFoo } from './HasFoo.ts';
@HasFoo
export class A {
static foo = 1;
}
```
```ts
// B.ts
import { HasFoo } from './HasFoo.ts';
@HasFoo
//^^^^^ TS error because class B has not `foo` property
export class B {}
// So fix it:
@HasFoo
export class B {
static foo = 2;
}
```
```ts
// sum.ts
import { fooSum } from './HasFoo.ts';
fooSum() // 3
```
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