- FormData for the JavaScript target: https://developer.mozilla.org/en-US/docs/Web/API/FormData
Example: cmd: -r:off
import std/jsformdata let data: FormData = newFormData() data["key0"] = "value0".cstring data.add("key1".cstring, "value1".cstring) data.delete("key1") assert data.hasKey("key0") assert data["key0"] == "value0".cstring data.clear() assert data.len == 0
Procs
func `[]=`(self: FormData; name, value: cstring) {.importjs: "#.set(#, #)", ...raises: [], tags: [].}
- https://developer.mozilla.org/en-US/docs/Web/API/FormData/set Source Edit
func `[]`(self: FormData; name: cstring): cstring {.importjs: "#.get(#)", ...raises: [], tags: [].}
- https://developer.mozilla.org/en-US/docs/Web/API/FormData/get Source Edit
func add(self: FormData; name: cstring; value: SomeNumber | bool | cstring) {. importjs: "#.append(#, #)", ...raises: [], tags: [].}
- https://developer.mozilla.org/en-US/docs/Web/API/FormData/append Duplicate keys are allowed and order is preserved. Source Edit
func add(self: FormData; name: cstring; value: SomeNumber | bool | cstring; filename: cstring) {.importjs: "#.append(#, #, #)", ...raises: [], tags: [].}
- https://developer.mozilla.org/en-US/docs/Web/API/FormData/append Duplicate keys are allowed and order is preserved. Source Edit
func clear(self: FormData) {.importjs: "(() => { const frmdt = #; Array.from(frmdt.keys()).forEach((key) => frmdt.delete(key)) })()", ...raises: [], tags: [].}
- Convenience func to delete all items from FormData. Source Edit
func delete(self: FormData; name: cstring) {.importjs: "#.$1(#)", ...raises: [], tags: [].}
-
https://developer.mozilla.org/en-US/docs/Web/API/FormData/deleteWarning: Deletes all items with the same key name.Source Edit
func getAll(self: FormData; name: cstring): seq[cstring] {.importjs: "#.$1(#)", ...raises: [], tags: [].}
- https://developer.mozilla.org/en-US/docs/Web/API/FormData/getAll Source Edit
func hasKey(self: FormData; name: cstring): bool {.importjs: "#.has(#)", ...raises: [], tags: [].}
- https://developer.mozilla.org/en-US/docs/Web/API/FormData/has Source Edit
func keys(self: FormData): seq[cstring] {.importjs: "Array.from(#.$1())", ...raises: [], tags: [].}
- https://developer.mozilla.org/en-US/docs/Web/API/FormData/keys Source Edit
func len(self: FormData): int {.importjs: "Array.from(#.entries()).length", ...raises: [], tags: [].}
- Source Edit
func newFormData(): FormData {.importjs: "new FormData()", ...raises: [], tags: [].}
- Source Edit
func pairs(self: FormData): seq[tuple[key, val: cstring]] {. importjs: "Array.from(#.entries())", ...raises: [], tags: [].}
- https://developer.mozilla.org/en-US/docs/Web/API/FormData/entries Source Edit
func put(self: FormData; name, value, filename: cstring) {. importjs: "#.set(#, #, #)", ...raises: [], tags: [].}
- https://developer.mozilla.org/en-US/docs/Web/API/FormData/set Source Edit