id stringlengths 34 124 | type stringclasses 4
values | prompt stringlengths 0 4.95k | response stringlengths 21 4.89k | source_lang stringclasses 3
values | target_lang stringclasses 2
values | repo stringclasses 75
values | path stringlengths 10 88 | license stringclasses 1
value | commit stringlengths 40 40 | stars int64 431 18.7k | source_url stringlengths 86 176 | line_start int64 1 214 | line_end int64 3 253 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
lmaccherone/node-localstorage:LocalStorage.coffee:7:raw_corpus | raw_corpus | metaKey = @metaKeyMap[key]
if (!!metaKey)
hasListeners = events.EventEmitter.listenerCount(this, 'storage')
oldValue = null
if hasListeners
oldValue = this.getItem(key)
delete @metaKeyMap[key]
@length -= 1
@bytesInUse -= metaKey.size
filename = path.join(@location, ... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 0b72cffdb00ff303fe46d2616c875051c4930713 | 460 | https://github.com/lmaccherone/node-localstorage/blob/0b72cffdb00ff303fe46d2616c875051c4930713/LocalStorage.coffee | 129 | 167 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:7:completion | completion | metaKey = @metaKeyMap[key]
if (!!metaKey)
hasListeners = events.EventEmitter.listenerCount(this, 'storage')
oldValue = null
if hasListeners
oldValue = this.getItem(key)
delete @metaKeyMap[key]
@length -= 1
@bytesInUse -= metaKey.size
filename = path.join(@location, ... | clear: () ->
_emptyDirectory(@location)
@metaKeyMap = createMap()
@keys = []
@length = 0
@bytesInUse = 0
if events.EventEmitter.listenerCount(this, 'storage')
evnt = new StorageEvent(null, null, null, @eventUrl)
this.emit('storage', evnt)
getBytesInUse: () ->
return @bytesInU... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 0b72cffdb00ff303fe46d2616c875051c4930713 | 460 | https://github.com/lmaccherone/node-localstorage/blob/0b72cffdb00ff303fe46d2616c875051c4930713/LocalStorage.coffee | 129 | 167 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:raw_corpus | raw_corpus | class LocalStorage extends events.EventEmitter
constructor: (@location, @quota = 5 * 1024 * 1024) ->
unless this instanceof LocalStorage
return new LocalStorage(@location, @quota)
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@metaK... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 2aff35665f6c1599a12623c40fc14216a5876531 | 460 | https://github.com/lmaccherone/node-localstorage/blob/2aff35665f6c1599a12623c40fc14216a5876531/LocalStorage.coffee | 29 | 78 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:5:completion | completion | class LocalStorage extends events.EventEmitter
constructor: (@location, @quota = 5 * 1024 * 1024) ->
unless this instanceof LocalStorage
return new LocalStorage(@location, @quota)
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@metaK... | _init: () ->
if fs.existsSync(@location)
unless fs.statSync(@location).isDirectory()
throw new Error("A file exists at the location '#{@location}' when trying to create/open localStorage")
@bytesInUse = 0
@length = 0
unless fs.existsSync(@location)
fs.mkdirSync(@location)
retu... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 2aff35665f6c1599a12623c40fc14216a5876531 | 460 | https://github.com/lmaccherone/node-localstorage/blob/2aff35665f6c1599a12623c40fc14216a5876531/LocalStorage.coffee | 29 | 78 |
lmaccherone/node-localstorage:LocalStorage.coffee:6:raw_corpus | raw_corpus | setItem: (key, value) ->
hasListeners = events.EventEmitter.listenerCount(this, 'storage')
oldValue = null
if hasListeners
oldValue = this.getItem(key)
key = key.toString()
encodedKey = encodeURIComponent(key)
filename = path.join(@location, encodedKey)
valueString = value.toString()
... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 2aff35665f6c1599a12623c40fc14216a5876531 | 460 | https://github.com/lmaccherone/node-localstorage/blob/2aff35665f6c1599a12623c40fc14216a5876531/LocalStorage.coffee | 79 | 128 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:6:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
setItem: (key, value) ->
hasListeners = events.EventEmitter.listenerCount(this, 'storage')
oldValue = null
if hasListeners
oldValue = this.getItem(key)
key = key.toString()
encodedKey = encodeURIComponent(key)
filename = path.join(@l... | ({
setItem: function(key, value) {
var encodedKey, evnt, existsBeforeSet, filename, hasListeners, metaKey, oldLength, oldValue, valueString, valueStringLength;
hasListeners = events.EventEmitter.listenerCount(this, 'storage');
oldValue = null;
if (hasListeners) {
oldValue = this.getItem(key);
... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 2aff35665f6c1599a12623c40fc14216a5876531 | 460 | https://github.com/lmaccherone/node-localstorage/blob/2aff35665f6c1599a12623c40fc14216a5876531/LocalStorage.coffee | 79 | 128 |
lmaccherone/node-localstorage:LocalStorage.coffee:6:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
setItem: function(key, value) {
var encodedKey, evnt, existsBeforeSet, filename, hasListeners, metaKey, oldLength, oldValue, valueString, valueStringLength;
hasListeners = events.EventEmitter.listenerCount(this, 'storage');
oldValue = null;
if ... | setItem: (key, value) ->
hasListeners = events.EventEmitter.listenerCount(this, 'storage')
oldValue = null
if hasListeners
oldValue = this.getItem(key)
key = key.toString()
encodedKey = encodeURIComponent(key)
filename = path.join(@location, encodedKey)
valueString = value.toString()
... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 2aff35665f6c1599a12623c40fc14216a5876531 | 460 | https://github.com/lmaccherone/node-localstorage/blob/2aff35665f6c1599a12623c40fc14216a5876531/LocalStorage.coffee | 79 | 128 |
lmaccherone/node-localstorage:LocalStorage.coffee:6:completion | completion | setItem: (key, value) ->
hasListeners = events.EventEmitter.listenerCount(this, 'storage')
oldValue = null
if hasListeners
oldValue = this.getItem(key)
key = key.toString()
encodedKey = encodeURIComponent(key)
filename = path.join(@location, encodedKey)
valueString = value.toString()
... | if hasListeners
evnt = new StorageEvent key, oldValue, value
this.emit('storage', evnt)
getItem: (key) ->
key = key.toString()
console.log('keys' + @length)
metaKey = @metaKeyMap[key]
if !!metaKey
filename = path.join(@location, metaKey.key)
return fs.readFileSync(filename, 'u... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 2aff35665f6c1599a12623c40fc14216a5876531 | 460 | https://github.com/lmaccherone/node-localstorage/blob/2aff35665f6c1599a12623c40fc14216a5876531/LocalStorage.coffee | 79 | 128 |
lmaccherone/node-localstorage:LocalStorage.coffee:7:raw_corpus | raw_corpus | if (!!metaKey)
hasListeners = events.EventEmitter.listenerCount(this, 'storage')
oldValue = null
if hasListeners
oldValue = this.getItem(key)
delete @metaKeyMap[key]
@length -= 1
@bytesInUse -= metaKey.size
filename = path.join(@location, metaKey.key)
@keys.splice... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 2aff35665f6c1599a12623c40fc14216a5876531 | 460 | https://github.com/lmaccherone/node-localstorage/blob/2aff35665f6c1599a12623c40fc14216a5876531/LocalStorage.coffee | 129 | 162 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:7:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
if (!!metaKey)
hasListeners = events.EventEmitter.listenerCount(this, 'storage')
oldValue = null
if hasListeners
oldValue = this.getItem(key)
delete @metaKeyMap[key]
@length -= 1
@bytesInUse -= metaKey.size
filena... | var evnt, filename, hasListeners, oldValue;
if (!!metaKey) {
hasListeners = events.EventEmitter.listenerCount(this, 'storage');
oldValue = null;
if (hasListeners) {
oldValue = this.getItem(key);
}
delete this.metaKeyMap[key];
this.length -= 1;
this.bytesInUse -= metaKey.size;
filename = path.join(t... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 2aff35665f6c1599a12623c40fc14216a5876531 | 460 | https://github.com/lmaccherone/node-localstorage/blob/2aff35665f6c1599a12623c40fc14216a5876531/LocalStorage.coffee | 129 | 162 |
lmaccherone/node-localstorage:LocalStorage.coffee:7:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var evnt, filename, hasListeners, oldValue;
if (!!metaKey) {
hasListeners = events.EventEmitter.listenerCount(this, 'storage');
oldValue = null;
if (hasListeners) {
oldValue = this.getItem(key);
}
delete this.metaKeyMap[key];
this.length -= 1;
th... | if (!!metaKey)
hasListeners = events.EventEmitter.listenerCount(this, 'storage')
oldValue = null
if hasListeners
oldValue = this.getItem(key)
delete @metaKeyMap[key]
@length -= 1
@bytesInUse -= metaKey.size
filename = path.join(@location, metaKey.key)
@keys.splice... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 2aff35665f6c1599a12623c40fc14216a5876531 | 460 | https://github.com/lmaccherone/node-localstorage/blob/2aff35665f6c1599a12623c40fc14216a5876531/LocalStorage.coffee | 129 | 162 |
lmaccherone/node-localstorage:LocalStorage.coffee:7:completion | completion | if (!!metaKey)
hasListeners = events.EventEmitter.listenerCount(this, 'storage')
oldValue = null
if hasListeners
oldValue = this.getItem(key)
delete @metaKeyMap[key]
@length -= 1
@bytesInUse -= metaKey.size
filename = path.join(@location, metaKey.key)
@keys.splice... | clear: () ->
_emptyDirectory(@location)
@metaKeyMap = createMap()
@keys = []
@length = 0
@bytesInUse = 0
getBytesInUse: () ->
return @bytesInUse
_deleteLocation: () ->
_rm(@location)
@metaKeyMap = {}
@keys = []
@length = 0
@bytesInUse = 0 | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 2aff35665f6c1599a12623c40fc14216a5876531 | 460 | https://github.com/lmaccherone/node-localstorage/blob/2aff35665f6c1599a12623c40fc14216a5876531/LocalStorage.coffee | 129 | 162 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:raw_corpus | raw_corpus | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
unless this instanceof LocalStorage
return new LocalStorage(@location, @quota)
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@metaKeyMap = createMap()
@_in... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | d605500d5f07a7a0a0e255dde133554a7be356b0 | 460 | https://github.com/lmaccherone/node-localstorage/blob/d605500d5f07a7a0a0e255dde133554a7be356b0/LocalStorage.coffee | 24 | 73 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
unless this instanceof LocalStorage
return new LocalStorage(@location, @quota)
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse ... | var LocalStorage;
LocalStorage = (function() {
var MetaKey, createMap;
class LocalStorage {
constructor(location, quota = 5 * 1024 * 1024) {
this.location = location;
this.quota = quota;
if (!(this instanceof LocalStorage)) {
return new LocalStorage(this.location, this.quota);
... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | d605500d5f07a7a0a0e255dde133554a7be356b0 | 460 | https://github.com/lmaccherone/node-localstorage/blob/d605500d5f07a7a0a0e255dde133554a7be356b0/LocalStorage.coffee | 24 | 73 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var LocalStorage;
LocalStorage = (function() {
var MetaKey, createMap;
class LocalStorage {
constructor(location, quota = 5 * 1024 * 1024) {
this.location = location;
this.quota = quota;
if (!(this instanceof LocalStorage)) {
ret... | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
unless this instanceof LocalStorage
return new LocalStorage(@location, @quota)
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@metaKeyMap = createMap()
@_in... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | d605500d5f07a7a0a0e255dde133554a7be356b0 | 460 | https://github.com/lmaccherone/node-localstorage/blob/d605500d5f07a7a0a0e255dde133554a7be356b0/LocalStorage.coffee | 24 | 73 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:completion | completion | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
unless this instanceof LocalStorage
return new LocalStorage(@location, @quota)
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@metaKeyMap = createMap()
@_in... | _init: () ->
if fs.existsSync(@location)
unless fs.statSync(@location).isDirectory()
throw new Error("A file exists at the location '#{@location}' when trying to create/open localStorage")
@bytesInUse = 0
@length = 0
unless fs.existsSync(@location)
fs.mkdirSync(@location)
retu... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | d605500d5f07a7a0a0e255dde133554a7be356b0 | 460 | https://github.com/lmaccherone/node-localstorage/blob/d605500d5f07a7a0a0e255dde133554a7be356b0/LocalStorage.coffee | 24 | 73 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:raw_corpus | raw_corpus | setItem: (key, value) ->
key = key.toString()
encodedKey = encodeURIComponent(key)
filename = path.join(@location, encodedKey)
valueString = value.toString()
valueStringLength = valueString.length
metaKey = @metaKeyMap[key]
existsBeforeSet = !!metaKey
if existsBeforeSet
oldLength =... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | d605500d5f07a7a0a0e255dde133554a7be356b0 | 460 | https://github.com/lmaccherone/node-localstorage/blob/d605500d5f07a7a0a0e255dde133554a7be356b0/LocalStorage.coffee | 74 | 123 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:5:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
setItem: (key, value) ->
key = key.toString()
encodedKey = encodeURIComponent(key)
filename = path.join(@location, encodedKey)
valueString = value.toString()
valueStringLength = valueString.length
metaKey = @metaKeyMap[key]
existsBefor... | ({
setItem: function(key, value) {
var encodedKey, existsBeforeSet, filename, metaKey, oldLength, valueString, valueStringLength;
key = key.toString();
encodedKey = encodeURIComponent(key);
filename = path.join(this.location, encodedKey);
valueString = value.toString();
valueStringLength = val... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | d605500d5f07a7a0a0e255dde133554a7be356b0 | 460 | https://github.com/lmaccherone/node-localstorage/blob/d605500d5f07a7a0a0e255dde133554a7be356b0/LocalStorage.coffee | 74 | 123 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
setItem: function(key, value) {
var encodedKey, existsBeforeSet, filename, metaKey, oldLength, valueString, valueStringLength;
key = key.toString();
encodedKey = encodeURIComponent(key);
filename = path.join(this.location, encodedKey);
valu... | setItem: (key, value) ->
key = key.toString()
encodedKey = encodeURIComponent(key)
filename = path.join(@location, encodedKey)
valueString = value.toString()
valueStringLength = valueString.length
metaKey = @metaKeyMap[key]
existsBeforeSet = !!metaKey
if existsBeforeSet
oldLength =... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | d605500d5f07a7a0a0e255dde133554a7be356b0 | 460 | https://github.com/lmaccherone/node-localstorage/blob/d605500d5f07a7a0a0e255dde133554a7be356b0/LocalStorage.coffee | 74 | 123 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:completion | completion | setItem: (key, value) ->
key = key.toString()
encodedKey = encodeURIComponent(key)
filename = path.join(@location, encodedKey)
valueString = value.toString()
valueStringLength = valueString.length
metaKey = @metaKeyMap[key]
existsBeforeSet = !!metaKey
if existsBeforeSet
oldLength =... | metaKey = @metaKeyMap[key]
if !!metaKey
filename = path.join(@location, metaKey.key)
return fs.readFileSync(filename, 'utf8')
else
return null
getStat: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
return ... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | d605500d5f07a7a0a0e255dde133554a7be356b0 | 460 | https://github.com/lmaccherone/node-localstorage/blob/d605500d5f07a7a0a0e255dde133554a7be356b0/LocalStorage.coffee | 74 | 123 |
lmaccherone/node-localstorage:LocalStorage.coffee:6:raw_corpus | raw_corpus | key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location)
@metaKeyMap = createMap()
@keys = []
@length = 0
@bytesInUse = 0
getBytesInUse: () ->
return @bytesInUse
_deleteLocation: () ->
_rm(@location)
@metaKeyMap = {}
@keys = []
@length = 0
@bytesInUse ... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | d605500d5f07a7a0a0e255dde133554a7be356b0 | 460 | https://github.com/lmaccherone/node-localstorage/blob/d605500d5f07a7a0a0e255dde133554a7be356b0/LocalStorage.coffee | 124 | 143 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:6:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location)
@metaKeyMap = createMap()
@keys = []
@length = 0
@bytesInUse = 0
getBytesInUse: () ->
return @bytesInUse
_deleteLocation: () ->
_rm(@location)
@metaKe... | ({
key: function(n) {
return this.keys[n];
},
clear: function() {
_emptyDirectory(this.location);
this.metaKeyMap = createMap();
this.keys = [];
this.length = 0;
return this.bytesInUse = 0;
},
getBytesInUse: function() {
return this.bytesInUse;
},
_deleteLocation: function() {
... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | d605500d5f07a7a0a0e255dde133554a7be356b0 | 460 | https://github.com/lmaccherone/node-localstorage/blob/d605500d5f07a7a0a0e255dde133554a7be356b0/LocalStorage.coffee | 124 | 143 |
lmaccherone/node-localstorage:LocalStorage.coffee:6:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
key: function(n) {
return this.keys[n];
},
clear: function() {
_emptyDirectory(this.location);
this.metaKeyMap = createMap();
this.keys = [];
this.length = 0;
return this.bytesInUse = 0;
},
getBytesInUse: function() {
return... | key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location)
@metaKeyMap = createMap()
@keys = []
@length = 0
@bytesInUse = 0
getBytesInUse: () ->
return @bytesInUse
_deleteLocation: () ->
_rm(@location)
@metaKeyMap = {}
@keys = []
@length = 0
@bytesInUse ... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | d605500d5f07a7a0a0e255dde133554a7be356b0 | 460 | https://github.com/lmaccherone/node-localstorage/blob/d605500d5f07a7a0a0e255dde133554a7be356b0/LocalStorage.coffee | 124 | 143 |
lmaccherone/node-localstorage:LocalStorage.coffee:6:completion | completion | key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location)
@metaKeyMap = createMap()
@keys = []
@length = 0
@bytesInUse = 0 | getBytesInUse: () ->
return @bytesInUse
_deleteLocation: () ->
_rm(@location)
@metaKeyMap = {}
@keys = []
@length = 0
@bytesInUse = 0 | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | d605500d5f07a7a0a0e255dde133554a7be356b0 | 460 | https://github.com/lmaccherone/node-localstorage/blob/d605500d5f07a7a0a0e255dde133554a7be356b0/LocalStorage.coffee | 124 | 143 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:raw_corpus | raw_corpus | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
unless this instanceof LocalStorage
return new LocalStorage(@location, @quota)
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QUOTA_EXCEEDED_ERR =... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | a2f00fc1e207c477910dd6636c7d9e678bc1d6d7 | 460 | https://github.com/lmaccherone/node-localstorage/blob/a2f00fc1e207c477910dd6636c7d9e678bc1d6d7/LocalStorage.coffee | 23 | 72 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
unless this instanceof LocalStorage
return new LocalStorage(@location, @quota)
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse ... | var LocalStorage;
LocalStorage = class LocalStorage {
constructor(location, quota = 5 * 1024 * 1024) {
this.location = location;
this.quota = quota;
if (!(this instanceof LocalStorage)) {
return new LocalStorage(this.location, this.quota);
}
this.length = 0; // !TODO: Maybe change this to a... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | a2f00fc1e207c477910dd6636c7d9e678bc1d6d7 | 460 | https://github.com/lmaccherone/node-localstorage/blob/a2f00fc1e207c477910dd6636c7d9e678bc1d6d7/LocalStorage.coffee | 23 | 72 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var LocalStorage;
LocalStorage = class LocalStorage {
constructor(location, quota = 5 * 1024 * 1024) {
this.location = location;
this.quota = quota;
if (!(this instanceof LocalStorage)) {
return new LocalStorage(this.location, this.quota);
... | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
unless this instanceof LocalStorage
return new LocalStorage(@location, @quota)
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QUOTA_EXCEEDED_ERR =... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | a2f00fc1e207c477910dd6636c7d9e678bc1d6d7 | 460 | https://github.com/lmaccherone/node-localstorage/blob/a2f00fc1e207c477910dd6636c7d9e678bc1d6d7/LocalStorage.coffee | 23 | 72 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:completion | completion | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
unless this instanceof LocalStorage
return new LocalStorage(@location, @quota)
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QUOTA_EXCEEDED_ERR =... | setItem: (key, value) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
existsBeforeSet = fs.existsSync(filename)
valueString = value.toString()
valueStringLength = valueString.length
if existsBeforeSet
oldLength = @getStat(key).size
else
oldLength ... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | a2f00fc1e207c477910dd6636c7d9e678bc1d6d7 | 460 | https://github.com/lmaccherone/node-localstorage/blob/a2f00fc1e207c477910dd6636c7d9e678bc1d6d7/LocalStorage.coffee | 23 | 72 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:raw_corpus | raw_corpus | getStat: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
return fs.statSync(filename,'utf8')
else
return null
removeItem: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | a2f00fc1e207c477910dd6636c7d9e678bc1d6d7 | 460 | https://github.com/lmaccherone/node-localstorage/blob/a2f00fc1e207c477910dd6636c7d9e678bc1d6d7/LocalStorage.coffee | 73 | 105 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:5:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
getStat: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
return fs.statSync(filename,'utf8')
else
return null
removeItem: (key) ->
key = key.toString()
filena... | ({
getStat: function(key) {
var filename;
key = key.toString();
filename = path.join(this.location, encodeURIComponent(key));
if (fs.existsSync(filename)) {
return fs.statSync(filename, 'utf8');
} else {
return null;
}
},
removeItem: function(key) {
var filename;
key = ... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | a2f00fc1e207c477910dd6636c7d9e678bc1d6d7 | 460 | https://github.com/lmaccherone/node-localstorage/blob/a2f00fc1e207c477910dd6636c7d9e678bc1d6d7/LocalStorage.coffee | 73 | 105 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
getStat: function(key) {
var filename;
key = key.toString();
filename = path.join(this.location, encodeURIComponent(key));
if (fs.existsSync(filename)) {
return fs.statSync(filename, 'utf8');
} else {
return null;
}
},
r... | getStat: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
return fs.statSync(filename,'utf8')
else
return null
removeItem: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | a2f00fc1e207c477910dd6636c7d9e678bc1d6d7 | 460 | https://github.com/lmaccherone/node-localstorage/blob/a2f00fc1e207c477910dd6636c7d9e678bc1d6d7/LocalStorage.coffee | 73 | 105 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:completion | completion | getStat: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
return fs.statSync(filename,'utf8')
else
return null
removeItem: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if... | return @keys[n]
clear: () ->
_emptyDirectory(@location)
@keys = []
@length = 0
@bytesInUse = 0
getBytesInUse: () ->
return @bytesInUse
_deleteLocation: () ->
_rm(@location)
@keys = []
@length = 0
@bytesInUse = 0 | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | a2f00fc1e207c477910dd6636c7d9e678bc1d6d7 | 460 | https://github.com/lmaccherone/node-localstorage/blob/a2f00fc1e207c477910dd6636c7d9e678bc1d6d7/LocalStorage.coffee | 73 | 105 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:raw_corpus | raw_corpus | getStat: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
return fs.statSync(filename,'utf8')
else
return null
removeItem: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if ... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | baec97ed3ba09e0406b73fcfbfd147af512a75f2 | 460 | https://github.com/lmaccherone/node-localstorage/blob/baec97ed3ba09e0406b73fcfbfd147af512a75f2/LocalStorage.coffee | 73 | 106 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:5:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
getStat: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
return fs.statSync(filename,'utf8')
else
return null
removeItem: (key) ->
key = key.toString()
filenam... | ({
getStat: function(key) {
var filename;
key = key.toString();
filename = path.join(this.location, encodeURIComponent(key));
if (fs.existsSync(filename)) {
return fs.statSync(filename, 'utf8');
} else {
return null;
}
},
removeItem: function(key) {
var filename;
key = ... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | baec97ed3ba09e0406b73fcfbfd147af512a75f2 | 460 | https://github.com/lmaccherone/node-localstorage/blob/baec97ed3ba09e0406b73fcfbfd147af512a75f2/LocalStorage.coffee | 73 | 106 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
getStat: function(key) {
var filename;
key = key.toString();
filename = path.join(this.location, encodeURIComponent(key));
if (fs.existsSync(filename)) {
return fs.statSync(filename, 'utf8');
} else {
return null;
}
},
r... | getStat: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
return fs.statSync(filename,'utf8')
else
return null
removeItem: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if ... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | baec97ed3ba09e0406b73fcfbfd147af512a75f2 | 460 | https://github.com/lmaccherone/node-localstorage/blob/baec97ed3ba09e0406b73fcfbfd147af512a75f2/LocalStorage.coffee | 73 | 106 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:completion | completion | getStat: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
return fs.statSync(filename,'utf8')
else
return null
removeItem: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if ... | clear: () ->
_emptyDirectory(@location)
@keys = []
@length = 0
@bytesInUse = 0
getBytesInUse: () ->
return @bytesInUse
_deleteLocation: () ->
_rm(@location)
@keys = []
@length = 0
@bytesInUse = 0
exports.LocalStorage = LocalStorage
exports.QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_E... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | baec97ed3ba09e0406b73fcfbfd147af512a75f2 | 460 | https://github.com/lmaccherone/node-localstorage/blob/baec97ed3ba09e0406b73fcfbfd147af512a75f2/LocalStorage.coffee | 73 | 106 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:raw_corpus | raw_corpus | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
unless this instanceof LocalStorage
return new LocalStorage(@location, @quota)
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QUOTA_EXCEEDED_ERR =... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | e86cf83775f0c1da8b1488f8e5b808616d9c976d | 460 | https://github.com/lmaccherone/node-localstorage/blob/e86cf83775f0c1da8b1488f8e5b808616d9c976d/LocalStorage.coffee | 23 | 72 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
unless this instanceof LocalStorage
return new LocalStorage(@location, @quota)
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse ... | var LocalStorage;
LocalStorage = class LocalStorage {
constructor(location, quota = 5 * 1024 * 1024) {
this.location = location;
this.quota = quota;
if (!(this instanceof LocalStorage)) {
return new LocalStorage(this.location, this.quota);
}
this.length = 0; // !TODO: Maybe change this to a... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | e86cf83775f0c1da8b1488f8e5b808616d9c976d | 460 | https://github.com/lmaccherone/node-localstorage/blob/e86cf83775f0c1da8b1488f8e5b808616d9c976d/LocalStorage.coffee | 23 | 72 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var LocalStorage;
LocalStorage = class LocalStorage {
constructor(location, quota = 5 * 1024 * 1024) {
this.location = location;
this.quota = quota;
if (!(this instanceof LocalStorage)) {
return new LocalStorage(this.location, this.quota);
... | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
unless this instanceof LocalStorage
return new LocalStorage(@location, @quota)
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QUOTA_EXCEEDED_ERR =... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | e86cf83775f0c1da8b1488f8e5b808616d9c976d | 460 | https://github.com/lmaccherone/node-localstorage/blob/e86cf83775f0c1da8b1488f8e5b808616d9c976d/LocalStorage.coffee | 23 | 72 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:completion | completion | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
unless this instanceof LocalStorage
return new LocalStorage(@location, @quota)
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QUOTA_EXCEEDED_ERR =... | setItem: (key, value) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
existsBeforeSet = fs.existsSync(filename)
valueString = value.toString()
valueStringLength = valueString.length
if existsBeforeSet
oldLength = @getItem(key).length
else
oldLengt... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | e86cf83775f0c1da8b1488f8e5b808616d9c976d | 460 | https://github.com/lmaccherone/node-localstorage/blob/e86cf83775f0c1da8b1488f8e5b808616d9c976d/LocalStorage.coffee | 23 | 72 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:raw_corpus | raw_corpus | getStat: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
return fs.statSync('Cakefile','utf8')
else
return null
removeItem: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
i... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | e86cf83775f0c1da8b1488f8e5b808616d9c976d | 460 | https://github.com/lmaccherone/node-localstorage/blob/e86cf83775f0c1da8b1488f8e5b808616d9c976d/LocalStorage.coffee | 73 | 106 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:5:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
getStat: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
return fs.statSync('Cakefile','utf8')
else
return null
removeItem: (key) ->
key = key.toString()
filen... | ({
getStat: function(key) {
var filename;
key = key.toString();
filename = path.join(this.location, encodeURIComponent(key));
if (fs.existsSync(filename)) {
return fs.statSync('Cakefile', 'utf8');
} else {
return null;
}
},
removeItem: function(key) {
var filename;
key ... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | e86cf83775f0c1da8b1488f8e5b808616d9c976d | 460 | https://github.com/lmaccherone/node-localstorage/blob/e86cf83775f0c1da8b1488f8e5b808616d9c976d/LocalStorage.coffee | 73 | 106 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
getStat: function(key) {
var filename;
key = key.toString();
filename = path.join(this.location, encodeURIComponent(key));
if (fs.existsSync(filename)) {
return fs.statSync('Cakefile', 'utf8');
} else {
return null;
}
},
... | getStat: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
return fs.statSync('Cakefile','utf8')
else
return null
removeItem: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
i... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | e86cf83775f0c1da8b1488f8e5b808616d9c976d | 460 | https://github.com/lmaccherone/node-localstorage/blob/e86cf83775f0c1da8b1488f8e5b808616d9c976d/LocalStorage.coffee | 73 | 106 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:completion | completion | getStat: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
return fs.statSync('Cakefile','utf8')
else
return null
removeItem: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
i... | clear: () ->
_emptyDirectory(@location)
@keys = []
@length = 0
@bytesInUse = 0
getBytesInUse: () ->
return @bytesInUse
_deleteLocation: () ->
_rm(@location)
@keys = []
@length = 0
@bytesInUse = 0
exports.LocalStorage = LocalStorage
exports.QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_E... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | e86cf83775f0c1da8b1488f8e5b808616d9c976d | 460 | https://github.com/lmaccherone/node-localstorage/blob/e86cf83775f0c1da8b1488f8e5b808616d9c976d/LocalStorage.coffee | 73 | 106 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:raw_corpus | raw_corpus | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
unless this instanceof LocalStorage
return new LocalStorage(@location, @quota)
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QUOTA_EXCEEDED_ERR =... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | abdb3fdc10662dc0228bdb39fd70a2b9bd75439b | 460 | https://github.com/lmaccherone/node-localstorage/blob/abdb3fdc10662dc0228bdb39fd70a2b9bd75439b/LocalStorage.coffee | 23 | 72 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
unless this instanceof LocalStorage
return new LocalStorage(@location, @quota)
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse ... | var LocalStorage;
LocalStorage = class LocalStorage {
constructor(location, quota = 5 * 1024 * 1024) {
this.location = location;
this.quota = quota;
if (!(this instanceof LocalStorage)) {
return new LocalStorage(this.location, this.quota);
}
this.length = 0; // !TODO: Maybe change this to a... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | abdb3fdc10662dc0228bdb39fd70a2b9bd75439b | 460 | https://github.com/lmaccherone/node-localstorage/blob/abdb3fdc10662dc0228bdb39fd70a2b9bd75439b/LocalStorage.coffee | 23 | 72 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var LocalStorage;
LocalStorage = class LocalStorage {
constructor(location, quota = 5 * 1024 * 1024) {
this.location = location;
this.quota = quota;
if (!(this instanceof LocalStorage)) {
return new LocalStorage(this.location, this.quota);
... | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
unless this instanceof LocalStorage
return new LocalStorage(@location, @quota)
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QUOTA_EXCEEDED_ERR =... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | abdb3fdc10662dc0228bdb39fd70a2b9bd75439b | 460 | https://github.com/lmaccherone/node-localstorage/blob/abdb3fdc10662dc0228bdb39fd70a2b9bd75439b/LocalStorage.coffee | 23 | 72 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:completion | completion | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
unless this instanceof LocalStorage
return new LocalStorage(@location, @quota)
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QUOTA_EXCEEDED_ERR =... | setItem: (key, value) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
existsBeforeSet = fs.existsSync(filename)
valueString = value.toString()
valueStringLength = valueString.length
if existsBeforeSet
oldLength = @getItem(key).length
else
oldLengt... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | abdb3fdc10662dc0228bdb39fd70a2b9bd75439b | 460 | https://github.com/lmaccherone/node-localstorage/blob/abdb3fdc10662dc0228bdb39fd70a2b9bd75439b/LocalStorage.coffee | 23 | 72 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:raw_corpus | raw_corpus | removeItem: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
_rm(filename)
@_init() # !TODO: Find a faster way to set @keys, length, and bytesInUse
key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location)
... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | abdb3fdc10662dc0228bdb39fd70a2b9bd75439b | 460 | https://github.com/lmaccherone/node-localstorage/blob/abdb3fdc10662dc0228bdb39fd70a2b9bd75439b/LocalStorage.coffee | 73 | 100 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:5:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
removeItem: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
_rm(filename)
@_init() # !TODO: Find a faster way to set @keys, length, and bytesInUse
key: (n) ->
return @... | ({
removeItem: function(key) {
var filename;
key = key.toString();
filename = path.join(this.location, encodeURIComponent(key));
if (fs.existsSync(filename)) {
_rm(filename);
}
return this._init(); // !TODO: Find a faster way to set @keys, length, and bytesInUse
},
key: function(n) {... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | abdb3fdc10662dc0228bdb39fd70a2b9bd75439b | 460 | https://github.com/lmaccherone/node-localstorage/blob/abdb3fdc10662dc0228bdb39fd70a2b9bd75439b/LocalStorage.coffee | 73 | 100 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
removeItem: function(key) {
var filename;
key = key.toString();
filename = path.join(this.location, encodeURIComponent(key));
if (fs.existsSync(filename)) {
_rm(filename);
}
return this._init(); // !TODO: Find a faster way to set ... | removeItem: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
_rm(filename)
@_init() # !TODO: Find a faster way to set @keys, length, and bytesInUse
key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location)
... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | abdb3fdc10662dc0228bdb39fd70a2b9bd75439b | 460 | https://github.com/lmaccherone/node-localstorage/blob/abdb3fdc10662dc0228bdb39fd70a2b9bd75439b/LocalStorage.coffee | 73 | 100 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:completion | completion | removeItem: (key) ->
key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
_rm(filename)
@_init() # !TODO: Find a faster way to set @keys, length, and bytesInUse
key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location)
... | @length = 0
@bytesInUse = 0
getBytesInUse: () ->
return @bytesInUse
_deleteLocation: () ->
_rm(@location)
@keys = []
@length = 0
@bytesInUse = 0
exports.LocalStorage = LocalStorage
exports.QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_ERR | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | abdb3fdc10662dc0228bdb39fd70a2b9bd75439b | 460 | https://github.com/lmaccherone/node-localstorage/blob/abdb3fdc10662dc0228bdb39fd70a2b9bd75439b/LocalStorage.coffee | 73 | 100 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:raw_corpus | raw_corpus | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_ERR
_init: () ->
if fs.existsSync(@location)
unless fs.statS... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 4f23ecf9342bc2b05cb745e085b5431f433442a0 | 460 | https://github.com/lmaccherone/node-localstorage/blob/4f23ecf9342bc2b05cb745e085b5431f433442a0/LocalStorage.coffee | 23 | 72 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_ERR
_init: ()... | var LocalStorage;
LocalStorage = class LocalStorage {
constructor(location, quota = 5 * 1024 * 1024) {
this.location = location;
this.quota = quota;
this.length = 0; // !TODO: Maybe change this to a property with __defineProperty__
this.bytesInUse = 0;
this.keys = [];
this._init();
this.Q... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 4f23ecf9342bc2b05cb745e085b5431f433442a0 | 460 | https://github.com/lmaccherone/node-localstorage/blob/4f23ecf9342bc2b05cb745e085b5431f433442a0/LocalStorage.coffee | 23 | 72 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var LocalStorage;
LocalStorage = class LocalStorage {
constructor(location, quota = 5 * 1024 * 1024) {
this.location = location;
this.quota = quota;
this.length = 0; // !TODO: Maybe change this to a property with __defineProperty__
this.bytesInUs... | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_ERR
_init: () ->
if fs.existsSync(@location)
unless fs.statS... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 4f23ecf9342bc2b05cb745e085b5431f433442a0 | 460 | https://github.com/lmaccherone/node-localstorage/blob/4f23ecf9342bc2b05cb745e085b5431f433442a0/LocalStorage.coffee | 23 | 72 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:completion | completion | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_ERR
_init: () ->
if fs.existsSync(@location)
unless fs.statS... | filename = path.join(@location, encodeURIComponent(key))
existsBeforeSet = fs.existsSync(filename)
valueString = value.toString()
valueStringLength = valueString.length
if existsBeforeSet
oldLength = @getItem(key).length
else
oldLength = 0
if @bytesInUse - oldLength + valueStringLeng... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 4f23ecf9342bc2b05cb745e085b5431f433442a0 | 460 | https://github.com/lmaccherone/node-localstorage/blob/4f23ecf9342bc2b05cb745e085b5431f433442a0/LocalStorage.coffee | 23 | 72 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:raw_corpus | raw_corpus | key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
_rm(filename)
@_init() # !TODO: Find a faster way to set @keys, length, and bytesInUse
key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location)
@keys = []
@length ... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 4f23ecf9342bc2b05cb745e085b5431f433442a0 | 460 | https://github.com/lmaccherone/node-localstorage/blob/4f23ecf9342bc2b05cb745e085b5431f433442a0/LocalStorage.coffee | 73 | 98 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:5:completion | completion | key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
_rm(filename)
@_init() # !TODO: Find a faster way to set @keys, length, and bytesInUse
key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location)
@keys = []
@length ... | @bytesInUse = 0
getBytesInUse: () ->
return @bytesInUse
_deleteLocation: () ->
_rm(@location)
@keys = []
@length = 0
@bytesInUse = 0
exports.LocalStorage = LocalStorage
exports.QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_ERR | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 4f23ecf9342bc2b05cb745e085b5431f433442a0 | 460 | https://github.com/lmaccherone/node-localstorage/blob/4f23ecf9342bc2b05cb745e085b5431f433442a0/LocalStorage.coffee | 73 | 98 |
lmaccherone/node-localstorage:LocalStorage.coffee:3:raw_corpus | raw_corpus | class QUOTA_EXCEEDED_ERR extends Error
constructor: (@message = 'Unknown error.') ->
if Error.captureStackTrace?
Error.captureStackTrace(this, @constructor)
@name = @constructor.name | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 0bc62b093620c60b1bf7d24973afbb83bf380e55 | 460 | https://github.com/lmaccherone/node-localstorage/blob/0bc62b093620c60b1bf7d24973afbb83bf380e55/LocalStorage.coffee | 14 | 18 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:3:completion | completion | class QUOTA_EXCEEDED_ERR extends Error
constructor: (@message = 'Unknown error.') -> | if Error.captureStackTrace?
Error.captureStackTrace(this, @constructor)
@name = @constructor.name | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 0bc62b093620c60b1bf7d24973afbb83bf380e55 | 460 | https://github.com/lmaccherone/node-localstorage/blob/0bc62b093620c60b1bf7d24973afbb83bf380e55/LocalStorage.coffee | 14 | 18 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:raw_corpus | raw_corpus | key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
_rm(filename)
@_init() # !TODO: Find a faster way to set @keys, length, and bytesInUse
key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location)
@keys = []
@length ... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 0bc62b093620c60b1bf7d24973afbb83bf380e55 | 460 | https://github.com/lmaccherone/node-localstorage/blob/0bc62b093620c60b1bf7d24973afbb83bf380e55/LocalStorage.coffee | 70 | 92 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:5:completion | completion | key = key.toString()
filename = path.join(@location, encodeURIComponent(key))
if fs.existsSync(filename)
_rm(filename)
@_init() # !TODO: Find a faster way to set @keys, length, and bytesInUse
key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location) | @keys = []
@length = 0
@bytesInUse = 0
getBytesInUse: () ->
return @bytesInUse
_deleteLocation: () ->
_rm(@location)
@keys = []
@length = 0
@bytesInUse = 0 | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 0bc62b093620c60b1bf7d24973afbb83bf380e55 | 460 | https://github.com/lmaccherone/node-localstorage/blob/0bc62b093620c60b1bf7d24973afbb83bf380e55/LocalStorage.coffee | 70 | 92 |
lmaccherone/node-localstorage:LocalStorage.coffee:6:raw_corpus | raw_corpus | toString: ->
return "#{@name}: #{@message}"
exports.LocalStorage = LocalStorage
exports.QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_ERR | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 0bc62b093620c60b1bf7d24973afbb83bf380e55 | 460 | https://github.com/lmaccherone/node-localstorage/blob/0bc62b093620c60b1bf7d24973afbb83bf380e55/LocalStorage.coffee | 94 | 98 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:6:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
toString: ->
return "#{@name}: #{@message}"
exports.LocalStorage = LocalStorage
exports.QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_ERR
``` | ({
toString: function() {
return `${this.name}: ${this.message}`;
}
});
exports.LocalStorage = LocalStorage;
exports.QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_ERR; | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 0bc62b093620c60b1bf7d24973afbb83bf380e55 | 460 | https://github.com/lmaccherone/node-localstorage/blob/0bc62b093620c60b1bf7d24973afbb83bf380e55/LocalStorage.coffee | 94 | 98 |
lmaccherone/node-localstorage:LocalStorage.coffee:6:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
toString: function() {
return `${this.name}: ${this.message}`;
}
});
exports.LocalStorage = LocalStorage;
exports.QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_ERR;
``` | toString: ->
return "#{@name}: #{@message}"
exports.LocalStorage = LocalStorage
exports.QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_ERR | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 0bc62b093620c60b1bf7d24973afbb83bf380e55 | 460 | https://github.com/lmaccherone/node-localstorage/blob/0bc62b093620c60b1bf7d24973afbb83bf380e55/LocalStorage.coffee | 94 | 98 |
lmaccherone/node-localstorage:LocalStorage.coffee:6:completion | completion | toString: ->
return "#{@name}: #{@message}" | exports.LocalStorage = LocalStorage
exports.QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_ERR | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 0bc62b093620c60b1bf7d24973afbb83bf380e55 | 460 | https://github.com/lmaccherone/node-localstorage/blob/0bc62b093620c60b1bf7d24973afbb83bf380e55/LocalStorage.coffee | 94 | 98 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:raw_corpus | raw_corpus | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_ERR
_init: () ->
if fs.existsSync(@location)
unless fs.statS... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 2740c6f5f2e11a1acd09acbd5f9cd19cd5bc54c3 | 460 | https://github.com/lmaccherone/node-localstorage/blob/2740c6f5f2e11a1acd09acbd5f9cd19cd5bc54c3/LocalStorage.coffee | 20 | 69 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_ERR
_init: ()... | var LocalStorage;
LocalStorage = class LocalStorage {
constructor(location, quota = 5 * 1024 * 1024) {
this.location = location;
this.quota = quota;
this.length = 0; // !TODO: Maybe change this to a property with __defineProperty__
this.bytesInUse = 0;
this.keys = [];
this._init();
this.Q... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 2740c6f5f2e11a1acd09acbd5f9cd19cd5bc54c3 | 460 | https://github.com/lmaccherone/node-localstorage/blob/2740c6f5f2e11a1acd09acbd5f9cd19cd5bc54c3/LocalStorage.coffee | 20 | 69 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var LocalStorage;
LocalStorage = class LocalStorage {
constructor(location, quota = 5 * 1024 * 1024) {
this.location = location;
this.quota = quota;
this.length = 0; // !TODO: Maybe change this to a property with __defineProperty__
this.bytesInUs... | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_ERR
_init: () ->
if fs.existsSync(@location)
unless fs.statS... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 2740c6f5f2e11a1acd09acbd5f9cd19cd5bc54c3 | 460 | https://github.com/lmaccherone/node-localstorage/blob/2740c6f5f2e11a1acd09acbd5f9cd19cd5bc54c3/LocalStorage.coffee | 20 | 69 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:completion | completion | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_ERR
_init: () ->
if fs.existsSync(@location)
unless fs.statS... | filename = path.join(@location, key)
existsBeforeSet = fs.existsSync(filename)
valueString = value.toString()
valueStringLength = valueString.length
if existsBeforeSet
oldLength = @getItem(key).length
else
oldLength = 0
if @bytesInUse - oldLength + valueStringLength > @quota
th... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 2740c6f5f2e11a1acd09acbd5f9cd19cd5bc54c3 | 460 | https://github.com/lmaccherone/node-localstorage/blob/2740c6f5f2e11a1acd09acbd5f9cd19cd5bc54c3/LocalStorage.coffee | 20 | 69 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:raw_corpus | raw_corpus | key = key.toString()
filename = path.join(@location, key)
if fs.existsSync(filename)
_rm(filename)
@_init() # !TODO: Find a faster way to set @keys, length, and bytesInUse
key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location)
@keys = []
@length = 0
@bytesInUse ... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 2740c6f5f2e11a1acd09acbd5f9cd19cd5bc54c3 | 460 | https://github.com/lmaccherone/node-localstorage/blob/2740c6f5f2e11a1acd09acbd5f9cd19cd5bc54c3/LocalStorage.coffee | 70 | 92 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:5:completion | completion | key = key.toString()
filename = path.join(@location, key)
if fs.existsSync(filename)
_rm(filename)
@_init() # !TODO: Find a faster way to set @keys, length, and bytesInUse
key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location) | @keys = []
@length = 0
@bytesInUse = 0
getBytesInUse: () ->
return @bytesInUse
_deleteLocation: () ->
_rm(@location)
@keys = []
@length = 0
@bytesInUse = 0 | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 2740c6f5f2e11a1acd09acbd5f9cd19cd5bc54c3 | 460 | https://github.com/lmaccherone/node-localstorage/blob/2740c6f5f2e11a1acd09acbd5f9cd19cd5bc54c3/LocalStorage.coffee | 70 | 92 |
lmaccherone/node-localstorage:LocalStorage.coffee:3:raw_corpus | raw_corpus | class QuotaExceededError extends Error
constructor: (@message = 'Unknown error.') ->
if Error.captureStackTrace?
Error.captureStackTrace(this, @constructor)
@name = @constructor.name | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 7caa3badaa3da756c1244881f804446bbd48a719 | 460 | https://github.com/lmaccherone/node-localstorage/blob/7caa3badaa3da756c1244881f804446bbd48a719/LocalStorage.coffee | 14 | 18 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:3:completion | completion | class QuotaExceededError extends Error
constructor: (@message = 'Unknown error.') -> | if Error.captureStackTrace?
Error.captureStackTrace(this, @constructor)
@name = @constructor.name | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 7caa3badaa3da756c1244881f804446bbd48a719 | 460 | https://github.com/lmaccherone/node-localstorage/blob/7caa3badaa3da756c1244881f804446bbd48a719/LocalStorage.coffee | 14 | 18 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:raw_corpus | raw_corpus | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QuotaExceededError = QuotaExceededError
_init: () ->
if fs.existsSync(@location)
unless fs.statS... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 7caa3badaa3da756c1244881f804446bbd48a719 | 460 | https://github.com/lmaccherone/node-localstorage/blob/7caa3badaa3da756c1244881f804446bbd48a719/LocalStorage.coffee | 20 | 69 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QuotaExceededError = QuotaExceededError
_init: ()... | var LocalStorage;
LocalStorage = class LocalStorage {
constructor(location, quota = 5 * 1024 * 1024) {
this.location = location;
this.quota = quota;
this.length = 0; // !TODO: Maybe change this to a property with __defineProperty__
this.bytesInUse = 0;
this.keys = [];
this._init();
this.Q... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 7caa3badaa3da756c1244881f804446bbd48a719 | 460 | https://github.com/lmaccherone/node-localstorage/blob/7caa3badaa3da756c1244881f804446bbd48a719/LocalStorage.coffee | 20 | 69 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var LocalStorage;
LocalStorage = class LocalStorage {
constructor(location, quota = 5 * 1024 * 1024) {
this.location = location;
this.quota = quota;
this.length = 0; // !TODO: Maybe change this to a property with __defineProperty__
this.bytesInUs... | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QuotaExceededError = QuotaExceededError
_init: () ->
if fs.existsSync(@location)
unless fs.statS... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 7caa3badaa3da756c1244881f804446bbd48a719 | 460 | https://github.com/lmaccherone/node-localstorage/blob/7caa3badaa3da756c1244881f804446bbd48a719/LocalStorage.coffee | 20 | 69 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:completion | completion | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QuotaExceededError = QuotaExceededError
_init: () ->
if fs.existsSync(@location)
unless fs.statS... | filename = path.join(@location, key)
existsBeforeSet = fs.existsSync(filename)
valueString = value.toString()
valueStringLength = valueString.length
if existsBeforeSet
oldLength = @getItem(key).length
else
oldLength = 0
if @bytesInUse - oldLength + valueStringLength > @quota
th... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 7caa3badaa3da756c1244881f804446bbd48a719 | 460 | https://github.com/lmaccherone/node-localstorage/blob/7caa3badaa3da756c1244881f804446bbd48a719/LocalStorage.coffee | 20 | 69 |
lmaccherone/node-localstorage:LocalStorage.coffee:6:raw_corpus | raw_corpus | toString: ->
return "#{@name}: #{@message}"
exports.LocalStorage = LocalStorage
exports.QuotaExceededError = QuotaExceededError | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 7caa3badaa3da756c1244881f804446bbd48a719 | 460 | https://github.com/lmaccherone/node-localstorage/blob/7caa3badaa3da756c1244881f804446bbd48a719/LocalStorage.coffee | 94 | 98 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:6:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
toString: ->
return "#{@name}: #{@message}"
exports.LocalStorage = LocalStorage
exports.QuotaExceededError = QuotaExceededError
``` | ({
toString: function() {
return `${this.name}: ${this.message}`;
}
});
exports.LocalStorage = LocalStorage;
exports.QuotaExceededError = QuotaExceededError; | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 7caa3badaa3da756c1244881f804446bbd48a719 | 460 | https://github.com/lmaccherone/node-localstorage/blob/7caa3badaa3da756c1244881f804446bbd48a719/LocalStorage.coffee | 94 | 98 |
lmaccherone/node-localstorage:LocalStorage.coffee:6:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
toString: function() {
return `${this.name}: ${this.message}`;
}
});
exports.LocalStorage = LocalStorage;
exports.QuotaExceededError = QuotaExceededError;
``` | toString: ->
return "#{@name}: #{@message}"
exports.LocalStorage = LocalStorage
exports.QuotaExceededError = QuotaExceededError | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 7caa3badaa3da756c1244881f804446bbd48a719 | 460 | https://github.com/lmaccherone/node-localstorage/blob/7caa3badaa3da756c1244881f804446bbd48a719/LocalStorage.coffee | 94 | 98 |
lmaccherone/node-localstorage:LocalStorage.coffee:6:completion | completion | toString: ->
return "#{@name}: #{@message}" | exports.LocalStorage = LocalStorage
exports.QuotaExceededError = QuotaExceededError | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 7caa3badaa3da756c1244881f804446bbd48a719 | 460 | https://github.com/lmaccherone/node-localstorage/blob/7caa3badaa3da756c1244881f804446bbd48a719/LocalStorage.coffee | 94 | 98 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:raw_corpus | raw_corpus | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QuotaExceededError = QuotaExceededError
_init: () ->
if fs.existsSync(@location)
unless fs.statS... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 87f0bece408eb003543a17e5068dba299246c73d | 460 | https://github.com/lmaccherone/node-localstorage/blob/87f0bece408eb003543a17e5068dba299246c73d/LocalStorage.coffee | 20 | 69 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QuotaExceededError = QuotaExceededError
_init: ()... | var LocalStorage;
LocalStorage = class LocalStorage {
constructor(location, quota = 5 * 1024 * 1024) {
this.location = location;
this.quota = quota;
this.length = 0; // !TODO: Maybe change this to a property with __defineProperty__
this.bytesInUse = 0;
this.keys = [];
this._init();
this.Q... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 87f0bece408eb003543a17e5068dba299246c73d | 460 | https://github.com/lmaccherone/node-localstorage/blob/87f0bece408eb003543a17e5068dba299246c73d/LocalStorage.coffee | 20 | 69 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var LocalStorage;
LocalStorage = class LocalStorage {
constructor(location, quota = 5 * 1024 * 1024) {
this.location = location;
this.quota = quota;
this.length = 0; // !TODO: Maybe change this to a property with __defineProperty__
this.bytesInUs... | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QuotaExceededError = QuotaExceededError
_init: () ->
if fs.existsSync(@location)
unless fs.statS... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 87f0bece408eb003543a17e5068dba299246c73d | 460 | https://github.com/lmaccherone/node-localstorage/blob/87f0bece408eb003543a17e5068dba299246c73d/LocalStorage.coffee | 20 | 69 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:completion | completion | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
@QuotaExceededError = QuotaExceededError
_init: () ->
if fs.existsSync(@location)
unless fs.statS... | filename = path.join(@location, key)
existsBeforeSet = fs.existsSync(filename)
valueString = value.toString()
valueStringLength = valueString.length
if existsBeforeSet
oldLength = @getItem(key).length
else
oldLength = 0
if @bytesInUse - oldLength + valueStringLength > @quota
e ... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 87f0bece408eb003543a17e5068dba299246c73d | 460 | https://github.com/lmaccherone/node-localstorage/blob/87f0bece408eb003543a17e5068dba299246c73d/LocalStorage.coffee | 20 | 69 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:raw_corpus | raw_corpus | removeItem: (key) ->
key = key.toString()
filename = path.join(@location, key)
if fs.existsSync(filename)
_rm(filename)
@_init() # !TODO: Find a faster way to set @keys, length, and bytesInUse
key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location)
@keys = []
@le... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 87f0bece408eb003543a17e5068dba299246c73d | 460 | https://github.com/lmaccherone/node-localstorage/blob/87f0bece408eb003543a17e5068dba299246c73d/LocalStorage.coffee | 70 | 94 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:5:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
removeItem: (key) ->
key = key.toString()
filename = path.join(@location, key)
if fs.existsSync(filename)
_rm(filename)
@_init() # !TODO: Find a faster way to set @keys, length, and bytesInUse
key: (n) ->
return @keys[n]
clear: ()... | ({
removeItem: function(key) {
var filename;
key = key.toString();
filename = path.join(this.location, key);
if (fs.existsSync(filename)) {
_rm(filename);
}
return this._init(); // !TODO: Find a faster way to set @keys, length, and bytesInUse
},
key: function(n) {
return this.key... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 87f0bece408eb003543a17e5068dba299246c73d | 460 | https://github.com/lmaccherone/node-localstorage/blob/87f0bece408eb003543a17e5068dba299246c73d/LocalStorage.coffee | 70 | 94 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
removeItem: function(key) {
var filename;
key = key.toString();
filename = path.join(this.location, key);
if (fs.existsSync(filename)) {
_rm(filename);
}
return this._init(); // !TODO: Find a faster way to set @keys, length, and b... | removeItem: (key) ->
key = key.toString()
filename = path.join(@location, key)
if fs.existsSync(filename)
_rm(filename)
@_init() # !TODO: Find a faster way to set @keys, length, and bytesInUse
key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location)
@keys = []
@le... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 87f0bece408eb003543a17e5068dba299246c73d | 460 | https://github.com/lmaccherone/node-localstorage/blob/87f0bece408eb003543a17e5068dba299246c73d/LocalStorage.coffee | 70 | 94 |
lmaccherone/node-localstorage:LocalStorage.coffee:5:completion | completion | removeItem: (key) ->
key = key.toString()
filename = path.join(@location, key)
if fs.existsSync(filename)
_rm(filename)
@_init() # !TODO: Find a faster way to set @keys, length, and bytesInUse
key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location) | @keys = []
@length = 0
@bytesInUse = 0
getBytesInUse: () ->
return @bytesInUse
_deleteLocation: () ->
_rm(@location)
@keys = []
@length = 0
@bytesInUse = 0 | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 87f0bece408eb003543a17e5068dba299246c73d | 460 | https://github.com/lmaccherone/node-localstorage/blob/87f0bece408eb003543a17e5068dba299246c73d/LocalStorage.coffee | 70 | 94 |
lmaccherone/node-localstorage:LocalStorage.coffee:3:raw_corpus | raw_corpus | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
_init: () ->
if fs.existsSync(@location)
unless fs.statSync(@location).isDirectory()
throw ne... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | b7878a0433eaa8dfc6b1dcdf0599d1ca8fa41f2f | 460 | https://github.com/lmaccherone/node-localstorage/blob/b7878a0433eaa8dfc6b1dcdf0599d1ca8fa41f2f/LocalStorage.coffee | 14 | 63 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
_init: () ->
if fs.existsSync(@location)
unl... | var LocalStorage;
LocalStorage = class LocalStorage {
constructor(location, quota = 5 * 1024 * 1024) {
this.location = location;
this.quota = quota;
this.length = 0; // !TODO: Maybe change this to a property with __defineProperty__
this.bytesInUse = 0;
this.keys = [];
this._init();
}
_in... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | b7878a0433eaa8dfc6b1dcdf0599d1ca8fa41f2f | 460 | https://github.com/lmaccherone/node-localstorage/blob/b7878a0433eaa8dfc6b1dcdf0599d1ca8fa41f2f/LocalStorage.coffee | 14 | 63 |
lmaccherone/node-localstorage:LocalStorage.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var LocalStorage;
LocalStorage = class LocalStorage {
constructor(location, quota = 5 * 1024 * 1024) {
this.location = location;
this.quota = quota;
this.length = 0; // !TODO: Maybe change this to a property with __defineProperty__
this.bytesInUs... | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
_init: () ->
if fs.existsSync(@location)
unless fs.statSync(@location).isDirectory()
throw ne... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | b7878a0433eaa8dfc6b1dcdf0599d1ca8fa41f2f | 460 | https://github.com/lmaccherone/node-localstorage/blob/b7878a0433eaa8dfc6b1dcdf0599d1ca8fa41f2f/LocalStorage.coffee | 14 | 63 |
lmaccherone/node-localstorage:LocalStorage.coffee:3:completion | completion | class LocalStorage
constructor: (@location, @quota = 5 * 1024 * 1024) ->
@length = 0 # !TODO: Maybe change this to a property with __defineProperty__
@bytesInUse = 0
@keys = []
@_init()
_init: () ->
if fs.existsSync(@location)
unless fs.statSync(@location).isDirectory()
throw ne... | filename = path.join(@location, key)
existsBeforeSet = fs.existsSync(filename)
valueString = value.toString()
valueStringLength = valueString.length
if existsBeforeSet
oldLength = @getItem(key).length
else
oldLength = 0
if @bytesInUse - oldLength + valueStringLength > @quota
e ... | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | b7878a0433eaa8dfc6b1dcdf0599d1ca8fa41f2f | 460 | https://github.com/lmaccherone/node-localstorage/blob/b7878a0433eaa8dfc6b1dcdf0599d1ca8fa41f2f/LocalStorage.coffee | 14 | 63 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:raw_corpus | raw_corpus | removeItem: (key) ->
key = key.toString()
filename = path.join(@location, key)
if fs.existsSync(filename)
_rm(filename)
@_init() # !TODO: Find a faster way to set @keys, length, and bytesInUse
key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location)
@keys = []
@le... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | b7878a0433eaa8dfc6b1dcdf0599d1ca8fa41f2f | 460 | https://github.com/lmaccherone/node-localstorage/blob/b7878a0433eaa8dfc6b1dcdf0599d1ca8fa41f2f/LocalStorage.coffee | 64 | 89 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
removeItem: (key) ->
key = key.toString()
filename = path.join(@location, key)
if fs.existsSync(filename)
_rm(filename)
@_init() # !TODO: Find a faster way to set @keys, length, and bytesInUse
key: (n) ->
return @keys[n]
clear: ()... | ({
removeItem: function(key) {
var filename;
key = key.toString();
filename = path.join(this.location, key);
if (fs.existsSync(filename)) {
_rm(filename);
}
return this._init(); // !TODO: Find a faster way to set @keys, length, and bytesInUse
},
key: function(n) {
return this.key... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | b7878a0433eaa8dfc6b1dcdf0599d1ca8fa41f2f | 460 | https://github.com/lmaccherone/node-localstorage/blob/b7878a0433eaa8dfc6b1dcdf0599d1ca8fa41f2f/LocalStorage.coffee | 64 | 89 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
({
removeItem: function(key) {
var filename;
key = key.toString();
filename = path.join(this.location, key);
if (fs.existsSync(filename)) {
_rm(filename);
}
return this._init(); // !TODO: Find a faster way to set @keys, length, and b... | removeItem: (key) ->
key = key.toString()
filename = path.join(@location, key)
if fs.existsSync(filename)
_rm(filename)
@_init() # !TODO: Find a faster way to set @keys, length, and bytesInUse
key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location)
@keys = []
@le... | JavaScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | b7878a0433eaa8dfc6b1dcdf0599d1ca8fa41f2f | 460 | https://github.com/lmaccherone/node-localstorage/blob/b7878a0433eaa8dfc6b1dcdf0599d1ca8fa41f2f/LocalStorage.coffee | 64 | 89 |
lmaccherone/node-localstorage:LocalStorage.coffee:4:completion | completion | removeItem: (key) ->
key = key.toString()
filename = path.join(@location, key)
if fs.existsSync(filename)
_rm(filename)
@_init() # !TODO: Find a faster way to set @keys, length, and bytesInUse
key: (n) ->
return @keys[n]
clear: () ->
_emptyDirectory(@location)
@keys = [] | @length = 0
@bytesInUse = 0
getBytesInUse: () ->
return @bytesInUse
_deleteLocation: () ->
_rm(@location)
@keys = []
@length = 0
@bytesInUse = 0
exports.LocalStorage = LocalStorage | CoffeeScript | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | b7878a0433eaa8dfc6b1dcdf0599d1ca8fa41f2f | 460 | https://github.com/lmaccherone/node-localstorage/blob/b7878a0433eaa8dfc6b1dcdf0599d1ca8fa41f2f/LocalStorage.coffee | 64 | 89 |
lmaccherone/node-localstorage:LocalStorage.coffee:1:raw_corpus | raw_corpus | path = require('path')
fs = require('fs')
_emptyDirectory = (target) ->
_rm(path.join(target, p)) for p in fs.readdirSync(target)
_rm = (target) ->
if fs.statSync(target).isDirectory()
_emptyDirectory(target)
fs.rmdirSync(target)
else
fs.unlinkSync(target)
class LocalStorage
constructor: (@locati... | CoffeeScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 2ff017439b39c854c5c1d5a6af45f8ca7b3af8d9 | 460 | https://github.com/lmaccherone/node-localstorage/blob/2ff017439b39c854c5c1d5a6af45f8ca7b3af8d9/LocalStorage.coffee | 1 | 50 | ||
lmaccherone/node-localstorage:LocalStorage.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
path = require('path')
fs = require('fs')
_emptyDirectory = (target) ->
_rm(path.join(target, p)) for p in fs.readdirSync(target)
_rm = (target) ->
if fs.statSync(target).isDirectory()
_emptyDirectory(target)
fs.rmdirSync(target)
else
fs.unlin... | var LocalStorage, _emptyDirectory, _rm, fs, path;
path = require('path');
fs = require('fs');
_emptyDirectory = function(target) {
var i, len, p, ref, results;
ref = fs.readdirSync(target);
results = [];
for (i = 0, len = ref.length; i < len; i++) {
p = ref[i];
results.push(_rm(path.join(target, p)))... | CoffeeScript | JavaScript | lmaccherone/node-localstorage | LocalStorage.coffee | MIT | 2ff017439b39c854c5c1d5a6af45f8ca7b3af8d9 | 460 | https://github.com/lmaccherone/node-localstorage/blob/2ff017439b39c854c5c1d5a6af45f8ca7b3af8d9/LocalStorage.coffee | 1 | 50 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.