_getAssetRecord(assetPath, platform = null) {
    const filename = path.basename(assetPath);

    return (
      this._findRoot(
        this._roots,
        path.dirname(assetPath)
      )
      .then(dir => Promise.all([
        dir,
        readDir(dir),
      ]))
      .then(res => {
        const dir = res[0];
        const files = res[1];
        const assetData = getAssetDataFromName(filename);

        const map = this._buildAssetMap(dir, files, platform);

        let record;
        if (platform != null){
          record = map[getAssetKey(assetData.assetName, platform)] ||
                   map[assetData.assetName];
        } else {
          record = map[assetData.assetName];
        }

        if (!record) {
          throw new Error(
            `Asset not found: ${assetPath} for platform: ${platform}`
          );
        }

        return record;
      })
    );
  }
/**
   * Given a request for an image by path. That could contain a resolution
   * postfix, we need to find that image (or the closest one to it's resolution)
   * in one of the project roots:
   *
   * 1. We first parse the directory of the asset
   * 2. We check to find a matching directory in one of the project roots
   * 3. We then build a map of all assets and their scales in this directory
   * 4. Then try to pick platform-specific asset records
   * 5. Then pick the closest resolution (rounding up) to the requested one
   */
Given a request for an image by path. That could contain a resolution
postfix, we need to find that image (or the closest one to it's resolution)
in one of the project roots.

1. We first parse the directory of the asset
2. We check to find a matching directory in one of the project roots
3. We then build a map of all assets and their scales in this directory
4. Then try to pick platform-specific asset records
5. Then pick the closest resolution (rounding up) to the requested one
Given a request for an image by path . That could contain a resolution postfix we need to find that image ( or the closest one to it ' s resolution ) in one of the project roots . 1 . We first parse the directory of the asset 2 . We check to find a matching directory in one of the project roots 3 . We then build a map of all assets and their scales in this directory 4 . Then try to pick platform - specific asset records 5 . Then pick the closest resolution ( rounding up ) to the requested one
_getAssetRecord(assetPath, platform = null) {
    const filename = path.basename(assetPath);
    return (
      this._findRoot(
        this._roots,
        path.dirname(assetPath)
      )
      .then(dir => Promise.all([
        dir,
        readDir(dir),
      ]))
      .then(res => {
        const dir = res[0];
        const files = res[1];
        const assetData = getAssetDataFromName(filename);
        const map = this._buildAssetMap(dir, files, platform);
        let record;
        if (platform != null){
          record = map[getAssetKey(assetData.assetName, platform)] ||
                   map[assetData.assetName];
        } else {
          record = map[assetData.assetName];
        }
        if (!record) {
          throw new Error(
            `Asset not found: ${assetPath} for platform: ${platform}`
          );
        }
        return record;
      })
    );
  }
_getAssetRecord ( assetPath , platform = null ) { const filename = path . basename ( assetPath ) ; return ( this . _findRoot ( this . _roots , path . dirname ( assetPath ) ) . then ( dir => Promise . all ( [ dir , readDir ( dir ) , ] ) ) . then ( res => { const dir = res [ 0 ] ; const files = res [ 1 ] ; const assetData = getAssetDataFromName ( filename ) ; const map = this . _buildAssetMap ( dir , files , platform ) ; let record ; if ( platform != null ) { record = map [ getAssetKey ( assetData . assetName , platform ) ] || map [ assetData . assetName ] ; } else { record = map [ assetData . assetName ] ; } if ( ! record ) { throw new Error ( ` ${ assetPath } ${ platform } ` ) ; } return record ; } ) ) ; }
Given a request for an image by path.
Given a request for an image by path .