Giter Club home page Giter Club logo

Comments (5)

bnoordhuis avatar bnoordhuis commented on August 22, 2024

I don't really object so feel free to open a pull request but if you want to set a function property on the prototype, then you could use NODE_SET_PROTOTYPE_METHOD() from node.h with a NAN_METHOD as the callback argument.

from nan.

mathiask88 avatar mathiask88 commented on August 22, 2024

Maybe I'm totally wrong, but I want to add a property to my objects prototype template. Until now I used tpl->PrototypeTemplate()->Set("name", NanNew<v8::Integer>(value));. And NODE_SET_PROTOTYPE_METHOD uses as value a FunctionTemplate.

from nan.

kkoopa avatar kkoopa commented on August 22, 2024

Does this differ from the existing NanSetTemplate()?

from nan.

mathiask88 avatar mathiask88 commented on August 22, 2024

The difference is 'Prototype' in tpl->PrototypeTemplate()->Set(..). I create a Javascript object from my native addon like foo = new native.bar(); and then I add some prototype methods to my object foo.prototype.method2 = function(){...} If I add my object property with tpl->PrototypeTemplate()->Set(..) I can access it over the prototype chain with this.property, but if I add the property with tpl->Template->Set(...) I can't. Then i can only access the property by native.bar.property.

from nan.

kkoopa avatar kkoopa commented on August 22, 2024

OK, I see. Yeah, go ahead and make a PR including a test case and documentation.

from nan.

Related Issues (20)

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.