open-index/open-npm huggingface dataset:
npm package: @geronimus/is-empty
Description: Identifies whether or not the provided value represents an empty value, such as an empty string or array.
Author: Graham Brown
Latest version: 0.1.3

# isEmpty( value )

Identifies whether the provided argument represents a value that does not hold any useful information. (eg, `null`, `undefined`, `NaN`, the empty string, or an empty Array, Map, Set or Object.)

## Examples

```javascript
const isEmpty = require( "@geronimus/is-empty" );

isEmpty( null ); // => true
isEmpty( undefined ); // => true
isEmpty( false ); // => false
isEmpty( NaN ); // => true
isEmpty( 0 ); // => false
isEmpty( "" ); // => true
isEmpty( " " ); // => false
isEmpty( {} ); // => true
isEmpty( [] ); // => true
isEmpty( [ {} ] ); // => false
isEmpty( new Map() ); // => true
isEmpty( new Set() ); // => true
```

## Parameters

`value` *any*

The value to test for emptiness.
npm package: @geronimus/is-null
Description: Tests values for strict equality with null or undefined.
Author: Graham Brown
Latest version: 0.1.5

# isNull( value )

Tests a value for strict equality with `null` and `undefined`, and returns `true` if the value is equal with either.

## Examples

```javascript
const isNull = require( "@geronimus/is-null" );

isNull( null ) // => true
isNull( undefined ) // => true
isNull( {} ) // => false
isNull( [] ) // => false
isNull( 0 ) // => false
isNull( false ) // => false
```

## Parameters

`value` *any*

The value to test for strict equality with `null` or `undefined`.
npm package: @geronimus/is-object
Description: Determines whether or not a reference's target is a non-null object type.
Author: Graham Brown
Latest version: 0.1.2

# isObject( value )

Returns `true` if - and only if - the referenced value's type is `"object"`, and it is not the value `null`.

Be aware that Arrays will return `true` because their type resolves to `"object"`.

## Examples

```javascript
const isObject = require( "@geronimus/is-object" );

isObject( undefined ); // => false
isObject( null ); // => false
isObject( 1 ); // => false
isObject( true ); // => false
isObject( "object" ); // => false
isObject( {} ); // => true
isObject( [] ); // => true
isObject( new Date() ); // => true
```

## Parameters

`value` *any*

The value that you want to identify as an `"object"`.

## Notes

- An Array will return `true` because it behaves as an object.
- Although `typeof null` resolves to `"object"`, `null` returns `false` because it does not behave like an object. (eg, It does not have, and cannot have, any properties.)
npm package: @geronimus/option
Description: Creates Some and None objects that you can use in functions that may or may not return a value.
Author: Graham Brown
Latest version: 0.1.0

# Option

Contains functions to create `Some` and `None` objects, which you can return from function calls that may or may not return a result.

The idea is to avoid returning `null` or `undefined` - whether intentionally, accidentally, or by default - and to make explicit the idea that giving no result is a legitimate possibility, which  any code that calls the function must be prepared to deal with.

When the invocation should return a result, you can "wrap" it in a `Some`.

When there is no result, you return the `None` singleton object.

Both objects share this common interface:

## Properties

`isEmpty` *boolean*

`true` if this is the `None` object, or a `Some` object that holds the value `undefined` or `null`. `false` if it is a `Some` object that holds a value.

## Methods

`map( transformation )` *function*

If called on the `None` object, this method always returns `None`, no matter what function you pass to it.

If called on a `Some` object, this method returns another `Some` object containing the result of applying the `transformation` function to the original `Some`'s `value`.

### None

`None` is not a function. It is a singleton object that you may return instead of a call to `Some`. (`Some` is a function.)

The `None` object adheres to to the **Option** interface described above.

As a simple object, `None` is not an `instanceof` anything. You cannot use the `new` keyword with `None`, nor does it have any meaning to call `None` with parentheses.

There is only one `None` object. As such, `None === None` returns `true`.

### Some( value )

Creates an instance of a `Some` object.

The returned object adheres to to the **Option** interface described above and contains the additional property `value`, which references the value that the `Some` object  holds.

You can use the keyword `new` to create a new `Some` instance, but you do not have to.

#### Parameters

`value` *any*

The value that you want to wrap in a `Some` object.

## Examples

```javascript
const { None, Some } = require( "@geronimus/option" );

function getFirstItem( array ) {

  if ( !Array.isArray( array ) || array.length === 0 )
    return None;
  else
    return Some( array[ 0 ] );
}
```

## Notes

- If you forget to provide an argument to `Some`, it will contain the value `undefined`, which seems like a contradiction. In this case, its `isEmpty` value will be `true`. We leave this possibility open ( - rather than, say, returning `None` when a value is not provided - ) in order not to be too opinionated about its usage.
- These objects provide a (much) simplified implementation of a pattern popularized by the Scala programming language.
npm package: @geronimus/random-int
Description: Generates a pseudo-random integer between the two bounds you specify. (Both inclusive.)
Author: Graham Brown
Latest version: 0.1.3

# randomInt( lowerBound, upperBound )

Generates a pseudo-random integer value between the bounds that you specify. (Both inclusive.)

If either number has a decimal part, it will be truncated.

Both bounds must be between `Number.MIN_SAFE_INTEGER` and `Number.MAX_SAFE_INTEGER`.

`upperBound` must be greater than `lowerBound`.

## Examples

