all files / couch/util/ computed.js

76.19% Statements 16/21
25% Branches 1/4
80% Functions 4/5
76.19% Lines 16/21
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45              251×       240×                     120×       28× 28× 28×            
import Ember from 'ember';
 
const {
  computed,
  getOwner,
  A
} = Ember;
 
export const array = () => {
  return computed(function() {
    return A();
  });
}
 
export const object = () => {
  return computed(function() {
    return Object.create(null);
  });
}
 
export const lookup = (name, fn) => {
  return computed(function() {
    let props = fn ? fn.call(this, name) : {};
    let owner = getOwner(this);
    return owner.factoryFor(name).create(props);
  }).readOnly();
}
 
export const fastboot = () => {
  return computed(function() {
    return getOwner(this).lookup('service:fastboot');
  }).readOnly();
};
 
export const isFastBoot = () => {
  return computed(function() {
    let fastboot = getOwner(this).lookup('service:fastboot');
    Eif(!fastboot) {
      return false;
    }
    return !!fastboot.get('isFastBoot');
  }).readOnly();
}