Giter Club home page Giter Club logo

Comments (5)

amark avatar amark commented on May 16, 2024

GUN figures out whether you need to use new for you:

    function Gun(opt){
        var gun = this;
        if(!Gun.is(gun)){
            return new Gun(opt);
        }
        gun.opt(opt);
    }

So that way you don't have to worry about it. I think you can call it explicitly and it'll still work just fine var gun = new Gun(...); but I should probably write tests to guarantee that. This just protects against common forgetfulness and it doesn't have any side effects.

from gun.

alexlafroscia avatar alexlafroscia commented on May 16, 2024

Okay, cool. It's more that I want to make sure that using new still works, since my linter is throwing a warning whenever it comes across not using it.

from gun.

coolaj86 avatar coolaj86 commented on May 16, 2024

I suggest also exposing a '.create()' method, as that's the conventional way to expose the constructor when you want to avoid new.

from gun.

metasean avatar metasean commented on May 16, 2024

Documented. @PsychoLlama may make an extension which adds a .create() method.

from gun.

PsychoLlama avatar PsychoLlama commented on May 16, 2024

Gun.create() has been added as a code snippet, found here

from gun.

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.