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

math-in-interval

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

math-in-interval

## Examples

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

math-interval

Examples

inInterval('(1,5)', 1); // false
inInterval('[1,5)', 1); // true
inInterval('[1,5)', 5); // false
inInterval('[1,5]', 5); // true
inInterval('(1,5]', 5); // true
inInterval('(,5]', 5); // true
inInterval('(,5]', 1); // true

More examples

test('open', () => {
  expect(inInterval('(1,5)', 1)).toBeFalsy();
  expect(inInterval('(1,5)', 5)).toBeFalsy();
  expect(inInterval('(-1,5)', 1)).toBeTruthy();
  expect(inInterval('(-1,5)', 5)).toBeFalsy();
  expect(inInterval('(-1,-5)', 5)).toBeFalsy();
  expect(inInterval('(,-5)', -100)).toBeTruthy();
  expect(inInterval('(-1,)', 5)).toBeTruthy();
  expect(inInterval('(-1,)', -5)).toBeFalsy();
});

test('closed', () => {
  expect(inInterval('[1,5]', 1)).toBeTruthy();
  expect(inInterval('[1,5]', 5)).toBeTruthy();
  expect(inInterval('[-1,5]', 1)).toBeTruthy();
  expect(inInterval('[-1,5]', 5)).toBeTruthy();
  expect(inInterval('[-1,-5]', 5)).toBeFalsy();
  expect(inInterval('[,-5]', -100)).toBeTruthy();
  expect(inInterval('[-1,]', 5)).toBeTruthy();
  expect(inInterval('[-1,]', -5)).toBeFalsy();
});

test('leftOpen', () => {
  expect(inInterval('(1,5]', 1)).toBeFalsy();
  expect(inInterval('(1,5]', 5)).toBeTruthy();
  expect(inInterval('(-1,5]', 1)).toBeTruthy();
  expect(inInterval('(-1,5]', 5)).toBeTruthy();
  expect(inInterval('(-1,-5]', 5)).toBeFalsy();
  expect(inInterval('(,-5]', -100)).toBeTruthy();
  expect(inInterval('(-1,]', 5)).toBeTruthy();
  expect(inInterval('(-1,]', -1)).toBeFalsy();
});

test('rightOpen', () => {
  expect(inInterval('[1,5)', 1)).toBeTruthy();
  expect(inInterval('[1,5)', 5)).toBeFalsy();
  expect(inInterval('[-1,5)', 1)).toBeTruthy();
  expect(inInterval('[-1,5)', 5)).toBeFalsy();
  expect(inInterval('[-1,-5)', 5)).toBeFalsy();
  expect(inInterval('[,-5)', -100)).toBeTruthy();
  expect(inInterval('[-1,)', 5)).toBeTruthy();
  expect(inInterval('[-1,)', -1)).toBeTruthy();
});

test('incorrect interval', () => {
  expect(inInterval('123jkvb12h3b12h3', 5)).toBeFalsy();
});

test('zero', () => {
  expect(inInterval('[-10,0]', -5)).toBeTruthy();
  expect(inInterval('[-10,0]', 1)).toBeFalsy();
});

FAQs

Package last updated on 15 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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