```javascript
const randomInt = require( "@geronimus/random-int" );

const randomByteValue = randomInt( 0, 255 );
```

## Parameters

`lowerBound` *number*

The smallest possible random value that can be produced.

`upperBound` *number*

The largest possible random value that can be produced.

## Notes

This function uses `Math.random()` as a pseudo-random number generator.

Therefore, ***DO NOT*** use it for any purpose that must be cryptographically secure.
npm package: @geronimus/range
Description: Produces an array containing all of the integers between the bounds you specify.
Author: Graham Brown
Latest version: 0.1.1

# range( lowerBound, upperBound )

Generates an array containing all of the integers between the two bounds that you specify. (Inclusive.)

## Examples

```javascript
const range = require( "@geronimus/range" );

console.log( range( 1, 5 ) );
// Expected output:
// => [ 1, 2, 3, 4, 5 ]
```

## Parameters

`lowerBound` *number*

The first number in the integer sequence that will be produced.

`upperBound` *number*

The last number in the integer sequence that will be produced.

## Notes

If either argument has a decimal part, it will be truncated.

Both bounds must be between `Number.MIN_SAFE_INTEGER` and `Number.MAX_SAFE_INTEGER`.

`upperBound` must be greater than or equal to `lowerBound`.

The difference between the two bounds must be less than 4,294,967,296 (2<sup>32</sup>).
npm package: @geronimus/resolve-type-name
Description: Resolves the type name of a value using both ECMAScript's primitive and extended type systems.
Author: Graham Brown
Latest version: 0.1.5

# resolveTypeName

Gives the name of the type of a value, whether that type is a primitive, an object literal, or an object returned by a constructor function.

- If the value is a primitive type (eg, `boolean`, `number`, `string` ), then it returns the name of that type.

- If the value is `null`, then it returns the text `null`.

- If the value is a function, then it returns the text `function`.

- If the value was defined as an object literal, then it returns the text `object`.

- If the value is an object defined with a constructor function (eg, `new Date()`), then it returns the name of the constructor (eg, `"Date"`).

### However, BEWARE!!!

This function is intended primarily to construct meaningful error and log messages during the development phase of a project.

It is not intended for use in program logic, and certainly never to produce any user-facing content.

The reason is that - for objects created using a constructor function - the value returned is the value of `Object.prototype.constructor.name`. If your code gets minified, then the constructor function's original name will be replaced by a shortened, unrecognizable, and potentially randomized name.

This means that this function:

  - Should never be used to determine the type of a user-defined object in program logic. (Use the `instanceof` operator instead.)
  - Will likely be unhelpful for production logging, and should not be used to produce error messages that may become visible to the end user.

#### Example

```javascript
const resolveTypeName = require( "@geronimus/resolve-type-name" );

function resolveTypeName( undefined ); \\ => "undefined"
function resolveTypeName( true ); \\ => "boolean"
function resolveTypeName( 1 ); \\ => "number"
function resolveTypeName( "text" ); \\ => "string"
function resolveTypeName( null ); \\ => "null"
function resolveTypeName( () => {} ); \\ => "function"
function resolveTypeName( {} ); \\ => "object"
function resolveTypeName( new Date() ); \\ => "Date"
```
npm package: @geronimus/type-err
Description: Simplifies generating an instance of TypeError with a predictable message.
Author: Graham Brown
Latest version: 0.1.2

# TypeErr( refName, expectedTypeName, foundInstance )

Returns a new instance of a `TypeError` with the error message:

> Reference name: *refName*
> <br/>&nbsp;&nbsp;Expected: *expectedTypeName*
> <br/>&nbsp;&nbsp;Actual: *either ***typeof foundInstance*** or, if ***foundInstance*** is of type ***object***, then ***foundInstance.constructor.name***.*

## Examples

```javascript
const TypeErr = require( "@geronimus/type-err" );

function hello( who ) {

  if ( typeof who !== "string" )
    throw TypeErr( "who", "string", who );
  else
    console.log( `Hello, ${ who }!` );
}
```

## Parameters

`param` *string*

The parameter, variable, or reference name where the invalid type was found.

`expectedTypeName` *string*

The type that is expected or allowed.

`foundInstance` *any*

The reference that you found to be of the wrong type.

The function will resolve its name for display in the error message. If the instance is a primitive value, then its `typeof` name will be displayed. If it is an object, then the message will display the name of its constructor.

## Notes

If you do not provide meaningful arguments, the generated message will be meaningless.
npm package: @geronimus/uuid
Description: Generates the string representation of a random (variant 4) RFC 4122 UUID.
Author: Graham Brown
Latest version: 0.1.2

# uuid()

Generates a Universally Unique Identifier, based on variant 4 (random) of the [Internet Engineering Task Force (IETF) Request for Comments (RFC) 4122](https://tools.ietf.org/html/rfc4122) proposal.

Specifically, this function generates its canonical string representation.

## Examples

```javascript
const uuid = require( "@geronimus/uuid" );

console.log( uuid() );
// Expected output:
// => "8afe0169-17a2-4091-8375-30ca1d4333ab" (Or similar.)

const id1 = uuid();
const id2 = uuid();

if ( id1 === id2 )
  console.log( "It's an impossible coincidence!" );
else
  console.log( "Each value is unique." );
```

## Notes

The randomness of this function depends on `Math.random()`. Therefore, it ***MUST NOT*** be used for any purpose requiring cryptographic security.