Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linting Problem with Constructor #6

Closed
alexlafroscia opened this issue Jan 18, 2015 · 5 comments
Closed

Linting Problem with Constructor #6

alexlafroscia opened this issue Jan 18, 2015 · 5 comments
Assignees
Labels

Comments

@alexlafroscia
Copy link
Contributor

When JSHint-ing whatever sets up the Gun connection with

var gun = Gun(...);

I keep getting the following warning:

Missing 'new' prefix when invoking a constructor.

Should we require new? I know that it works right now, but if it doesn't follow JavaScript's normal patterns then we should at least discuss bringing it in line.

@amark
Copy link
Owner

amark commented Jan 19, 2015

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.

@alexlafroscia
Copy link
Contributor Author

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.

@coolaj86
Copy link

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

@metasean metasean added the doc label May 20, 2015
@metasean metasean self-assigned this May 20, 2015
@metasean metasean added the Queue label May 20, 2015
@amark amark added Document and removed Queue labels Jul 15, 2015
@metasean
Copy link
Collaborator

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

@metasean metasean added Pending and removed Document labels Dec 17, 2015
@PsychoLlama
Copy link
Contributor

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

@metasean metasean closed this as completed Jan 4, 2016
@metasean metasean removed the Pending label Jan 4, 2016
mmalmi pushed a commit to mmalmi/gun that referenced this issue Mar 16, 2020
* add: wait for once, so data is returned on first get

* Update then.js
mmalmi added a commit to mmalmi/gun that referenced this issue Mar 16, 2020
* react native support (amark#5)

* WIP: use isomorphic-webcrypto for RN

* WIP: expo friendly exports

* WIP: buffer for RN

* WIP: textencoder for RN

* WIP: aeskey from jwk instead of raw for RN

* fix: missing taglength for msrcrypto

* add: update isomorphic-webcrypto

* add: match isocrypto api

* add: failing test for 4e2 as 400

* fix: remove extra atob btoa

* add: sea unbuild

* refactor: according to mhelander review

* refactor: shorter require

* fix: make bug test pass, capitlize bug test.

* fix: npm ci + sea test

* add: restore old browser export and add react-native friendly exports

* fix: import buffer into correct global/window

* fix: bad comparison

* fix: only include buffer if no btoa/atob

* add: wait for once, so data is returned on first get (amark#6)

* add: wait for once, so data is returned on first get

* Update then.js

* add: decrypt opposite of secret

* add: update dependencies

* add: update to use webview-crypto

* refactor: remove duplicate

* fix: match amark master

* Update README.md

* Update README.md

* add: restore old crypto package, isomorphic changes things in react-native

* fix: typo

* add: update readme with example

* cache remote files, quick ugly test experiment?

* IF email ENV CONFIG set, report slow parse

* IF email ENV CONFIG set, report slows

* refine health

* how long is 1ms in actuality?

* skip saving in-mem acks? thrash socket 0?

* begin

* live debug ?

* try live debug (chrome inspector)

* Update Aptfile

* Update Aptfile

* Update Aptfile

* Update Procfile

* Update Procfile

* Update Procfile

* Update Procfile

* notes & tests

* TODO SPAM, REMEMBER TO UNCOMMIT

* because yeah!

* yet another day.

* ? trace ? tmp

* Update trace.js

* Update trace.js

* only flamegraph emails

* Update .gitignore

* full circuit

* unit tests passing

* p v b

* fixup

* duh

* find ugh

* Update sea.js

* Update sea.js

* crash it

* work!

* Update rs3.js

* Update radisk.js

* uptime decimal

* only check once per disk, not each cb of it

* woops that was crashing stuff

* FIX CHAIN EMIT / ON, add more stats

* woops put was too big for email

* better diagnostics

* check mix time

* allow sort / dynamic prefix on hash?

* Update gun.js

* ugh lol finally get this right?

* more info

* I want the count

* yet again

* if emitting chain perf fault, then redo _rad

* 3rd rewrite, have batched acks.

* fix .pub on account check

* -log +stat, not gets or dbg yet tho

* woops, what?

* fix large records saving to RAD

* TEMPORARY test

* undo temporary test

* file serve stats

* DO NOT PUBLISH! ECHO TEST.

* put debug (dbg)

* must be defined undefined

* TEMPORARILY disable RAD

* restore

* perf notes

* puff say loop? see how it goes.

* don't lose ref

* puff it

* prof back in

* in s not ms

* rad check node read, important puffs

* fix chain emit & faith

* check if migration needed

Co-authored-by: sirpy <[email protected]>
Co-authored-by: Mark Nadal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants