New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

xdim

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xdim - npm Package Compare versions

Comparing version 1.0.0-0 to 1.1.0-0

src/funcs.js

12

package.json
{
"name": "xdim",
"version": "1.0.0-0",
"version": "1.1.0-0",
"description": "Multi-Dimensional Functions. Create, Query, and Transform Multi-Dimensional Data.",
"main": "xdim.js",
"main": "src/xdim.js",
"files": [
"xdim.js"
"src/xdim.js",
"src/funcs.js"
],
"scripts": {
"format": "npx prettier --arrow-parens=avoid --print-width=160 --trailing-comma=none --write *.js */*.js",
"test": "for f in tests/*.js; do node $f; done"
"build": "node scripts/build.js",
"format": "npx prettier --arrow-parens=avoid --print-width=160 --trailing-comma=none --write */*.js",
"test": "npm run build && for f in tests/*.js; do node $f; done"
},

@@ -13,0 +15,0 @@ "repository": {

@@ -40,3 +40,3 @@ # xdim

# usage
This library provides the following functions: [select](#select), [clip](#clip), [transform](#transform), [prepareData](#prepareData), and [update](#update).
This library provides the following functions: [select](#select), [prepareSelect](#prepareSelect), [clip](#clip), [transform](#transform), [prepareData](#prepareData), and [update](#update).

@@ -89,2 +89,56 @@ ## select

## prepareSelect
The `prepareSelect` function is use to create a supercharged select function for some data. There is some
fixed cost to creating the function, so only use it if you think you will run several to many selects.
:sparkles: So what magic makes the prepared select statements so fast? We pre-generate
[select functions](https://github.com/DanielJDufour/xdim/blob/main/src/funcs.js), so that JavaScript compilers
can optimize the logical steps needed to lookup data. We then just [bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Function/bind) the dimension names, sizes, and data to these "pre-compiled" functions.
```javascript
import { prepareSelect } from 'xdim';
// satellite imagery data broken down by band
const data = [
[0, 123, 123, 162, ...], // red band
[213, 41, 62, 124, ...], // green band
[84, 52, 124, 235, ...] // blue band
];
const select = prepareSelect({
data,
// each band is a separate array
// the values in a band are in row-major order
layout: "[band][row,column]",
sizes: {
band: 3, // image has 3 bands (red, green, and blue)
column: 100 // image is 100 pixels wide
}
});
const result = select({
point: {
band: 2, // 3rd band (blue), where band index starts at zero
row: 74, // 75th row from the top
column: 63 // 64th column from the left
}
});
```
result is an object
```js
{
// the actual value found in the array
value: 62,
// the index in the array where the value is found
index: 7463,
// a reference to the same array in the provided data
parent: [84, 52, 124, 235, ... 62, ...]
}
```
## clip

@@ -91,0 +145,0 @@ The `clip` function is used to pull out a subsection of the data within a [hyperrectangle](https://en.wikipedia.org/wiki/Hyperrectangle) (i.e. multi-dimensional rectangle), which we call "rect". The "rect" is defined by an object with dimension name keys and a numerical range. The range is "inclusive", including the first and last numbers provided.

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