forms.d.ts 1003 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import type { AnyNode } from 'domhandler';
  2. import type { Cheerio } from '../cheerio.js';
  3. /**
  4. * Encode a set of form elements as a string for submission.
  5. *
  6. * @category Forms
  7. * @example
  8. *
  9. * ```js
  10. * $('<form><input name="foo" value="bar" /></form>').serialize();
  11. * //=> 'foo=bar'
  12. * ```
  13. *
  14. * @returns The serialized form.
  15. * @see {@link https://api.jquery.com/serialize/}
  16. */
  17. export declare function serialize<T extends AnyNode>(this: Cheerio<T>): string;
  18. interface SerializedField {
  19. name: string;
  20. value: string;
  21. }
  22. /**
  23. * Encode a set of form elements as an array of names and values.
  24. *
  25. * @category Forms
  26. * @example
  27. *
  28. * ```js
  29. * $('<form><input name="foo" value="bar" /></form>').serializeArray();
  30. * //=> [ { name: 'foo', value: 'bar' } ]
  31. * ```
  32. *
  33. * @returns The serialized form.
  34. * @see {@link https://api.jquery.com/serializeArray/}
  35. */
  36. export declare function serializeArray<T extends AnyNode>(this: Cheerio<T>): SerializedField[];
  37. export {};
  38. //# sourceMappingURL=forms.d.ts.map