simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

lastDimToZeroBase.js (543B)


      1 "use strict";
      2 
      3 Object.defineProperty(exports, "__esModule", {
      4   value: true
      5 });
      6 exports.lastDimToZeroBase = lastDimToZeroBase;
      7 
      8 var _is = require("../../../utils/is.js");
      9 
     10 /**
     11  * Change last argument dim from one-based to zero-based.
     12  */
     13 function lastDimToZeroBase(args) {
     14   if (args.length === 2 && (0, _is.isCollection)(args[0])) {
     15     args = args.slice();
     16     var dim = args[1];
     17 
     18     if ((0, _is.isNumber)(dim)) {
     19       args[1] = dim - 1;
     20     } else if ((0, _is.isBigNumber)(dim)) {
     21       args[1] = dim.minus(1);
     22     }
     23   }
     24 
     25   return args;
     26 }