@feelinglovelynow/get-form-entries
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

🕉 @feelinglovelynow/get-form-entries

💎 Install

pnpm add @feelinglovelynow/get-form-entries

🤓 Unit Tests

Statements

🙏 Description

  • Recieves Form Data and responds with an Object
  • Converts <input name="foo" value="bar" /> into { foo: 'bar' }
  • Converts <input name="image" /> into { image: File }
  • Converts <input name="images" multiple /> into { images: File[] }
  • If the input support multiple but only 1 file is uploaded => { image: File }
  • An array is used for a response value only if multiple files share the same form name (example below)

💚 Example

  • Implementation
import { getFormEntries } from '@feelinglovelynow/get-form-entries'

const fields = getFormEntries(formData)
  • formData
  FormData <entries>
    0: message → "Hello World!"
​​    1: images → File
​​​     <key>: "images"
​​​     <value>: File
​​    2: images → File
​​​     <key>: "images"
​​​     <value>: File
​​    3: images → File
​​​     <key>: "images"
​​     <value>: File
  • Response from getFormEntries(formData)
{
  message: 'Hello World!',
  images: [
    File {
      size: 93146,
      type: 'image/jpeg',
      name: 'glew-fl.jpg',
      lastModified: 1683003052322
    },
    File {
      size: 64056,
      type: 'image/jpeg',
      name: 'violet flame.jpg',
      lastModified: 1683003052322
    },
    File {
      size: 46030,
      type: 'image/jpeg',
      name: 'violet-flame.jpg',
      lastModified: 1683003052323
    }
  ]
}

🔥 Errors we may throw

  • getFormEntries()
if (!(data instanceof FormData)) throw { id: 'fln__get-form-entries__invalid-data', message: 'Please pass getFormEntries() FormData', _errorData: { data } }

🎁 All Our Packages

  1. @feelinglovelynow/datetime-local: NPMGithub
  2. @feelinglovelynow/dgraph: NPMGithub
  3. @feelinglovelynow/env-write: NPMGithub
  4. @feelinglovelynow/get-form-entries: NPMGithub
  5. @feelinglovelynow/get-relative-time: NPMGithub
  6. @feelinglovelynow/global-style: NPMGithub
  7. @feelinglovelynow/jwt: NPMGithub
  8. @feelinglovelynow/loop-backwards: NPMGithub
  9. @feelinglovelynow/slug: NPMGithub
  10. @feelinglovelynow/svelte-catch: NPMGithub
  11. @feelinglovelynow/svelte-kv: NPMGithub
  12. @feelinglovelynow/svelte-loading-anchor: NPMGithub
  13. @feelinglovelynow/svelte-modal: NPMGithub
  14. @feelinglovelynow/svelte-turnstile: NPMGithub
  15. @feelinglovelynow/toast: NPMGithub

Package Sidebar

Install

npm i @feelinglovelynow/get-form-entries

Weekly Downloads

4

Version

1.0.5

License

MIT

Unpacked Size

29.7 kB

Total Files

22

Last publish

Collaborators

  • feelinglovelynow