0.8.1 • Published 4 years ago

@rudenko/stalin-sort v0.8.1

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

stalinSort

Inspired by a post on mastodon

Developed for educational purposes within kottans

Installation

  • npm: npm install --save @rudenko/stalin-sort
  • yarn: yarn add @rudenko/stalin-sort

Usage

const stalinSort = require('@rudenko/stalin-sort')

const numbers = [5, 2, 18, 1];
const strings = ['klm', 'nop', 'def', 'abc']
let result

try {
  result = stalinSort(numbers) // [5, 18]
} catch (e) {
  // handle exception TypeError('Argument must be an array')
}

try {
  result = stalinSort(strings, (a, b) => a > b) // ['klm', 'def', 'abc']
} catch (e) {
  // handle exceptions:
  // - TypeError('Argument must be an array')
  // - TypeError('Comparator must be a function')
}

See example.js for more examples.

Educational

Advance from version to version to track the development process.

See also CHANGELOG.md

VersionMilestoneCommentDiff
0.0.1Initialize project
0.0.2Add code stub and basic testTests failv0.0.1...v0.0.2
0.0.3Add positive scenarios test setTests still failv0.0.2...v0.0.3
0.1.0Add for loop implementationTests succeedv0.0.3...v0.1.0
0.1.1Change implementation using for...in loopTests succeedv0.1.0...v0.1.1
0.1.2Change implementation using for...of loopTests succeedv0.1.1...v0.1.2
0.2.0Change implementation using Array.forEachTests succeedv0.1.2...v0.2.0
0.3.0Change implementation using Array.reduceTests succeedv0.2.0...v0.3.0
0.4.0Change implementation using Array.filterTests succeedv0.3.0...v0.4.0
0.4.1Change Array.filter condition (skip boolean literals)Tests succeedv0.4.0...v0.4.1
0.4.2Change Array.filter condition (distill logic)Tests succeedv0.4.1...v0.4.2
0.5.0Add error handling on wrong argument typeTests succeedv0.4.2...v0.5.0
0.6.0Add compare argument and pre-defined comparatorsTests succeedv0.5.0...v0.6.0
0.7.0Add usage and example.jsTests succeedv0.6.0...v0.7.0
0.8.0Fix stalinSort implementation logical mistakeTests succeedv0.7.0...v0.8.0
0.8.1Add tests for comparison functions from utilsTests succeedv0.8.0...v0.8.1

Similar projects

Misc

Time spent: apx 2hrs