PHP 7.4.33
Preview: URLSearchParams.js Size: 1.79 KB
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/react-native/Libraries/Blob/URLSearchParams.js
/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @format
 * @flow
 */

// Small subset from whatwg-url: https://github.com/jsdom/whatwg-url/tree/master/src
// The reference code bloat comes from Unicode issues with URLs, so those won't work here.
export class URLSearchParams {
  _searchParams: Array<Array<string>> = [];

  constructor(params: any) {
    if (typeof params === 'object') {
      Object.keys(params).forEach(key => this.append(key, params[key]));
    }
  }

  append(key: string, value: string): void {
    this._searchParams.push([key, value]);
  }

  delete(name: string): void {
    throw new Error('URLSearchParams.delete is not implemented');
  }

  get(name: string): void {
    throw new Error('URLSearchParams.get is not implemented');
  }

  getAll(name: string): void {
    throw new Error('URLSearchParams.getAll is not implemented');
  }

  has(name: string): void {
    throw new Error('URLSearchParams.has is not implemented');
  }

  set(name: string, value: string): void {
    throw new Error('URLSearchParams.set is not implemented');
  }

  sort(): void {
    throw new Error('URLSearchParams.sort is not implemented');
  }

  // $FlowFixMe[unsupported-syntax]
  // $FlowFixMe[missing-local-annot]
  [Symbol.iterator]() {
    return this._searchParams[Symbol.iterator]();
  }

  toString(): string {
    if (this._searchParams.length === 0) {
      return '';
    }
    const last = this._searchParams.length - 1;
    return this._searchParams.reduce((acc, curr, index) => {
      return (
        acc +
        encodeURIComponent(curr[0]) +
        '=' +
        encodeURIComponent(curr[1]) +
        (index === last ? '' : '&')
      );
    }, '');
  }
}

Directory Contents

Dirs: 1 × Files: 20
Name Size Perms Modified Actions
__mocks__ DIR
- drwxr-xr-x 2025-03-28 11:04:42
Edit Download
4.47 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
4.92 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
784 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
535 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
1.07 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
3.99 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
408 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
432 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
594 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
1.96 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
1001 B lrwxr-xr-x 2025-03-28 11:04:41
Edit Download
9.87 KB lrwxr-xr-x 2025-03-28 11:04:43
Edit Download
938 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
901 B lrw-r--r-- 2025-03-28 11:04:43
Edit Download
292 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
2.83 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
2.69 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
4.46 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
1.79 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
606 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).