1.0.5 ā€¢ Published 5 months ago

@feelinglovelynow/get-form-entries v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

šŸ•‰ @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: NPM ā‹… Github
  2. @feelinglovelynow/dgraph: NPM ā‹… Github
  3. @feelinglovelynow/env-write: NPM ā‹… Github
  4. @feelinglovelynow/get-form-entries: NPM ā‹… Github
  5. @feelinglovelynow/get-relative-time: NPM ā‹… Github
  6. @feelinglovelynow/global-style: NPM ā‹… Github
  7. @feelinglovelynow/jwt: NPM ā‹… Github
  8. @feelinglovelynow/loop-backwards: NPM ā‹… Github
  9. @feelinglovelynow/slug: NPM ā‹… Github
  10. @feelinglovelynow/svelte-catch: NPM ā‹… Github
  11. @feelinglovelynow/svelte-kv: NPM ā‹… Github
  12. @feelinglovelynow/svelte-loading-anchor: NPM ā‹… Github
  13. @feelinglovelynow/svelte-modal: NPM ā‹… Github
  14. @feelinglovelynow/svelte-turnstile: NPM ā‹… Github
  15. @feelinglovelynow/toast: NPM ā‹… Github
1.0.5

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

7 months ago