Skip to content

Commit

Permalink
remove getEntriesFromState
Browse files Browse the repository at this point in the history
  • Loading branch information
tsctx committed Dec 30, 2023
1 parent 7202f1c commit 9c0c22b
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions lib/fetch/formdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class FormData {

const state = this[kState]
return makeIterator(
() => getEntriesFromState(state),
() => state.map(pair => [pair.name, pair.value]),
'FormData',
'key+value'
)
Expand All @@ -202,7 +202,7 @@ class FormData {

const state = this[kState]
return makeIterator(
() => getEntriesFromState(state),
() => state.map(pair => [pair.name, pair.value]),
'FormData',
'key'
)
Expand All @@ -213,7 +213,7 @@ class FormData {

const state = this[kState]
return makeIterator(
() => getEntriesFromState(state),
() => state.map(pair => [pair.name, pair.value]),
'FormData',
'value'
)
Expand Down Expand Up @@ -300,18 +300,4 @@ function makeEntry (name, value, filename) {
return { name, value }
}

/**
* @param {unknown} formDataState
* @returns {[string, string | File][]}
*/
function getEntriesFromState (formDataState) {
const stateLength = formDataState.length
// Note: avoid `Array#push`
const result = new Array(stateLength)
for (let i = 0; i < stateLength; ++i) {
result[i] = [formDataState[i].name, formDataState[i].value]
}
return result
}

module.exports = { FormData }

0 comments on commit 9c0c22b

Please sign in to comment.