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

contentful-resolve-response

Package Overview
Dependencies
Maintainers
5
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contentful-resolve-response - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

6

CHANGELOG.md
# Change Log
All notable changes to this project will be documented in this file.
## v1.1.4 - 2018-02-21
### Bug Fixes
* **array-fields:** proper unresolved removal while iterating array ([#19](https://github.com/contentful/contentful-resolve-response/pull/19)) ([39bf40d7](https://github.com/contentful/contentful-resolve-response/commit/39bf40d7e38f5e3a0bce96491448c333d128b850))
## v1.1.3 - 2018-02-12

@@ -5,0 +11,0 @@

35

dist/cjs/index.js

@@ -15,2 +15,4 @@ 'use strict';

var UNRESOLVED_LINK = {}; // unique object to avoid polyfill bloat using Symbol()
/**

@@ -38,3 +40,3 @@ * isLink Function

}
return undefined;
return UNRESOLVED_LINK;
};

@@ -64,16 +66,19 @@

/**
* cleanUpLink Function
* cleanUpLinks Function
* - Removes unresolvable links from Arrays and Objects
*
* @param {Object[]|Object} input
* @param {number|string} key
*/
var cleanUpLink = function cleanUpLink(input, key) {
if (input[key] === undefined) {
if (Array.isArray(input)) {
input.splice(key, 1);
} else {
var cleanUpLinks = function cleanUpLinks(input) {
if (Array.isArray(input)) {
return input.filter(function (val) {
return val !== UNRESOLVED_LINK;
});
}
for (var key in input) {
if (input[key] === UNRESOLVED_LINK) {
delete input[key];
}
}
return input;
};

@@ -88,3 +93,3 @@

*/
var walkMutate = function walkMutate(input, predicate, mutator) {
var walkMutate = function walkMutate(input, predicate, mutator, removeUnresolved) {
if (predicate(input)) {

@@ -97,6 +102,8 @@ return mutator(input);

if (input.hasOwnProperty(key)) {
input[key] = walkMutate(input[key], predicate, mutator);
cleanUpLink(input, key);
input[key] = walkMutate(input[key], predicate, mutator, removeUnresolved);
}
}
if (removeUnresolved) {
input = cleanUpLinks(input);
}
}

@@ -108,4 +115,4 @@ return input;

var resolvedLink = getLink(allEntries, link);
if (resolvedLink === undefined) {
return removeUnresolved ? undefined : link;
if (resolvedLink === UNRESOLVED_LINK) {
return removeUnresolved ? resolvedLink : link;
}

@@ -156,3 +163,3 @@ return resolvedLink;

return normalizeLink(allEntries, link, options.removeUnresolved);
}));
}, options.removeUnresolved));
});

@@ -159,0 +166,0 @@

@@ -7,2 +7,4 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

var UNRESOLVED_LINK = {}; // unique object to avoid polyfill bloat using Symbol()
/**

@@ -30,3 +32,3 @@ * isLink Function

}
return undefined;
return UNRESOLVED_LINK;
};

@@ -56,16 +58,19 @@

/**
* cleanUpLink Function
* cleanUpLinks Function
* - Removes unresolvable links from Arrays and Objects
*
* @param {Object[]|Object} input
* @param {number|string} key
*/
var cleanUpLink = function cleanUpLink(input, key) {
if (input[key] === undefined) {
if (Array.isArray(input)) {
input.splice(key, 1);
} else {
var cleanUpLinks = function cleanUpLinks(input) {
if (Array.isArray(input)) {
return input.filter(function (val) {
return val !== UNRESOLVED_LINK;
});
}
for (var key in input) {
if (input[key] === UNRESOLVED_LINK) {
delete input[key];
}
}
return input;
};

@@ -80,3 +85,3 @@

*/
var walkMutate = function walkMutate(input, predicate, mutator) {
var walkMutate = function walkMutate(input, predicate, mutator, removeUnresolved) {
if (predicate(input)) {

@@ -89,6 +94,8 @@ return mutator(input);

if (input.hasOwnProperty(key)) {
input[key] = walkMutate(input[key], predicate, mutator);
cleanUpLink(input, key);
input[key] = walkMutate(input[key], predicate, mutator, removeUnresolved);
}
}
if (removeUnresolved) {
input = cleanUpLinks(input);
}
}

@@ -100,4 +107,4 @@ return input;

var resolvedLink = getLink(allEntries, link);
if (resolvedLink === undefined) {
return removeUnresolved ? undefined : link;
if (resolvedLink === UNRESOLVED_LINK) {
return removeUnresolved ? resolvedLink : link;
}

@@ -148,3 +155,3 @@ return resolvedLink;

return normalizeLink(allEntries, link, options.removeUnresolved);
}));
}, options.removeUnresolved));
});

@@ -151,0 +158,0 @@

2

package.json
{
"name": "contentful-resolve-response",
"version": "1.1.3",
"version": "1.1.4",
"description": "",

@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js",

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