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

ml-array-normed

Package Overview
Dependencies
Maintainers
5
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-array-normed - npm Package Compare versions

Comparing version

to
1.3.5

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [1.3.5](https://github.com/mljs/array/compare/ml-array-normed@1.3.4...ml-array-normed@1.3.5) (2021-03-03)
### Bug Fixes
* use TS namespace instead of modules for default exports ([#16](https://github.com/mljs/array/issues/16)) ([3b5c725](https://github.com/mljs/array/commit/3b5c7258df898ec5d35af70ac51570f956e1f9a8))
## [1.3.4](https://github.com/mljs/array/compare/ml-array-normed@1.3.3...ml-array-normed@1.3.4) (2021-02-23)

@@ -8,0 +19,0 @@

0

History.md

@@ -0,0 +0,0 @@ # 1.1.0 (2020-03-02)

20

lib/index.js
'use strict';
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var isArray = require('is-any-array');
var max = require('ml-array-max');
var sum = require('ml-array-sum');
var isArray = _interopDefault(require('is-any-array'));
var max = _interopDefault(require('ml-array-max'));
var sum = _interopDefault(require('ml-array-sum'));
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var isArray__default = /*#__PURE__*/_interopDefaultLegacy(isArray);
var max__default = /*#__PURE__*/_interopDefaultLegacy(max);
var sum__default = /*#__PURE__*/_interopDefaultLegacy(sum);
function norm(input, options = {}) {
const { algorithm = 'absolute', sumValue = 1, maxValue = 1 } = options;
if (!isArray(input)) {
if (!isArray__default['default'](input)) {
throw new Error('input must be an array');

@@ -17,3 +21,3 @@ }

if (options.output !== undefined) {
if (!isArray(options.output)) {
if (!isArray__default['default'](options.output)) {
throw new TypeError('output option must be an array if specified');

@@ -40,3 +44,3 @@ }

case 'max': {
let currentMaxValue = max(input);
let currentMaxValue = max__default['default'](input);
if (currentMaxValue === 0) return input.slice(0);

@@ -50,3 +54,3 @@ const factor = maxValue / currentMaxValue;

case 'sum': {
let sumFactor = sum(input) / sumValue;
let sumFactor = sum__default['default'](input) / sumValue;
if (sumFactor === 0) return input.slice(0);

@@ -53,0 +57,0 @@ for (let i = 0; i < input.length; i++) {

{
"name": "ml-array-normed",
"version": "1.3.4",
"version": "1.3.5",
"description": "Normalize the values of a given array",

@@ -27,6 +27,6 @@ "main": "lib/index.js",

"is-any-array": "^0.1.0",
"ml-array-max": "^1.2.1",
"ml-array-max": "^1.2.2",
"ml-array-sum": "^1.1.4"
},
"gitHead": "55597eaa820f947d2c6eeffa7c5f807a5e4c94c8"
"gitHead": "047f2d11d174dad9b576649f676adfa2439fff15"
}

@@ -0,0 +0,0 @@ # array-normed

@@ -0,0 +0,0 @@ import norm from '..';

@@ -0,0 +0,0 @@ import isArray from 'is-any-array';

@@ -1,2 +0,2 @@

declare module 'ml-array-normed' {
declare namespace mlArrayNormed {
export interface ArrayNormedOptions<T extends ArrayLike<number>> {

@@ -22,11 +22,12 @@ /**

}
}
/**
* Normalize the values of the given array.
*/
function arrayNormed<T extends ArrayLike<number>>(
array: T,
options?: ArrayNormedOptions<T>,
): number[];
export = arrayNormed;
}
/**
* Normalize the values of the given array.
*/
declare function mlArrayNormed<T extends ArrayLike<number>>(
array: T,
options?: mlArrayNormed.ArrayNormedOptions<T>,
): number[];
export = mlArrayNormed;

Sorry, the diff of this file is not supported yet