Sha256: 76dd0e66c21efdd80e91786a763fd460d1c0e8bd7ea5e30363bfd2018cc8a6e5

Contents?: true

Size: 882 Bytes

Versions: 2

Compression:

Stored size: 882 Bytes

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 as ScalarType[]) {
          q.push(encodeURIComponent(key + "[]") + "=" + encodeURIComponent("" + v));
        }
      } else {
        q.push(encodeURIComponent(key) + "=" + encodeURIComponent("" + value));
      }
    }
    return (q.length > 0 ? "?" + q.join("&") : "") + anchor;
  } else {
    return "";
  }
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ts_routes-0.2.0 lib/ts_routes/runtime.ts
ts_routes-0.1.0 lib/ts_routes/runtime.ts