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

@opentripplanner/core-utils

Package Overview
Dependencies
Maintainers
3
Versions
211
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentripplanner/core-utils - npm Package Compare versions

Comparing version 0.0.13 to 0.0.14-dev

lib/__tests__/query.js

9

lib/query.js

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

default:
if (!Number.isNaN(params[key])) query[key] = parseFloat(params[key]);else query[key] = params[key];
{
const maybeNumber = Number(params[key]); // If the param value is an empty string literal and is not a number,
// use string value. Else, use parsed number value.
// See https://github.com/opentripplanner/otp-ui/issues/50
query[key] = params[key] === "" || Number.isNaN(maybeNumber) ? params[key] : maybeNumber;
break;
}
}

@@ -206,0 +213,0 @@ });

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

exports.formatDuration = formatDuration;
exports.formatDurationWithSeconds = formatDurationWithSeconds;
exports.formatTime = formatTime;

@@ -64,2 +65,19 @@ exports.formatSecondsAfterMidnight = formatSecondsAfterMidnight;

/**
* Formats an elapsed time in seconds, minutes, hours duration for display in narrative
* TODO: internationalization
* @param {number} seconds duration in seconds
* @returns {string} formatted text representation
*/
function formatDurationWithSeconds(seconds) {
const dur = _moment.default.duration(seconds, "seconds");
let text = "";
if (dur.hours() > 0) text += `${dur.hours()} hr, `;
if (dur.minutes() > 0) text += `${dur.minutes()} min, `;
text += `${dur.seconds()} sec`;
return text;
}
/**
* Formats a time value for display in narrative

@@ -66,0 +84,0 @@ * TODO: internationalization/timezone

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

exports.createChainableTypeChecker = createChainableTypeChecker;
exports.userLocationType = exports.geocodedFeatureType = exports.configuredCompanyType = exports.configuredModesType = exports.configuredModeType = exports.queryType = exports.modeSelectorOptionsType = exports.modeOptionType = exports.latlngType = exports.stationType = exports.transitiveDataType = exports.transitIndexStopWithRoutes = exports.timeOptionsType = exports.locationType = exports.itineraryType = exports.fareType = exports.legType = exports.placeType = exports.stepsType = exports.encodedPolylineType = exports.configType = exports.vehicleRentalMapOverlaySymbolsType = exports.languageConfigType = exports.transitOperatorType = exports.leafletPathType = exports.companyType = void 0;
exports.userLocationType = exports.geocodedFeatureType = exports.configuredCompanyType = exports.configuredModesType = exports.configuredModeType = exports.queryType = exports.modeSelectorOptionsType = exports.modeOptionType = exports.latlngType = exports.stationType = exports.transitiveDataType = exports.transitIndexStopWithRoutes = exports.timeOptionsType = exports.locationType = exports.itineraryType = exports.fareType = exports.legType = exports.placeType = exports.stepsType = exports.encodedPolylineType = exports.configType = exports.vehicleRentalMapOverlaySymbolsType = exports.transitVehicleType = exports.languageConfigType = exports.transitOperatorType = exports.leafletPathType = exports.companyType = void 0;

@@ -74,5 +74,26 @@ var _propTypes = _interopRequireDefault(require("prop-types"));

});
/** describes the objects from the real-time vehicle service */
exports.languageConfigType = languageConfigType;
const transitVehicleType = _propTypes.default.shape({
routeShortName: _propTypes.default.string,
routeLongName: _propTypes.default.string,
routeType: _propTypes.default.string,
status: _propTypes.default.string,
reportDate: _propTypes.default.string,
seconds: _propTypes.default.number,
stopSequence: _propTypes.default.number,
stopId: _propTypes.default.string,
vehicleId: _propTypes.default.string,
tripId: _propTypes.default.string,
blockId: _propTypes.default.string,
lat: _propTypes.default.number,
lon: _propTypes.default.number,
heading: _propTypes.default.number
});
exports.transitVehicleType = transitVehicleType;
const vehicleRentalMapOverlaySymbolsType = _propTypes.default.arrayOf(_propTypes.default.shape({

@@ -79,0 +100,0 @@ dockStrokeColor: _propTypes.default.string,

4

package.json
{
"name": "@opentripplanner/core-utils",
"version": "0.0.13",
"version": "0.0.14-dev",
"description": "Core functionality that is shared among numerous UI components",

@@ -20,3 +20,3 @@ "main": "lib/index.js",

},
"gitHead": "f9d17b0c3f7e3ee90b4ef172e571943376fa8d8a"
"gitHead": "0af1b7cda60bd4252b219dcf893e01c2acb2ed5d"
}

@@ -212,5 +212,13 @@ import moment from "moment";

break;
default:
if (!Number.isNaN(params[key])) query[key] = parseFloat(params[key]);
else query[key] = params[key];
default: {
const maybeNumber = Number(params[key]);
// If the param value is an empty string literal and is not a number,
// use string value. Else, use parsed number value.
// See https://github.com/opentripplanner/otp-ui/issues/50
query[key] =
params[key] === "" || Number.isNaN(maybeNumber)
? params[key]
: maybeNumber;
break;
}
}

@@ -217,0 +225,0 @@ });

@@ -46,2 +46,17 @@ import moment from "moment";

/**
* Formats an elapsed time in seconds, minutes, hours duration for display in narrative
* TODO: internationalization
* @param {number} seconds duration in seconds
* @returns {string} formatted text representation
*/
export function formatDurationWithSeconds(seconds) {
const dur = moment.duration(seconds, "seconds");
let text = "";
if (dur.hours() > 0) text += `${dur.hours()} hr, `;
if (dur.minutes() > 0) text += `${dur.minutes()} min, `;
text += `${dur.seconds()} sec`;
return text;
}
/**
* Formats a time value for display in narrative

@@ -48,0 +63,0 @@ * TODO: internationalization/timezone

@@ -53,2 +53,23 @@ import PropTypes from "prop-types";

/** describes the objects from the real-time vehicle service */
export const transitVehicleType = PropTypes.shape({
routeShortName: PropTypes.string,
routeLongName: PropTypes.string,
routeType: PropTypes.string,
status: PropTypes.string,
reportDate: PropTypes.string,
seconds: PropTypes.number,
stopSequence: PropTypes.number,
stopId: PropTypes.string,
vehicleId: PropTypes.string,
tripId: PropTypes.string,
blockId: PropTypes.string,
lat: PropTypes.number,
lon: PropTypes.number,
heading: PropTypes.number
});
export const vehicleRentalMapOverlaySymbolsType = PropTypes.arrayOf(

@@ -55,0 +76,0 @@ PropTypes.shape({

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