All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.src.identity.js Maven / Gradle / Ivy

The newest version!
import {linearish} from "./linear.js";
import number from "./number.js";

export default function identity(domain) {
  var unknown;

  function scale(x) {
    return x == null || isNaN(x = +x) ? unknown : x;
  }

  scale.invert = scale;

  scale.domain = scale.range = function(_) {
    return arguments.length ? (domain = Array.from(_, number), scale) : domain.slice();
  };

  scale.unknown = function(_) {
    return arguments.length ? (unknown = _, scale) : unknown;
  };

  scale.copy = function() {
    return identity(domain).unknown(unknown);
  };

  domain = arguments.length ? Array.from(domain, number) : [0, 1];

  return linearish(scale);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy