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 1.2.11 to 1.2.12

2

es/parsers/fieldsParser.js

@@ -30,3 +30,3 @@ /**

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

@@ -33,0 +33,0 @@ /**

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

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

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

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

@@ -38,0 +38,0 @@ /**

@@ -22,3 +22,4 @@ /**

return !!(
typeof object === 'object'
object
&& typeof object === 'object'
&& object.hasOwnProperty('sys')

@@ -25,0 +26,0 @@ && Object.keys(object).length === 1

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

/*! contentful-parsers v1.2.11 | (c) 2020 Ryan Hefner | MIT License | https://github.com/ryanhefner/contentful-parsers.git !*/
/*! contentful-parsers v1.2.12 | (c) 2020 Ryan Hefner | MIT License | https://github.com/ryanhefner/contentful-parsers.git !*/
(function (global, factory) {

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

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

@@ -40,0 +40,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="undefined"!=typeof globalThis?globalThis:e||self)["contentful-parsers"]={})}(this,function(e){"use strict";function R(e,l,o){function s(e){return"object"==typeof e&&e.hasOwnProperty("sys")&&1===Object.keys(e).length}function u(t,e,n,r){if(void 0===n&&(n={}),void 0===r&&(r=0),!t||"object"!=typeof t)return n;if(r>=l.include)return n;var i=Object.assign({},n);return Object.keys(t).forEach(function(e){i[e]=t[e]&&t[e].fields&&o.parseRefs?u(t[e].fields,t[e].sys,i[e],r+1):function t(e,n){return void 0===n&&(n=0),s(e)?null:Array.isArray(e)&&o.parseArrays?e.filter(function(e){return!s(e)}).map(function(e){return e&&"object"==typeof e&&e.fields?u(e.fields,e.sys,{},n+1):t(e,n+1)}):e}(t[e],r+1)}),e&&e.contentType&&e.contentType.sys&&e.contentType.sys.id&&(i.id=e.id,i.__typename=e.contentType.sys.id),e&&e.updatedAt&&(i.updatedAt=e.updatedAt),e&&e.createdAt&&(i.createdAt=e.createdAt),i}void 0===l&&(l={include:10}),void 0===o&&(o={parseArrays:!0,parseRefs:!0});var t=Object.assign({},e);return u(t.fields,t.sys)}var r=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e};function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function l(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?i(Object(n),!0).forEach(function(e){r(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function S(e){return e.substring(0,1).toUpperCase()+e.substring(1)}e.contentfulResolver=function(e,t){return t&&t.hasOwnProperty(e)?t[e]:null},e.fieldsParser=R,e.graphqlParser=function(e,t,n,E){var r,i;function k(e,t){return e&&(e.hasOwnProperty("__typename")&&e.__typename&&(e.__typename=S(e.__typename)),t&&t.sys?e.sys=l(l({},t.sys),{},{__typename:"Sys"}):t.id&&(e.sys={id:t.id,__typename:"Sys"}),e.id&&delete e.id,e.createdAt&&delete e.createdAt,e.updatedAt&&delete e.updatedAt),e}function C(i,l,o,s){var e;if(void 0===s&&(s=0),!i)return null;if(s>=E.include)return i;var u=Object.assign({},i.hasOwnProperty("sys")&&i.hasOwnProperty("fields")?R(i,E,{parseArrays:!1,parseRefs:!1}):i);Object.keys(u).forEach(function(n){var e=u[n];if(Array.isArray(e)){var t=!1;if(e.filter(function(e){return!!e}).forEach(function(e){(e.hasOwnProperty("sys")&&e.hasOwnProperty("fields")||e.hasOwnProperty("__typename"))&&(t=!0)}),t){var r=n+"Collection";u[r]=D(e,""+l+S(r),null==o?void 0:o[r],s+1),delete u[n]}else u[n]=e.map(function(e,t){return k(e,i&&i.fields&&i.fields[n][t])}).filter(function(e){return!!e})}else e&&"object"==typeof e&&(e.hasOwnProperty("__typename")||e.hasOwnProperty("sys")&&e.hasOwnProperty("fields"))?u[n]=C(e,l,null==o?void 0:o[n],s+1):u[n]=e});var t,n,r,a,d,f,c,y,p,v,O,b,h,m,_,j,g,P,w,A=k(u,i),T="Asset"===(null==A||null===(e=A.sys)||void 0===e?void 0:e.type)?(t=A,(w=Object.assign({},t)).__typename="Asset",w.url=null==w||null===(n=w.file)||void 0===n?void 0:n.url,w.contentType=null==w||null===(r=w.file)||void 0===r?void 0:r.contentType,w.size=null==w||null===(a=w.file)||void 0===a||null===(d=a.details)||void 0===d?void 0:d.size,w.width=(null==w||null===(f=w.file)||void 0===f||null===(c=f.details)||void 0===c||null===(y=c.image)||void 0===y?void 0:y.width)||(null==w||null===(p=w.file)||void 0===p||null===(v=p.details)||void 0===v||null===(O=v.video)||void 0===O?void 0:O.width),w.height=(null==w||null===(b=w.file)||void 0===b||null===(h=b.details)||void 0===h||null===(m=h.image)||void 0===m?void 0:m.height)||(null==w||null===(_=w.file)||void 0===_||null===(j=_.details)||void 0===j||null===(g=j.video)||void 0===g?void 0:g.height),w.fileName=null==w||null===(P=w.file)||void 0===P?void 0:P.fileName,delete w.file,w):A;return function r(e,i,l){if(!e||!l)return e;var o=Object.assign({},e||{});return Object.keys(l).forEach(function(e){if(!o.hasOwnProperty(e))if(e.endsWith("Collection")){var t=e.replace("Collection",""),n=o.hasOwnProperty(t)&&o[t];n?(o[e]=D(n,""+i+S(e),l[e]),delete o[t]):o[e]=D([],""+i+S(e),l[e])}else e.startsWith("...")&&o.__typename&&o.__typename===e.replace("...","")?Object.assign(o,r(o,i,l[e])):o[e]=null}),o}(T,T.__typename||l,o)}function D(e,t,n,r){return void 0===e&&(e=[]),void 0===r&&(r=0),{__typename:t,total:(e&&Array.isArray(e)?e:[]).length,items:(e&&Array.isArray(e)?e:[]).map(function(e){return C(e,t,null==n?void 0:n.items,r)}).filter(function(e){return!!e})}}return void 0===E&&(E={include:10}),null!=t&&t.items?((i={})[e]=D(t.items,S(e),null==n?void 0:n[e]),i):((r={})[e]=l({__typename:S(e)},C(t,S(e),null==n?void 0:n[e])),r)},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="undefined"!=typeof globalThis?globalThis:e||self)["contentful-parsers"]={})}(this,function(e){"use strict";function R(e,l,o){function s(e){return e&&"object"==typeof e&&e.hasOwnProperty("sys")&&1===Object.keys(e).length}function u(t,e,n,r){if(void 0===n&&(n={}),void 0===r&&(r=0),!t||"object"!=typeof t)return n;if(r>=l.include)return n;var i=Object.assign({},n);return Object.keys(t).forEach(function(e){i[e]=t[e]&&t[e].fields&&o.parseRefs?u(t[e].fields,t[e].sys,i[e],r+1):function t(e,n){return void 0===n&&(n=0),s(e)?null:Array.isArray(e)&&o.parseArrays?e.filter(function(e){return!s(e)}).map(function(e){return e&&"object"==typeof e&&e.fields?u(e.fields,e.sys,{},n+1):t(e,n+1)}):e}(t[e],r+1)}),e&&e.contentType&&e.contentType.sys&&e.contentType.sys.id&&(i.id=e.id,i.__typename=e.contentType.sys.id),e&&e.updatedAt&&(i.updatedAt=e.updatedAt),e&&e.createdAt&&(i.createdAt=e.createdAt),i}void 0===l&&(l={include:10}),void 0===o&&(o={parseArrays:!0,parseRefs:!0});var t=Object.assign({},e);return u(t.fields,t.sys)}var r=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e};function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function l(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?i(Object(n),!0).forEach(function(e){r(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function S(e){return e.substring(0,1).toUpperCase()+e.substring(1)}e.contentfulResolver=function(e,t){return t&&t.hasOwnProperty(e)?t[e]:null},e.fieldsParser=R,e.graphqlParser=function(e,t,n,E){var r,i;function k(e,t){return e&&(e.hasOwnProperty("__typename")&&e.__typename&&(e.__typename=S(e.__typename)),t&&t.sys?e.sys=l(l({},t.sys),{},{__typename:"Sys"}):t.id&&(e.sys={id:t.id,__typename:"Sys"}),e.id&&delete e.id,e.createdAt&&delete e.createdAt,e.updatedAt&&delete e.updatedAt),e}function C(i,l,o,s){var e;if(void 0===s&&(s=0),!i)return null;if(s>=E.include)return i;var u=Object.assign({},i.hasOwnProperty("sys")&&i.hasOwnProperty("fields")?R(i,E,{parseArrays:!1,parseRefs:!1}):i);Object.keys(u).forEach(function(n){var e=u[n];if(Array.isArray(e)){var t=!1;if(e.filter(function(e){return!!e}).forEach(function(e){(e.hasOwnProperty("sys")&&e.hasOwnProperty("fields")||e.hasOwnProperty("__typename"))&&(t=!0)}),t){var r=n+"Collection";u[r]=D(e,""+l+S(r),null==o?void 0:o[r],s+1),delete u[n]}else u[n]=e.map(function(e,t){return k(e,i&&i.fields&&i.fields[n][t])}).filter(function(e){return!!e})}else e&&"object"==typeof e&&(e.hasOwnProperty("__typename")||e.hasOwnProperty("sys")&&e.hasOwnProperty("fields"))?u[n]=C(e,l,null==o?void 0:o[n],s+1):u[n]=e});var t,n,r,a,d,f,c,y,p,v,O,b,h,m,_,j,g,P,w,A=k(u,i),T="Asset"===(null==A||null===(e=A.sys)||void 0===e?void 0:e.type)?(t=A,(w=Object.assign({},t)).__typename="Asset",w.url=null==w||null===(n=w.file)||void 0===n?void 0:n.url,w.contentType=null==w||null===(r=w.file)||void 0===r?void 0:r.contentType,w.size=null==w||null===(a=w.file)||void 0===a||null===(d=a.details)||void 0===d?void 0:d.size,w.width=(null==w||null===(f=w.file)||void 0===f||null===(c=f.details)||void 0===c||null===(y=c.image)||void 0===y?void 0:y.width)||(null==w||null===(p=w.file)||void 0===p||null===(v=p.details)||void 0===v||null===(O=v.video)||void 0===O?void 0:O.width),w.height=(null==w||null===(b=w.file)||void 0===b||null===(h=b.details)||void 0===h||null===(m=h.image)||void 0===m?void 0:m.height)||(null==w||null===(_=w.file)||void 0===_||null===(j=_.details)||void 0===j||null===(g=j.video)||void 0===g?void 0:g.height),w.fileName=null==w||null===(P=w.file)||void 0===P?void 0:P.fileName,delete w.file,w):A;return function r(e,i,l){if(!e||!l)return e;var o=Object.assign({},e||{});return Object.keys(l).forEach(function(e){if(!o.hasOwnProperty(e))if(e.endsWith("Collection")){var t=e.replace("Collection",""),n=o.hasOwnProperty(t)&&o[t];n?(o[e]=D(n,""+i+S(e),l[e]),delete o[t]):o[e]=D([],""+i+S(e),l[e])}else e.startsWith("...")&&o.__typename&&o.__typename===e.replace("...","")?Object.assign(o,r(o,i,l[e])):o[e]=null}),o}(T,T.__typename||l,o)}function D(e,t,n,r){return void 0===e&&(e=[]),void 0===r&&(r=0),{__typename:t,total:(e&&Array.isArray(e)?e:[]).length,items:(e&&Array.isArray(e)?e:[]).map(function(e){return C(e,t,null==n?void 0:n.items,r)}).filter(function(e){return!!e})}}return void 0===E&&(E={include:10}),null!=t&&t.items?((i={})[e]=D(t.items,S(e),null==n?void 0:n[e]),i):((r={})[e]=l({__typename:S(e)},C(t,S(e),null==n?void 0:n[e])),r)},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