src/modules/storage.js
function (key, value, callbackId) {
    const sender = this.sender
    if (!supportLocalStorage) {
      return callNotSupportFail(sender, callbackId)
    }
    if (!key || (!value && value !== 0)) {
      sender.performCallback(callbackId, {
        result: 'failed',
        data: INVALID_PARAM
      })
      return
    }
    try {
      localStorage.setItem(key, value)
      sender.performCallback(callbackId, {
        result: SUCCESS,
        data: UNDEFINED
      })
    }
    catch (e) {
      // accept any exception thrown during a storage attempt as a quota error
      callFail(sender, callbackId)
    }
  }
function (key, value, callbackId) {
    const sender = this.sender
    if (!supportLocalStorage) {
      return callNotSupportFail(sender, callbackId)
    }
    if (!key || (!value && value !== 0)) {
      sender.performCallback(callbackId, {
        result: 'failed',
        data: INVALID_PARAM
      })
      return
    }
    try {
      localStorage.setItem(key, value)
      sender.performCallback(callbackId, {
        result: SUCCESS,
        data: UNDEFINED
      })
    }
    catch (e) {
      // accept any exception thrown during a storage attempt as a quota error
      callFail(sender, callbackId)
    }
  }
function ( key , value , callbackId ) { const sender = this . sender if ( ! supportLocalStorage ) { return callNotSupportFail ( sender , callbackId ) } if ( ! key || ( ! value && value !== 0 ) ) { sender . performCallback ( callbackId , { result : 'failed' , data : INVALID_PARAM } ) return } try { localStorage . setItem ( key , value ) sender . performCallback ( callbackId , { result : SUCCESS , data : UNDEFINED } ) } catch ( e ) { // accept any exception thrown during a storage attempt as a quota error callFail ( sender , callbackId ) } }
When passed a key name and value, will add that key to the storage,
or update that key's value if it already exists.
@param {string} key
@param {string} value not null nor undifined，but 0 works.
@param {function} callbackId
When passed a key name and value will add that key to the storage or update that key s value if it already exists .