Giter Site home page Giter Site logo

injecting's People

Contributors

dependabot[bot] avatar ssnau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

amyyo chenhebing

injecting's Issues

设置 overwritable 为true,再次register时,报循环引用的错

你好,我需要多次注册一个 name。如果其对应为service,并且如果已经调用了invoke,即使设置了overwritable,依然会报错,想请教下,这种情况应该怎么来处理?如果是service的话,之前的name不能再被覆盖了吗?下面是测试代码:

//story.js
module.exports = function(place, person){
    return {
        place: place,
        person: person.name,
        pet: person.pet.name
    };
};

// index.js
var injecting = require('injecting');
var app = injecting();
app.register('place', 'pacific');
app.register('cat', function() {
    this.name = "white cat";
});
app.register('person', function(cat) {
    this.name = "robot";
    this.pet = cat;
});
let story = require('./story');
app.register('story', story, {
    overwritable: true
});
app.invoke(function(story){
    console.log(story);
});

app.register('story', story);
app.invoke(function(story){
    console.log(story);
});

injecting and minification

First of all thank you for the nice di.

Let us take the code from the README example

var injecting = require('injecting');
var app = injecting();
app.register('name', 'jack');
app.register('person', function(name) {
    this.name = name;
});

app.invoke(function(person) {
    console.log(person.name); // jack
});

after minification it will be something like this

var injecting = require("injecting"),
    app = injecting();
app.register("name","jack");
app.register("person",function(n){this.name=n});
app.invoke(function(n){console.log(n.name)});

The code above will throw an error UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: n is not found!, because the function property name was replaced with n after minification.

So the question is: is there any workaround to deal with minification?

async name => {},这种情况获取参数的结果是async name

@ssnau
get-parameter-names.js 中获取参数名有点小问题,如题;

result = [code.slice(0, arrowIndex).trim()];

改为

var arrowParams = code.slice(0, arrowIndex).trim(); 
result = [arrowParams.indexOf(' ') === -1 ? arrowParams : arrowParams.split(' ')[1]];

即可修复,或者其他更优雅的实现

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.