Skip to content

Instantly share code, notes, and snippets.

@bfricka
Last active December 10, 2015 17:08
Show Gist options
  • Save bfricka/4465490 to your computer and use it in GitHub Desktop.
Save bfricka/4465490 to your computer and use it in GitHub Desktop.

Revisions

  1. bfricka revised this gist Apr 1, 2013. 1 changed file with 17 additions and 17 deletions.
    34 changes: 17 additions & 17 deletions storageClass.coffee
    Original file line number Diff line number Diff line change
    @@ -2,20 +2,20 @@
    # I prefer this syntax for interacting with storage.

    class Stor
    # Constructor sets defaults for amplify
    # and optionally for expiration and key
    constructor: (key, exp) ->
    @key = if key? then key else undefined
    @exp = if exp? then exp else null
    @amp = amplify.store
    get: (key = @key) ->
    @amp(key)
    set: (val, key = @key, exp = @exp) ->
    @amp(key, val, exp)
    remove: (key = @key) ->
    @amp(key, null)
    empty: ->
    self = @
    storage = self.amp()
    _.each storage, (itm, key) ->
    self.amp(key, null)
    # Constructor sets defaults for amplify
    # and optionally for expiration and key
    constructor: (key, exp) ->
    @key = if key? then key else undefined
    @exp = if exp? then exp else null
    @amp = amplify.store
    get: (key = @key) ->
    @amp(key)
    set: (val, key = @key, exp = @exp) ->
    @amp(key, val, { expiration: exp })
    remove: (key = @key) ->
    @amp(key, null)
    empty: ->
    self = @
    storage = self.amp()
    _.each storage, (itm, key) ->
    self.amp(key, null)
  2. bfricka created this gist Jan 6, 2013.
    21 changes: 21 additions & 0 deletions storageClass.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    # This is really just an interaction wrapper for amplify
    # I prefer this syntax for interacting with storage.

    class Stor
    # Constructor sets defaults for amplify
    # and optionally for expiration and key
    constructor: (key, exp) ->
    @key = if key? then key else undefined
    @exp = if exp? then exp else null
    @amp = amplify.store
    get: (key = @key) ->
    @amp(key)
    set: (val, key = @key, exp = @exp) ->
    @amp(key, val, exp)
    remove: (key = @key) ->
    @amp(key, null)
    empty: ->
    self = @
    storage = self.amp()
    _.each storage, (itm, key) ->
    self.amp(key, null)