JSPM

append-type

0.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 29034
  • Score
    100M100P100Q138312F
  • License MIT

Stringify the value with appending its type: 10 → '10 (number)'

Package Exports

  • append-type

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (append-type) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

sub-index

NPM version Bower version Build Status Coverage Status devDependencies Status

Find an array index of the substitute value that should be chosen when a given index is deleted

import subIndex from 'sub-index';

const array = new Array(3);

subIndex(array, 1); //=> 0
subIndex(array, 2); //=> 1

subIndex(array, 0); //=> 1

Installation

npm

npm install sub-index

bower

bower install sub-index

API

subIndex(array, index)

array: Array (non-empty array)
index: Number (index of the array assumed to be deleted)
Return: Number or null

Essentially, it returns the predecessor number of a given index.

index:      0 1 2
value:      A B C
deleted:      ^
substitute: ^
subIndex(['A', 'B', 'C'], 1); //=> 0

If index is 0, it returns the successor number 1 because the first element has no predecessor elements.

index:      0 1 2
value:      A B C
deleted:    ^
substitute:   ^
subIndex(['A', 'B', 'C'], 0); //=> 1

If the array includes only a single value, it returns null because no value exists after deletion.

index:      0
value:      A
deleted:    ^
substitute: (none)
subIndex(['A'], 0); //=> null

License

Copyright (c) 2016 Shinnosuke Watanabe

Licensed under the MIT License.