Socket
Socket
Sign inDemoInstall

redux-object

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-object - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

CHANGELOG.md

2

dist/bundle.js

@@ -1,1 +0,1 @@

module.exports=function(e){function t(o){if(r[o])return r[o].exports;var i=r[o]={exports:{},id:o,loaded:!1};return e[o].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){e.exports=r(1)},function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function i(e,t,r){var o=r.toString(),n={},u=e[t][o];return u?(u.id&&(n.id=u.id),(0,a.default)(u.attributes).forEach(function(e){n[e]=u.attributes[e]}),u.relationships&&(0,a.default)(u.relationships).forEach(function(t){Object.defineProperty(n,t,{get:function(){var r="__"+t;if(n[r])return n[r];var o=u.relationships[t];if("undefined"!=typeof o.data)(0,l.default)(o.data)?n[r]=o.data.map(function(t){return i(e,t.type,t.id)}):(0,p.default)(o.data)?n[r]=null:n[r]=i(e,o.data.type,o.data.id);else{if(o.links)throw new Error("Remote lazy loading is not implemented for redux-object. Please refer https://github.com/yury-dymov/json-api-normalizer/issues/2");n[r]=[]}return n[r]}})}),(0,d.default)(n,"id")||(n.id=o),n):null}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var n=r(5),a=o(n),u=r(2),d=o(u),s=r(3),l=o(s),f=r(4),p=o(f)},function(e,t){e.exports=require("lodash/has")},function(e,t){e.exports=require("lodash/isArray")},function(e,t){e.exports=require("lodash/isNull")},function(e,t){e.exports=require("lodash/keys")}]);
module.exports=function(e){function r(n){if(t[n])return t[n].exports;var i=t[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}var t={};return r.m=e,r.c=t,r.p="",r(0)}([function(e,r,t){e.exports=t(1)},function(e,r,t){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,r,t,n){var i=n.ignoreLinks,u=r.relationships[t];if("undefined"!=typeof u.data)return(0,c.default)(u.data)?u.data.map(function(r){return o(e,r.type,r.id,n)}):(0,y.default)(u.data)?null:o(e,u.data.type,u.data.id,n);if(!i&&u.links)throw new Error("\n Remote lazy loading is not implemented for redux-object. \n Please refer https://github.com/yury-dymov/json-api-normalizer/issues/2.\n If you would like to disable this error, provide 'ingoreLinks: true' option to the build function like below:\n build(reducer, type, id, { ignoreLinks: true })\n ");return[]}function o(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},u={eager:!1,ignoreLinks:!1},d=(0,f.default)({},u,n),s=d.eager;if(!e[r])return null;if(null===t||Array.isArray(t)){var p=t||(0,a.default)(e[r]);return p.map(function(t){return o(e,r,t,d)})}var c=t.toString(),h={},y=e[r][c];return y?(y.id&&(h.id=y.id),(0,a.default)(y.attributes).forEach(function(e){h[e]=y.attributes[e]}),y.relationships&&(0,a.default)(y.relationships).forEach(function(r){s?h[r]=i(e,y,r,d):Object.defineProperty(h,r,{get:function(){var t="__"+r;return h[t]?h[t]:(h[t]=i(e,y,r,d),h[t])}})}),(0,l.default)(h,"id")||(h.id=c),h):null}Object.defineProperty(r,"__esModule",{value:!0}),r.default=o;var u=t(6),a=n(u),d=t(3),l=n(d),s=t(2),f=n(s),p=t(4),c=n(p),h=t(5),y=n(h)},function(e,r){e.exports=require("lodash/assign")},function(e,r){e.exports=require("lodash/has")},function(e,r){e.exports=require("lodash/isArray")},function(e,r){e.exports=require("lodash/isNull")},function(e,r){e.exports=require("lodash/keys")}]);
{
"name": "redux-object",
"version": "0.4.0",
"version": "0.4.1",
"description": "Builds complex JS object from normalized redux store. Best works with json-api-normalizer",
"main": "dist/bundle.js",
"scripts": {
"build": "NODE_ENV=production webpack -p",
"build": "cross-env NODE_ENV=production webpack -p",
"clean": "rimraf dist coverage lib",
"coverage": "NODE_ENV=production webpack && istanbul cover _mocha -- --compilers js:babel-core/register && NODE_ENV=production webpack -p",
"coverage": "cross-env NODE_ENV=production webpack && istanbul cover _mocha -- --compilers js:babel-core/register && NODE_ENV=production webpack -p",
"lint": "eslint src --ext .js",

@@ -36,2 +36,3 @@ "test": "mocha --compilers js:babel-core/register"

"chai": "^3.5.0",
"cross-env": "^4.0.0",
"eslint": "^3.12.2",

@@ -38,0 +39,0 @@ "eslint-config-airbnb": "^13.0.0",

@@ -15,4 +15,12 @@ # redux-object

# API
Library provides `build` function, which takes 3 parameters: state part, object type and ID.
Library provides `build` function, which takes 4 parameters: redux state part, object type, ID or an array of IDs or null, and options.
If ID is provided in a form of array, multiple objects are fetched. If ID is null, all objects of selected type are fetched.
| Option | Default | Description |
|:--------|:---------------:|:-------------|
| eager | false | Controls lazy loading for the child relationship objects. By default, lazy loading is enabled. |
| ignoreLinks | false | redux-object doesn't support remote objects. This option suppresses the exception thrown in case user accesses a property, which is not loaded to redux store yet. |
```JavaScript

@@ -36,7 +44,14 @@ import build from 'redux-object';

},
liker: {
id: "1,2,3",
type: "user"
},
comments: {}
liker: [{
id: "1",
type: "user"
}, {
id: "2",
type: "user",
}, {
id: "3",
type: "user"
}
],
comments: []
}

@@ -90,7 +105,12 @@ }

console.log(post.liker[0]); // -> { id: 1, name: "Alice" }
// Other examples
const post = build(state.data, 'post', '2620', { eager: true });
const post = build(state.data, 'post', '2620', { eager: false, ignoreLinks: true });
```
Child objects are lazy loaded.
Child objects are lazy loaded unless eager option is explicitly provided.
# License
MIT (c) Yury Dymov
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc