MCPcopy Create free account
hub / github.com/microsoft/SandDance / Functions

Function Functions

docs/app/js/sanddance-app.js:144405–144489  ·  view source on GitHub ↗
(codegen1)

Source from the content-addressed store, hash-verified

144403 MAX_VALUE: "Number.MAX_VALUE"
144404};
144405function Functions(codegen1) {
144406 function fncall(name, args, cast, type) {
144407 let obj = codegen1(args[0]);
144408 if (cast) {
144409 obj = cast + "(" + obj + ")";
144410 if (cast.lastIndexOf("new ", 0) === 0) obj = "(" + obj + ")";
144411 }
144412 return obj + "." + name + (type < 0 ? "" : type === 0 ? "()" : "(" + args.slice(1).map(codegen1).join(",") + ")");
144413 }
144414 function fn(name, cast, type) {
144415 return (args)=>fncall(name, args, cast, type);
144416 }
144417 const DATE = "new Date", STRING = "String", REGEXP = "RegExp";
144418 return {
144419 // MATH functions
144420 isNaN: "Number.isNaN",
144421 isFinite: "Number.isFinite",
144422 abs: "Math.abs",
144423 acos: "Math.acos",
144424 asin: "Math.asin",
144425 atan: "Math.atan",
144426 atan2: "Math.atan2",
144427 ceil: "Math.ceil",
144428 cos: "Math.cos",
144429 exp: "Math.exp",
144430 floor: "Math.floor",
144431 log: "Math.log",
144432 max: "Math.max",
144433 min: "Math.min",
144434 pow: "Math.pow",
144435 random: "Math.random",
144436 round: "Math.round",
144437 sin: "Math.sin",
144438 sqrt: "Math.sqrt",
144439 tan: "Math.tan",
144440 clamp: function(args) {
144441 if (args.length < 3) (0, _vegaUtil.error)("Missing arguments to clamp function.");
144442 if (args.length > 3) (0, _vegaUtil.error)("Too many arguments to clamp function.");
144443 const a = args.map(codegen1);
144444 return "Math.max(" + a[1] + ", Math.min(" + a[2] + "," + a[0] + "))";
144445 },
144446 // DATE functions
144447 now: "Date.now",
144448 utc: "Date.UTC",
144449 datetime: DATE,
144450 date: fn("getDate", DATE, 0),
144451 day: fn("getDay", DATE, 0),
144452 year: fn("getFullYear", DATE, 0),
144453 month: fn("getMonth", DATE, 0),
144454 hours: fn("getHours", DATE, 0),
144455 minutes: fn("getMinutes", DATE, 0),
144456 seconds: fn("getSeconds", DATE, 0),
144457 milliseconds: fn("getMilliseconds", DATE, 0),
144458 time: fn("getTime", DATE, 0),
144459 timezoneoffset: fn("getTimezoneOffset", DATE, 0),
144460 utcdate: fn("getUTCDate", DATE, 0),
144461 utcday: fn("getUTCDay", DATE, 0),
144462 utcyear: fn("getUTCFullYear", DATE, 0),

Callers

nothing calls this directly

Calls 1

fnFunction · 0.70

Tested by

no test coverage detected