Socket
Socket
Sign inDemoInstall

ob1

Package Overview
Dependencies
Maintainers
2
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ob1 - npm Package Compare versions

Comparing version 0.80.5 to 0.80.6

2

package.json
{
"name": "ob1",
"version": "0.80.5",
"version": "0.80.6",
"description": "A small library for working with 0- and 1-based offsets in a type-checked way.",

@@ -5,0 +5,0 @@ "main": "src/ob1.js",

@@ -1,12 +0,1 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";

@@ -36,35 +25,14 @@

testUnsafeOps() {
// $FlowExpectedError - adding two 1-based offsets.
add(FORTY_TWO_1, FORTY_TWO_1);
// $FlowExpectedError - subtracting 1-based offset from 0-based offset.
sub(FORTY_TWO_0, FORTY_TWO_1);
// $FlowExpectedError - direct computations with offsets are disallowed.
FORTY_TWO_0 - 1;
// $FlowExpectedError - direct computations with offsets are disallowed.
FORTY_TWO_1 - 1;
// $FlowExpectedError - extracting a 1-based offset as a 0-based number
get0(FORTY_TWO_1);
// $FlowExpectedError - extracting a 0-based offset as a 1-based number
get1(FORTY_TWO_0);
// $FlowExpectedError - negating a 1-based offset
neg(FORTY_TWO_1);
// $FlowExpectedError - adding 1 to an offset that's already 1-based
add1(FORTY_TWO_1);
// $FlowExpectedError - subtracting 1 from an offset that's already 0-based
sub1(FORTY_TWO_0);
// $FlowExpectedError - extracting an arbitrary number as a 0-based number
get0(42);
// $FlowExpectedError - extracting an arbitrary number as a 1-based number
get1(42);
},
};

@@ -1,63 +0,27 @@

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
"use strict";
/* eslint-disable no-redeclare */
// A type representing 0-based offsets.
// A type representing 1-based offsets.
// Add two offsets or numbers.
function add(a, b) {
return a + b;
}
// Subtract a number or 0-based offset from a 1/0-based offset.
function sub(a, b) {
return a - b;
}
// Get the underlying number of a 0-based offset, casting away the opaque type.
function get0(x) {
return x;
}
// Get the underlying number of a 1-based offset, casting away the opaque type.
function get1(x) {
return x;
}
// Add 1 to a 0-based offset, thus converting it to 1-based.
function add1(x) {
return x + 1;
}
// Subtract 1 from a 1-based offset, thus converting it to 0-based.
function sub1(x) {
return x - 1;
}
// Negate a 0-based offset.
function neg(x) {
return -x;
}
// Cast a number to a 0-based offset.
function add0(x) {
return x;
}
// Increment a 0-based offset.
function inc(x) {

@@ -64,0 +28,0 @@ return x + 1;

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