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

@anselan/maprange

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@anselan/maprange - npm Package Compare versions

Comparing version 0.8.0 to 0.9.0

2

dist/index.js

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

exports.remapArray = remapArray;
const remapCoords = (inputCoords, inputDimensions, targetDimensions, clamp = false, shouldRound = true) => {
const remapCoords = (inputCoords, inputDimensions, targetDimensions, clamp = false, shouldRound = false) => {
if (inputCoords.length !== targetDimensions.length || inputCoords.length !== inputDimensions.length) {

@@ -40,0 +40,0 @@ throw Error('coordinates must have same number of dimensions as input and target dimensions');

@@ -148,2 +148,12 @@ "use strict";

});
test('cm to pixels', () => {
const [x, y] = [100, 200];
const pixels = _1.remapCoords([x, y], [400, 400], [1920, 1080]);
expect(pixels).toEqual([480, 540]);
});
test('pixels, normalised', () => {
const [x, y] = [100, 200];
const norm = _1.remapCoords([x, y], [1000, 1000], [1, 1], false, false);
expect(norm).toEqual([0.1, 0.2]);
});
test('normalised to realworld dimensions, 3D', () => {

@@ -150,0 +160,0 @@ const [x, y, z] = [0.25, 0.5, 2.5];

{
"name": "@anselan/maprange",
"version": "0.8.0",
"version": "0.9.0",
"description": "Map values from one range to another",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -180,2 +180,14 @@ import { remap, remapArray, remapCoords } from '.'

test('cm to pixels', () => {
const [x,y] = [100,200];
const pixels = remapCoords([x,y], [400,400], [1920,1080]);
expect(pixels).toEqual([480, 540]);
})
test ('pixels, normalised', () => {
const [x,y] = [100, 200];
const norm = remapCoords([x,y], [1000,1000], [1,1], false, false);
expect(norm).toEqual([0.1, 0.2])
})
test('normalised to realworld dimensions, 3D', () => {

@@ -182,0 +194,0 @@ const [x,y,z] = [0.25, 0.5, 2.5];

@@ -35,3 +35,3 @@ const checkValidRanges = (arrays: number[][]): boolean =>

const remapCoords = (inputCoords: number[], inputDimensions: number[], targetDimensions: number[], clamp=false, shouldRound = true): number[] => {
const remapCoords = (inputCoords: number[], inputDimensions: number[], targetDimensions: number[], clamp=false, shouldRound = false): number[] => {
if (inputCoords.length !== targetDimensions.length || inputCoords.length !== inputDimensions.length) {

@@ -38,0 +38,0 @@ throw Error('coordinates must have same number of dimensions as input and target dimensions')

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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