promisify.js
// In seneca 4, update seneca-entity to be async/await
In seneca 4, update seneca-entity to be async/await
In seneca 4 update seneca - entity to be async / await
function promisify_entity(ent, options) {
  if (null == ent || ent.__promisify$$ || (options && false === options.ent)) {
    return ent
  }
  ent.__promisify$$ = true
  ent.__make$$ = ent.make$
  ent.__load$$ = Util.promisify(ent.load$)
  ent.__save$$ = Util.promisify(ent.save$)
  ent.__list$$ = Util.promisify(ent.list$)
  ent.__remove$$ = Util.promisify(ent.remove$)
  ent.__close$$ = Util.promisify(ent.close$)
  ent.make$ = function () {
    var outent = ent.__make$$.apply(ent, arguments)
    return promisify_entity(outent)
  }
  ent.load$ = async function () {
    var outent = await ent.__load$$.apply(ent, arguments)
    return promisify_entity(outent)
  }
  ent.save$ = async function () {
    var outent = await ent.__save$$.apply(ent, arguments)
    return promisify_entity(outent)
  }
  ent.list$ = async function () {
    var outlist = await ent.__list$$.apply(ent, arguments)
    for (var i = 0; i < outlist.length; i++) {
      outlist[i] = promisify_entity(outlist[i])
    }
    return outlist
  }
  ent.remove$ = async function () {
    var outent = await ent.__remove$$.apply(ent, arguments)
    return promisify_entity(outent)
  }
  ent.close$ = async function () {
    var outent = await ent.__close$$.apply(ent, arguments)
    return promisify_entity(outent)
  }
  ent.native$ = Util.promisify(ent.native$)
  return ent
}
function promisify_entity ( ent , options ) { if ( null == ent || ent . __promisify$$ || ( options && false === options . ent ) ) { return ent } ent . __promisify$$ = true ent . __make$$ = ent . make$ ent . __load$$ = Util . promisify ( ent . load$ ) ent . __save$$ = Util . promisify ( ent . save$ ) ent . __list$$ = Util . promisify ( ent . list$ ) ent . __remove$$ = Util . promisify ( ent . remove$ ) ent . __close$$ = Util . promisify ( ent . close$ ) ent . make$ = function ( ) { var outent = ent . __make$$ . apply ( ent , arguments ) return promisify_entity ( outent ) } ent . load$ = async function ( ) { var outent = await ent . __load$$ . apply ( ent , arguments ) return promisify_entity ( outent ) } ent . save$ = async function ( ) { var outent = await ent . __save$$ . apply ( ent , arguments ) return promisify_entity ( outent ) } ent . list$ = async function ( ) { var outlist = await ent . __list$$ . apply ( ent , arguments ) for ( var i = 0 ; i < outlist . length ; i ++ ) { outlist [ i ] = promisify_entity ( outlist [ i ] ) } return outlist } ent . remove$ = async function ( ) { var outent = await ent . __remove$$ . apply ( ent , arguments ) return promisify_entity ( outent ) } ent . close$ = async function ( ) { var outent = await ent . __close$$ . apply ( ent , arguments ) return promisify_entity ( outent ) } ent . native$ = Util . promisify ( ent . native$ ) return ent }
In seneca 4, update seneca-entity to be async/await
In seneca 4 update seneca - entity to be async / await