function load(string) {
    return new Promise(function(resolve, reject) {
      if (!_.isString(string)) {
        throw new TypeError('load function only accepts a string');
      }

      try {
        JSON.parse(string);
      } catch (error) {
        // Do not change to JSON if it is YAML, and
        // just resolve it
        resolve(string);
        return;
      }

      YAML.load(string, function(error, json) {
        if (error) {
          return reject(error);
        }

        YAML.dump(json, function(error, yamlString) {
          if (error) {
            return reject(error);
          }

          resolve(yamlString);
        });
      });
    });
  }
/**
   * takes a JSON or YAML string, returns YAML string
   *
   * @param {string} string - the JSON or YAML raw string
   * @return {Promise} YAML string
   * @throws {TypeError} - resolves to a YAML string
  */
takes a JSON or YAML string, returns YAML string
@param {string} string - the JSON or YAML raw string
@return {Promise} YAML string
@throws {TypeError} - resolves to a YAML string
takes a JSON or YAML string returns YAML string @param { string } string - the JSON or YAML raw string @return { Promise } YAML string @throws { TypeError } - resolves to a YAML string
function load(string) {
    return new Promise(function(resolve, reject) {
      if (!_.isString(string)) {
        throw new TypeError('load function only accepts a string');
      }
      try {
        JSON.parse(string);
      } catch (error) {
        resolve(string);
        return;
      }
      YAML.load(string, function(error, json) {
        if (error) {
          return reject(error);
        }
        YAML.dump(json, function(error, yamlString) {
          if (error) {
            return reject(error);
          }
          resolve(yamlString);
        });
      });
    });
  }
function load ( string ) { return new Promise ( function ( resolve , reject ) { if ( ! _ . isString ( string ) ) { throw new TypeError ( 'load function only accepts a string' ) ; } try { JSON . parse ( string ) ; } catch ( error ) { resolve ( string ) ; return ; } YAML . load ( string , function ( error , json ) { if ( error ) { return reject ( error ) ; } YAML . dump ( json , function ( error , yamlString ) { if ( error ) { return reject ( error ) ; } resolve ( yamlString ) ; } ) ; } ) ; } ) ; }
takes a JSON or YAML string, returns YAML string
 @param {string} string - the JSON or YAML raw string
 @return {Promise} YAML string
 @throws {TypeError} - resolves to a YAML string
takes a JSON or YAML string returns YAML string @param { string } string - the JSON or YAML raw string @return { Promise } YAML string @throws { TypeError } - resolves to a YAML string
// Do not change to JSON if it is YAML, and // just resolve it