Answer the question
In order to leave comments, you need to log in
Autocomplete for native modules?
Hello.
There is a simple module, something like:
var _counters = {};<br>
<br>
this.createCounter = function (counterName, initialValue) {<br>
_counters[counterName] = initialValue;<br>
return this;<br>
}<br>
<br>
this.removeCounter = function (counterName) {<br>
delete _counters[counterName];<br>
return this;<br>
}<br>
<br>
this.increment = function (counterName, incrementValue) {<br>
if (typeof incrementValue == 'undefined') {<br>
incrementValue = 1;<br>
}<br>
_counters[counterName] += 1;<br>
}<br>
<br>
this.decrement = function (counterName, incrementValue) {<br>
if (typeof incrementValue == 'undefined') {<br>
incrementValue = 1;<br>
}<br>
_counters[counterName] -= incrementValue;<br>
}<br>
var Counter = require('./modules/counter/Counter.js');<br>
Answer the question
In order to leave comments, you need to log in
Hmm, why don't you follow the best practices for writing Nodejs Modules ?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question