Registry / devops / fetch-normalize-data

fetch-normalize-data

JSON →
library1.22.7jsnpmunverified

A library (v1.22.7) to obtain a state of normalized data, providing fetch and reducer helpers. It offers functions to merge or delete normalized data into a Redux-like state, with configurable merging behavior. It is maintained by betagouv and has a moderate release cadence. Differentiators include simple normalization for nested data, optional isMergingArray/isMutatingDatum flags, and compatibility with redux-thunk/redux-saga/plain React Context via companion packages.

npm install fetch-normalize-data
INSTALL
IMPORT
SIG · FETCH-NORMALIZE-DA
F
fetch-normalize-data
devopsjavascriptv1.22.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

getNormalizedMergedState
import { getNormalizedMergedState } from 'fetch-normalize-data'
const getNormalizedMergedState = require('fetch-normalize-data').getNormalizedMergedState
Correct named import; avoid accessing as default export.
getNormalizedDeletedState
import { getNormalizedDeletedState } from 'fetch-normalize-data'
import getNormalizedDeletedState from 'fetch-normalize-data'
Named import, not default.
fetchData
import { fetchData } from 'fetch-normalize-data'
Named import for the fetch helper.

Shows how to merge normalized data with a nested normalizer configuration.

import { getNormalizedMergedState } from 'fetch-normalize-data' const state = { authors: [{ id: 0, name: 'John Marxou' }], books: [{ authorId: 0, id: 0, text: 'my foo' }] } const patch = { books: [ { author: { id: 1, name: 'Edmond Frostan' }, id: 1, text: 'you foo' } ] } const config = { normalizer: { books: { normalizer: { author: 'authors' }, stateKey: 'books' } } } const nextState = getNormalizedMergedState(state, patch, config) console.log(nextState)
Debug
Known issues

No known issues recorded.

Errors
Common errors & fixes
Cannot find module 'fetch-normalize-data'
Package not installed or incorrect path.
fix
Run npm install fetch-normalize-data or yarn add fetch-normalize-data
Uncaught TypeError: getNormalizedMergedState is not a function
Incorrect import (default vs named).
fix
Use import { getNormalizedMergedState } from 'fetch-normalize-data'
TypeError: Cannot read properties of undefined (reading 'normalizer')
Missing normalizer config in getNormalizedMergedState call.
fix
Provide a config object with a normalizer property.
Upgrade
Version history
1.22.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
fetch-normalize-data — npm install fetch-normalize-data · libregistry