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

@opencreek/ext

Package Overview
Dependencies
Maintainers
3
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opencreek/ext - npm Package Compare versions

Comparing version 1.7.0--canary.12.1829903665.0 to 1.7.0--canary.12.1829969022.0

1

build/range.d.ts
/**
* range will make an array from start to end (exclusive), with the given step
*
* @param start first value in the array

@@ -4,0 +5,0 @@ * @param end last value + step of the array

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.range = void 0;
const _1 = require(".");
/**
* range will make an array from start to end (exclusive), with the given step
*
* @param start first value in the array

@@ -11,4 +13,14 @@ * @param end last value + step of the array

function range(start, end, step = 1) {
if (step === 0) {
(0, _1.error)("step must not be 0");
}
const ret = [];
let i = 0;
step = start > end && step > 0 ? -step : step;
if (step < 0) {
for (let n = start; n > end; n += step) {
ret[i++] = n;
}
return ret;
}
for (let n = start; n < end; n += step) {

@@ -15,0 +27,0 @@ ret[i++] = n;

@@ -16,2 +16,9 @@ "use strict";

});
(0, ava_1.default)("range should produce negative ranges", (t) => {
t.deepEqual((0, range_1.range)(6, 3), [6, 5, 4]);
t.deepEqual((0, range_1.range)(6, 1, 2), [6, 4, 2]);
t.deepEqual((0, range_1.range)(6, 1, -2), [6, 4, 2]);
t.deepEqual((0, range_1.range)(8, 3, -0.5), [3.5, 4, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0].reverse());
t.deepEqual((0, range_1.range)(8, 3, 0.5), [3.5, 4, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0].reverse());
});
//# sourceMappingURL=range.test.js.map

2

package.json
{
"name": "@opencreek/ext",
"version": "1.7.0--canary.12.1829903665.0",
"version": "1.7.0--canary.12.1829969022.0",
"description": "",

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

@@ -13,1 +13,15 @@ import test from "ava"

})
test("range should produce negative ranges", (t) => {
t.deepEqual(range(6, 3), [6, 5, 4])
t.deepEqual(range(6, 1, 2), [6, 4, 2])
t.deepEqual(range(6, 1, -2), [6, 4, 2])
t.deepEqual(
range(8, 3, -0.5),
[3.5, 4, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0].reverse()
)
t.deepEqual(
range(8, 3, 0.5),
[3.5, 4, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0].reverse()
)
})

@@ -0,3 +1,6 @@

import { error } from "."
/**
* range will make an array from start to end (exclusive), with the given step
*
* @param start first value in the array

@@ -8,5 +11,16 @@ * @param end last value + step of the array

export function range(start: number, end: number, step = 1): Array<number> {
if (step === 0) {
error("step must not be 0")
}
const ret = []
let i = 0
step = start > end && step > 0 ? -step : step
if (step < 0) {
for (let n = start; n > end; n += step) {
ret[i++] = n
}
return ret
}
for (let n = start; n < end; n += step) {

@@ -13,0 +27,0 @@ ret[i++] = n

Sorry, the diff of this file is not supported yet

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