New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@aminya/mixto

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

@aminya/mixto

A mixin superclass. Its subclasses have `.extend` and `.includeInto` methods to mix behavior into other objects and classes.

latest
Source
npmnpm
Version
1.0.0-aminya.1
Version published
Maintainers
1
Created
Source

Mixto: A simple mixin superclass Build Status

npm install @aminya/mixto

JavaScript Classes (ES6)

To create a mixin, subclass mixto:

const Mixin = require('mixto/lib/es6')

class MyMixin extends Mixin {
  static classMethod() { console.log("foo"); }
  instanceMethod() { console.log("bar"); }
}

Then mix into classes with .includeInto:

class MyClass {
  static initClass() {
    MyMixin.includeInto(this); // adds all the mixin's class properties or prototype properties to the target class if they aren't already defined
  }
}
MyClass.initClass();

MyClass.classMethod();
(new MyClass).instanceMethod();

Or extend individual objects with .extend:

const myObject = {a: 1, b: 2};
MyMixin.extend(myObject);   // adds all the mixin's prototype properties to the target object if they aren't already defined
myObject.instanceMethod();

Or build standalone instances of your 'mixin':

const standalone = new MyMixin;
standalone.instanceMethod();

CoffeeScript 1 Classes (ES5)

To create a mixin, subclass mixto:

Mixin = require 'mixto'

class MyMixin extends Mixin
  @classMethod: -> console.log("foo")
  instanceMethod: -> console.log("bar")

Then mix into classes with .includeInto:

class MyClass
  MyMixin.includeInto(this)

MyClass.classMethod()
(new MyClass).instanceMethod()

Or extend individual objects with .extend:

myObject = {a: 1, b: 2}
MyMixin.extend(myObject)
myObject.instanceMethod()

Or build standalone instances of your 'mixin':

standalone = new MyMixin
standalone.instanceMethod()

Keywords

mixin

FAQs

Package last updated on 31 Aug 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