Sha256: 0ce488f9f3bc14c7ab0507d56d7ae84cd64caa37faab710a8966b7f47d91a915

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

/* This is generated by ts_routes-rails */

type ScalarType = string | number | boolean;

function $buildOptions(options: any, names: string[]): string {
  if (options) {
    let anchor = "";
    const q = [];
    for (const key of Object.keys(options)) {
      if (names.indexOf(key) !== -1) {
        // the key is already consumed
        continue;
      }

      const value: ScalarType = options[ key ];

      if (key === "anchor") {
        anchor = "#" + encodeURIComponent("" + value);
      } else if (Array.isArray(value)) {
        for (const v of value) {
          q.push(encodeURIComponent(key + "[]") + "=" + encodeURIComponent("" + v));
        }
      } else if(value !== null && value !== undefined) {
        q.push(encodeURIComponent(key) + "=" + encodeURIComponent("" + value));
      }
    }
    return (q.length > 0 ? "?" + q.join("&") : "") + anchor;
  } else {
    return "";
  }
}

function $isPresent(value: any): boolean {
  return value !== undefined && value !== null && ("" + value).length > 0;
}

function $hasPresentOwnProperty(options: any, key: string): boolean {
  return options && options.hasOwnProperty(key) && $isPresent(options[key]);
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ts_routes-0.4.0 lib/ts_routes/runtime.ts