GithubHelp home page GithubHelp logo

class-extension's People


overlookmotel avatar


 avatar  avatar


 avatar  avatar  avatar

class-extension's Issues

Declare extensions an extension extends as part of constructor

Presently, you create an extension which extends another extension with:

const myExt = new Extension( {
  extend( Class ) {
    Class = Class.extend( otherExtension );
    Class = Class.extend( anotherExtension );
    return class extends Class { /* ... */ };
} );

Instead could provide the extensions to the plugin constructor:

const myExt = new Extension( {
  extends: [ otherExtension, anotherExtension ],
  extend: Class => class extends Class { /* ... */ }
} );

This change would have 2 advantages:

  1. Terser syntax
  2. Easier to implement #13

Mechanism for specifying an acceptable range of versions of extensions

Where an extension extends another extension, and that extension is already applied, it prevents the extension being applied twice.

const M = Main.extend( extensionA )
  .extend( extensionB )
  .extend( extensionA );

In above case, extensionA is deduplicated (see docs).

If the two extensionAs are actually different versions of extensionA e.g. 1.0.0 and 1.1.0, an error will be thrown.

It would be better if you could provide an acceptable semver version range which which prevents this error. e.g.:

.extend( extensionA, { version: '^1.0.0' } )

In extensions, ranges could be specified with a dependencies option:

const otherExt = require('other-ext');

const MyExt = new Extension( {
  name: 'my-ext',
  version: '0.0.1',
  dependencies: {
    'other-ext': '^1.0.0'
  extend( Class ) {
    Class = Class.extends( otherExt );
    return class extends Class { /* ... */ }
} );

Conveniently, if this plugin is in an NPM module, you can then just include package.json to cover name, version and dependencies in one.

const otherExt = require('other-ext');

const MyExt = new Extension(
  ( Class ) => {
    Class = Class.extends( otherExt );
    return class extends Class { /* ... */ }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.