19router.use(express.json());
20
21/** RULES OF OUR API */
22router.use((req, res, next) => {23 // set the CORS policy
24 res.header("Access-Control-Allow-Origin", "*");
25 // set the CORS headers
27 return res.send({"x-span":ret.xspan, "y-span":ret.yspan});
28};
29
30const getTerminals = async (req: Request, res: Response, next: NextFunction) => {31 let primitive = req.query.mint;
32 let key = primitive as string;
33 let technology = ComponentAPI.getComponentWithMINT(key);
43 }
44
45 spec.forEach(item => {
46 ["min", "max", "units", "value"].forEach(key => {47 if (!Object.hasOwnProperty.call(item, key)) {
48 console.error("Missing key " + key + " from item", item);
49 return "danger";
1438 }
1439 }
1440 // Handle movement on document for handle and range drag.
1441 function eventMove(event, data) {1442 // Fix #498
1443 // Check value of .buttons in 'start' to work around a bug in IE10 mobile (data.buttonsProperty).
1444 // https://connect.microsoft.com/IE/feedback/details/927005/mobile-ie10-windows-phone-buttons-property-of-pointermove-event-always-zero
1325 e.calcPoint = e.points[options.ort];
1326 // Call the event handler with the event [ and additional data ].
1327 callback(e, data);
1328 return;1329 };
1330 var methods = [];
1331 // Bind a closure on the target for every event type.
Any code paths that do not have explicit returns will return undefined
.
It is recommended to replace any implicit dead-ends that return undefined
with a return null
statement.
As a convention, undefined
signals that an unexpected value has been produced as the
result of a logical error in the program.
A null
return, on the other hand, signals that the input to a function was incorrect,
or a value was 'not found'.
Having this distinction in code helps you figure out if something was caused because of a logical error, or malformed input to a function call.
function getUser(name) {
if (userExists(name)) {
return userDb.get(name);
}
// whoops! Implicit undefined return
}
function readFile(fileName) {
if (fs.existsSync(fileName)) {
return fs.readFileSync(fileName, 'utf-8');
}
return; // Implicit undefined return.
}
function getUser(name) {
if (userExists(name)) {
return userDb.get(name);
}
// `null` indicates there is no such user.
return null;
}
function readFile(fileName) {
if (fs.existsSync(fileName)) {
return fs.readFileSync(fileName, 'utf-8');
}
// `null` indicates there is no such file.
return null;
}