Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

contentful-parsers

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contentful-parsers - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

24

es/parsers/fieldsParser.js

@@ -5,3 +5,3 @@ /**

*
* @param {Object} data
* @param {Object} data
* @return {Object}

@@ -18,3 +18,3 @@ */

function emptyModel(object) {
return typeof object === 'object' && object.sys && Object.keys(object).length === 1;
return !!(typeof object === 'object' && object.sys && Object.keys(object).length === 1);
}

@@ -34,4 +34,6 @@ /**

return null;
}
} // If value is an object and only contains a sys property, just return null
// since it’s either an empty or unpublished entry
if (emptyModel(value)) {

@@ -55,2 +57,3 @@ return null;

* @param {Object} fieldsObject - fields object to iterate over and flatten into objectRef
* @param {Object} sys - sys object associated with fieldsObject
* @param {Object} objectRef - Compiled object that flattens the field objects

@@ -70,14 +73,19 @@ * @return {Object}

var objectRefClone = Object.assign({}, objectRef); // Iterate over fieldObject keys, rercursively parsing child objects that
// contain fields, or parsing non-fields-child objects/entries
Object.keys(fieldsObject).forEach(function (key) {
objectRef[key] = fieldsObject[key].fields ? parseFields(fieldsObject[key].fields, objectRef[key]) : parseValue(fieldsObject[key]);
objectRefClone[key] = fieldsObject[key].fields ? parseFields(fieldsObject[key].fields, fieldsObject[key].sys, objectRefClone[key]) : parseValue(fieldsObject[key]);
}); // Apply typeNameKey/value to each fields object to define the Contentful model type
if (sys && sys.contentType && sys.contentType.sys && sys.contentType.sys.id) {
var contentTypeId = sys && sys.contentType && sys.contentType.sys && sys.contentType.sys.id;
if (!!contentTypeId) {
/* eslint-disable */
objectRef['id'] = sys.id;
objectRef['__typename'] = sys.contentType.sys.id;
objectRefClone['id'] = sys.id;
objectRefClone['__typename'] = sys.contentType.sys.id;
/* eslint-enable */
}
return objectRef;
return objectRefClone;
}

@@ -84,0 +92,0 @@

{
"name": "contentful-parsers",
"version": "0.1.2",
"version": "0.1.3",
"description": "Library of useful parsers to use when working with Contentful API responses.",

@@ -41,5 +41,3 @@ "repository": "ryanhefner/contentful-parsers.git",

"dependencies": {
"@babel/runtime": "^7.4.2",
"invariant": "^2.2.4",
"warning": "^4.0.3"
"@babel/runtime": "^7.4.2"
},

@@ -46,0 +44,0 @@ "devDependencies": {

@@ -10,3 +10,3 @@ "use strict";

*
* @param {Object} data
* @param {Object} data
* @return {Object}

@@ -23,3 +23,3 @@ */

function emptyModel(object) {
return typeof object === 'object' && object.sys && Object.keys(object).length === 1;
return !!(typeof object === 'object' && object.sys && Object.keys(object).length === 1);
}

@@ -39,4 +39,6 @@ /**

return null;
}
} // If value is an object and only contains a sys property, just return null
// since it’s either an empty or unpublished entry
if (emptyModel(value)) {

@@ -60,2 +62,3 @@ return null;

* @param {Object} fieldsObject - fields object to iterate over and flatten into objectRef
* @param {Object} sys - sys object associated with fieldsObject
* @param {Object} objectRef - Compiled object that flattens the field objects

@@ -75,14 +78,19 @@ * @return {Object}

var objectRefClone = Object.assign({}, objectRef); // Iterate over fieldObject keys, rercursively parsing child objects that
// contain fields, or parsing non-fields-child objects/entries
Object.keys(fieldsObject).forEach(function (key) {
objectRef[key] = fieldsObject[key].fields ? parseFields(fieldsObject[key].fields, objectRef[key]) : parseValue(fieldsObject[key]);
objectRefClone[key] = fieldsObject[key].fields ? parseFields(fieldsObject[key].fields, fieldsObject[key].sys, objectRefClone[key]) : parseValue(fieldsObject[key]);
}); // Apply typeNameKey/value to each fields object to define the Contentful model type
if (sys && sys.contentType && sys.contentType.sys && sys.contentType.sys.id) {
var contentTypeId = sys && sys.contentType && sys.contentType.sys && sys.contentType.sys.id;
if (!!contentTypeId) {
/* eslint-disable */
objectRef['id'] = sys.id;
objectRef['__typename'] = sys.contentType.sys.id;
objectRefClone['id'] = sys.id;
objectRefClone['__typename'] = sys.contentType.sys.id;
/* eslint-enable */
}
return objectRef;
return objectRefClone;
}

@@ -89,0 +97,0 @@

@@ -5,3 +5,3 @@ /**

*
* @param {Object} data
* @param {Object} data
* @return {Object}

@@ -18,3 +18,3 @@ */

