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

@poppinss/macroable

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@poppinss/macroable - npm Package Compare versions

Comparing version 1.0.0-7 to 1.0.0-8

32

build/index.d.ts

@@ -0,5 +1,37 @@

/**
* Adds capabilities for extending the class from outside-in, in the form
* of macros and getters.
*/
export default abstract class Macroable {
/**
*
* Macros are standard properties that gets added to the class prototype.
*
* ```ts
* MyClass.macro('foo', 'bar')
* ```
*/
static macro<T extends {
new (...args: any[]): any;
}, K extends keyof InstanceType<T>>(this: T, name: K, value: InstanceType<T>[K]): void;
/**
*
* Getters are added to the class prototype using the Object.defineProperty.
*
* ```ts
* MyClass.getter('foo', function foo () {
* return 'bar'
* })
* ```
*
* You can add a singleton getter by enabling the `singleton` flag.
*
* ```ts
* const singleton = true
*
* MyClass.getter('foo', function foo () {
* return 'bar'
* }, singleton)
* ```
*/
static getter<T extends {

@@ -6,0 +38,0 @@ new (...args: any[]): any;

@@ -0,5 +1,45 @@

/*
* @poppinss/macroable
*
* (c) Poppinss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Adds capabilities for extending the class from outside-in, in the form
* of macros and getters.
*/
export default class Macroable {
/**
*
* Macros are standard properties that gets added to the class prototype.
*
* ```ts
* MyClass.macro('foo', 'bar')
* ```
*/
static macro(name, value) {
this.prototype[name] = value;
}
/**
*
* Getters are added to the class prototype using the Object.defineProperty.
*
* ```ts
* MyClass.getter('foo', function foo () {
* return 'bar'
* })
* ```
*
* You can add a singleton getter by enabling the `singleton` flag.
*
* ```ts
* const singleton = true
*
* MyClass.getter('foo', function foo () {
* return 'bar'
* }, singleton)
* ```
*/
static getter(name, accumulator, singleton = false) {

@@ -6,0 +46,0 @@ Object.defineProperty(this.prototype, name, {

26

package.json
{
"name": "@poppinss/macroable",
"version": "1.0.0-7",
"version": "1.0.0-8",
"description": "Extend classes from outside in using Macros and getters",

@@ -38,21 +38,21 @@ "main": "build/index.js",

"devDependencies": {
"@adonisjs/eslint-config": "^1.1.5",
"@adonisjs/prettier-config": "^1.1.5",
"@adonisjs/tsconfig": "^1.1.5",
"@commitlint/cli": "^17.6.6",
"@commitlint/config-conventional": "^17.6.6",
"@adonisjs/eslint-config": "^1.1.8",
"@adonisjs/prettier-config": "^1.1.8",
"@adonisjs/tsconfig": "^1.1.8",
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@japa/assert": "^2.0.0-1",
"@japa/expect-type": "^2.0.0-0",
"@japa/runner": "^3.0.0-2",
"@swc/core": "^1.3.67",
"@types/node": "^20.3.2",
"c8": "^8.0.0",
"del-cli": "^5.0.0",
"eslint": "^8.43.0",
"@swc/core": "1.3.82",
"@types/node": "^20.6.3",
"c8": "^8.0.1",
"del-cli": "^5.1.0",
"eslint": "^8.50.0",
"github-label-sync": "^2.3.1",
"husky": "^8.0.3",
"np": "^8.0.4",
"prettier": "^2.8.8",
"prettier": "^3.0.3",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
"typescript": "^5.2.2"
},

@@ -59,0 +59,0 @@ "repository": {

# @poppinss/macroable
> Extend classes from outside in using Macros and getters
[![gh-workflow-image]][gh-workflow-url] [![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url] [![synk-image]][synk-url]
[![gh-workflow-image]][gh-workflow-url] [![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url]

@@ -115,4 +115,4 @@ Macroable offers a simple API for adding properties and getters to the class prototype. You might not even need this package, if you are happy writing `Object.defineProperty` calls yourself.

[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/poppinss/macroable/test.yml?style=for-the-badge
[gh-workflow-url]: https://github.com/poppinss/macroable/actions/workflows/test.yml "Github action"
[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/poppinss/macroable/checks.yml?style=for-the-badge
[gh-workflow-url]: https://github.com/poppinss/macroable/actions/workflows/checks.yml "Github action"

@@ -127,4 +127,1 @@ [typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript

[license-url]: LICENSE.md 'license'
[synk-image]: https://img.shields.io/snyk/vulnerabilities/github/poppinss/manager?label=Synk%20Vulnerabilities&style=for-the-badge
[synk-url]: https://snyk.io/test/github/poppinss/manager?targetFile=package.json "synk"
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