MCPcopy Create free account
hub / github.com/BrasilAPI/BrasilAPI / parseDimensions

Function parseDimensions

services/isbn/googleBooks.js:14–24  ·  view source on GitHub ↗

* Parse the Google Books dimensions format into a proper object. * * @param {string} dimensions The Google Books dimensions. * @returns A object with width and height if valid.

(dimensions)

Source from the content-addressed store, hash-verified

12 * @returns A object with width and height if valid.
13 */
14function parseDimensions(dimensions) {
15 if (!dimensions) {
16 return null;
17 }
18
19 return {
20 width: parseFloat(dimensions.width.replace(/\s(cm|in)+$/, '')),
21 height: parseFloat(dimensions.height.replace(/\s(cm|in)+$/, '')),
22 unit: dimensions.width.includes('cm') ? 'CENTIMETER' : 'INCH',
23 };
24}
25
26/**
27 * Parse the Google Books price format into a proper object.

Callers 1

searchInGoogleBooksFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected