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

a-frame-components

Package Overview
Dependencies
Maintainers
1
Versions
321
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a-frame-components - npm Package Compare versions

Comparing version 1.0.293 to 1.0.294

23

dist/gui/components/slider.js

@@ -13,3 +13,3 @@ var __assign = (this && this.__assign) || function () {

import { AFRAME } from "../../react/root";
import { createText } from "../../util";
import { createText, findClosestValue } from "../../util";
import { key_orange, key_offwhite, key_grey, key_white, key_grey_light } from "../vars";

@@ -421,23 +421,2 @@ import interactionMixin from "../../react/components/interaction-mixin";

}
function findClosestValue(textValueMap, val) {
// Initialize a variable to keep track of the closest item. Start with null and will replace it with an item from textValueMap.
var closestItem = null;
// Initialize a variable to keep track of the smallest difference found. Start with Infinity as we haven't checked any items yet.
var smallestDifference = Infinity;
// Iterate over each item in textValueMap
textValueMap.forEach(function (item) {
// Convert the item's value to a number for comparison
var itemValue = (item.value);
// Calculate the absolute difference between the item's value and the provided val
var difference = Math.abs(val - itemValue);
// Check if this difference is smaller than the smallest difference we've found so far
if (difference < smallestDifference) {
// If so, update the smallestDifference and the closestItem
smallestDifference = difference;
closestItem = item;
}
});
// After checking all items, return the closestItem found
return closestItem;
}
}

4

dist/index.js

@@ -40,4 +40,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { raiseOn, setAttribute, useEventsListenerOn, useBindEventOn } from './react/useEventListenerOn';
import { createElement } from "./util";
export { raiseOn, setAttribute, useEventsListenerOn, useBindEventOn, useEventListenerOn, createElement };
import { createElement, findClosestValue } from "./util";
export { raiseOn, findClosestValue, setAttribute, useEventsListenerOn, useBindEventOn, useEventListenerOn, createElement };
export function load() {

@@ -44,0 +44,0 @@ return __awaiter(this, void 0, void 0, function () {

@@ -465,1 +465,22 @@ var __assign = (this && this.__assign) || function () {

};
export function findClosestValue(textValueMap, val) {
// Initialize a variable to keep track of the closest item. Start with null and will replace it with an item from textValueMap.
var closestItem = null;
// Initialize a variable to keep track of the smallest difference found. Start with Infinity as we haven't checked any items yet.
var smallestDifference = Infinity;
// Iterate over each item in textValueMap
textValueMap.forEach(function (item) {
// Convert the item's value to a number for comparison
var itemValue = (item.value);
// Calculate the absolute difference between the item's value and the provided val
var difference = Math.abs(val - itemValue);
// Check if this difference is smaller than the smallest difference we've found so far
if (difference < smallestDifference) {
// If so, update the smallestDifference and the closestItem
smallestDifference = difference;
closestItem = item;
}
});
// After checking all items, return the closestItem found
return closestItem;
}
{
"name": "a-frame-components",
"version": "1.0.293",
"version": "1.0.294",
"description": "",

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

import { AFRAME } from "../../react/root";
import { createText } from "../../util";
import { createText, findClosestValue } from "../../util";
import { key_orange, key_offwhite, key_grey, key_white, key_grey_light } from "../vars";

@@ -481,29 +481,2 @@ import interactionMixin from "../../react/components/interaction-mixin";

function findClosestValue(textValueMap: { text: string; value: number }[], val: number): { text: string; value: number } {
// Initialize a variable to keep track of the closest item. Start with null and will replace it with an item from textValueMap.
let closestItem: { text: string; value: number } | null = null;
// Initialize a variable to keep track of the smallest difference found. Start with Infinity as we haven't checked any items yet.
let smallestDifference = Infinity;
// Iterate over each item in textValueMap
textValueMap.forEach(item => {
// Convert the item's value to a number for comparison
const itemValue = (item.value);
// Calculate the absolute difference between the item's value and the provided val
const difference = Math.abs(val - itemValue);
// Check if this difference is smaller than the smallest difference we've found so far
if (difference < smallestDifference) {
// If so, update the smallestDifference and the closestItem
smallestDifference = difference;
closestItem = item;
}
});
// After checking all items, return the closestItem found
return closestItem;
}
}
import painter from "./react";
import useEventListenerOn from "./react/useEventListenerOn";
import { raiseOn, setAttribute, useEventsListenerOn, useBindEventOn } from './react/useEventListenerOn';
import { createElement } from "./util";
export { raiseOn, setAttribute, useEventsListenerOn, useBindEventOn, useEventListenerOn, createElement };
import { createElement, findClosestValue } from "./util";
export { raiseOn, findClosestValue, setAttribute, useEventsListenerOn, useBindEventOn, useEventListenerOn, createElement };
export async function load() {
return painter();
}

@@ -586,2 +586,30 @@ export interface Container {

transition: 'background-color 0.2s',
};
};
export function findClosestValue(textValueMap: { text: string; value: number }[], val: number): { text: string; value: number } {
// Initialize a variable to keep track of the closest item. Start with null and will replace it with an item from textValueMap.
let closestItem: { text: string; value: number } | null = null;
// Initialize a variable to keep track of the smallest difference found. Start with Infinity as we haven't checked any items yet.
let smallestDifference = Infinity;
// Iterate over each item in textValueMap
textValueMap.forEach(item => {
// Convert the item's value to a number for comparison
const itemValue = (item.value);
// Calculate the absolute difference between the item's value and the provided val
const difference = Math.abs(val - itemValue);
// Check if this difference is smaller than the smallest difference we've found so far
if (difference < smallestDifference) {
// If so, update the smallestDifference and the closestItem
smallestDifference = difference;
closestItem = item;
}
});
// After checking all items, return the closestItem found
return closestItem;
}

@@ -27,2 +27,3 @@ // aframe.d.ts

export function raiseOn(props: { [`frame-id`]: string }, eventName: string, details: any): void;
export function findClosestValue(textValueMap: { text: string; value: number }[], val: number): { text: string; value: number };
}

@@ -29,0 +30,0 @@ declare namespace JSX {

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