function emptyModel(object) {
return (
return !!(
typeof object === 'object'

@@ -39,2 +39,4 @@ && object.sys

// If value is an object and only contains a sys property, just return null
// since it’s either an empty or unpublished entry
if (emptyModel(value)) {

@@ -62,2 +64,3 @@ return null;

* @param {Object} fieldsObject - fields object to iterate over and flatten into objectRef
* @param {Object} sys - sys object associated with fieldsObject
* @param {Object} objectRef - Compiled object that flattens the field objects

@@ -71,5 +74,9 @@ * @return {Object}

const objectRefClone = Object.assign({}, objectRef);
// Iterate over fieldObject keys, rercursively parsing child objects that
// contain fields, or parsing non-fields-child objects/entries
Object.keys(fieldsObject).forEach((key) => {
objectRef[key] = fieldsObject[key].fields
? parseFields(fieldsObject[key].fields, objectRef[key])
objectRefClone[key] = fieldsObject[key].fields
? parseFields(fieldsObject[key].fields, fieldsObject[key].sys, objectRefClone[key])
: parseValue(fieldsObject[key]);

@@ -79,10 +86,15 @@ });

// Apply typeNameKey/value to each fields object to define the Contentful model type
if (sys && sys.contentType && sys.contentType.sys && sys.contentType.sys.id) {
const contentTypeId = sys
&& sys.contentType
&& sys.contentType.sys
&& sys.contentType.sys.id;
if (!!contentTypeId) {
/* eslint-disable */
objectRef['id'] = sys.id;
objectRef['__typename'] = sys.contentType.sys.id;
objectRefClone['id'] = sys.id;
objectRefClone['__typename'] = sys.contentType.sys.id;
/* eslint-enable */
}
return objectRef;
return objectRefClone;
}

@@ -89,0 +101,0 @@

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

/*! contentful-parsers v0.1.2 | (c) 2019 Ryan Hefner | MIT License | https://github.com/ryanhefner/contentful-parsers.git !*/
/*! contentful-parsers v0.1.3 | (c) 2019 Ryan Hefner | MIT License | https://github.com/ryanhefner/contentful-parsers.git !*/
(function (global, factory) {

@@ -12,3 +12,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

*
* @param {Object} data
* @param {Object} data
* @return {Object}

@@ -25,3 +25,3 @@ */

function emptyModel(object) {
return typeof object === 'object' && object.sys && Object.keys(object).length === 1;
return !!(typeof object === 'object' && object.sys && Object.keys(object).length === 1);
}

@@ -41,4 +41,6 @@ /**

return null;
}
} // If value is an object and only contains a sys property, just return null
// since it’s either an empty or unpublished entry
if (emptyModel(value)) {

@@ -62,2 +64,3 @@ return null;

* @param {Object} fieldsObject - fields object to iterate over and flatten into objectRef
* @param {Object} sys - sys object associated with fieldsObject
* @param {Object} objectRef - Compiled object that flattens the field objects

@@ -77,14 +80,19 @@ * @return {Object}

var objectRefClone = Object.assign({}, objectRef); // Iterate over fieldObject keys, rercursively parsing child objects that
// contain fields, or parsing non-fields-child objects/entries
Object.keys(fieldsObject).forEach(function (key) {
objectRef[key] = fieldsObject[key].fields ? parseFields(fieldsObject[key].fields, objectRef[key]) : parseValue(fieldsObject[key]);
objectRefClone[key] = fieldsObject[key].fields ? parseFields(fieldsObject[key].fields, fieldsObject[key].sys, objectRefClone[key]) : parseValue(fieldsObject[key]);
}); // Apply typeNameKey/value to each fields object to define the Contentful model type
if (sys && sys.contentType && sys.contentType.sys && sys.contentType.sys.id) {
var contentTypeId = sys && sys.contentType && sys.contentType.sys && sys.contentType.sys.id;
if (!!contentTypeId) {
/* eslint-disable */
objectRef['id'] = sys.id;
objectRef['__typename'] = sys.contentType.sys.id;
objectRefClone['id'] = sys.id;
objectRefClone['__typename'] = sys.contentType.sys.id;
/* eslint-enable */
}
return objectRef;
return objectRefClone;
}

@@ -91,0 +99,0 @@

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self)["contentful-parsers"]={})}(this,function(e){"use strict";e.fieldsParser=function(e){function o(e){return"object"==typeof e&&e.sys&&1===Object.keys(e).length}function s(t,e,n){return void 0===n&&(n={}),t&&"object"==typeof t&&(Object.keys(t).forEach(function(e){n[e]=t[e].fields?s(t[e].fields,n[e]):function t(e){return e?o(e)?null:Array.isArray(e)?e.filter(function(e){return!o(e)}).map(function(e){return e&&"object"==typeof e&&e.fields?s(e.fields,e.sys):t(e)}):e:null}(t[e])}),e&&e.contentType&&e.contentType.sys&&e.contentType.sys.id&&(n.id=e.id,n.__typename=e.contentType.sys.id)),n}return s(e.fields,e.sys)},Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self)["contentful-parsers"]={})}(this,function(e){"use strict";e.fieldsParser=function(e){function o(e){return!("object"!=typeof e||!e.sys||1!==Object.keys(e).length)}function f(t,e,n){if(void 0===n&&(n={}),!t||"object"!=typeof t)return n;var s=Object.assign({},n);return Object.keys(t).forEach(function(e){s[e]=t[e].fields?f(t[e].fields,t[e].sys,s[e]):function t(e){return e?o(e)?null:Array.isArray(e)?e.filter(function(e){return!o(e)}).map(function(e){return e&&"object"==typeof e&&e.fields?f(e.fields,e.sys):t(e)}):e:null}(t[e])}),e&&e.contentType&&e.contentType.sys&&e.contentType.sys.id&&(s.id=e.id,s.__typename=e.contentType.sys.id),s}return f(e.fields,e.sys)},Object.defineProperty(e,"__esModule",{value:!0})});
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