包详细信息

@onelinecode/onelinecode

martinkr61MIT1.21.0

Awesome javascript in one line of code

onelineofcode, javascript, codequality, utilities

自述文件

Awesome JavaScript in one line of code written above a picture of Mt. Fuji's peak

Awesome javascript in one line of code

A collection of utilities and helpers following the principle: Keep it as simple as possible in one line of code.

As long as we area dealing with JavaScript, the library assumes that the user provides valid input. No type checking or other verifications of the arguments are part of the functions. The library tires to use the simplest and most performant code possible. To keep the functions as simple as possible they will be reduced to the core functionality: "one function should have one specific functionality only".

New functions will be added every time there is an article being published.

All functions are written in ESNext esmodules (./src) and available as -umd (./dist/index.js) with the onelinecode namespace (e.g. window.onlinecode) -commonjs (./dist/index.cjs.js) -esm (./dist/index.esm.js)

Available functions

Array

See ./doc/array.md

Installation

$ npm i @onelinecode/onelinecode
$ yarn add @onelinecode/onelinecode

Usage

For example, you want to shallowClone an array:

import { shallowClone } from '@onelinecode/onelinecode/array';
let array = [1];
let arrayClone = shallowClone(array);

Testing

The library has 100% code coverage with ava and passes the build on Build status from travis-ci.

Contribution

If you are interested in discussion a specific function, please see the corresponding article from the series on dev.to.

Please don't hesitate to comment, give feedback. I appreciate every input or comment. We can and should learn from each others opinion and knowledge. Please stick to a respectful style of discussion and read the code of conduct like the articles or star the repository.

Tech Stack

  • ava: 3.15.0
  • c8: 7.10.0
  • esm: 3.2.25
  • rollup: 2.58.

License

Licensed under the MIT license. MIT - http://www.opensource.org/licenses/mit-license.php

更新日志

1.21.0 (2022-01-19)

Features

  • push new version: new version (da64205)

1.20.2 (2021-12-08)

Bug Fixes

  • string/capitalise: performance (4fd3a59)

1.20.1 (2021-12-07)

Bug Fixes

  • string/countWords: punctation chars (62e1460)

1.20.0 (2021-12-06)

Features

  • string/countWords: BREAKING CHANGE for versioning but only because of introducing strings (2598907)

1.19.0 (2021-12-02)

Features

  • array/rangeArray: create a range array (b2ed9e9)

1.18.1 (2021-12-01)

Bug Fixes

  • array/sortDesc: performance (1173fd2)

1.18.0 (2021-11-24)

Features

  • array/nthItems: performance (b11f276)
  • array/nthItems: performance (c475a97)

1.17.0 (2021-11-23)

Features

  • array/average: performance (74776c7)

1.16.0 (2021-11-22)

Features

  • array/average new features (e9f4d76)
  • array/sortAsc ew features (e9f4d76)
  • array/sortDesc new features (e9f4d76)
  • array/sum, array/average: calculations (a2cd22f)

1.15.0 (2021-11-17)

Features

  • array/clean: clean an array (881dafa)
  • array/cleanFalsy: clean an array from falsy values (3f5518e)

1.14.2 (2021-11-15)

Bug Fixes

  • Array/mergeArray: performance improvements (88b5356)

1.14.1 (2021-11-11)

Bug Fixes

  • Array/evenItem, Array/oddItem: performance improvements (cc30384)

1.14.0 (2021-11-10)

Bug Fixes

  • Array/evenItem: performance improvements (5953fd3)

Features

  • Array/evenItem: Returns an array which contains every even item of the original array. (85bb14b)

1.13.0 (2021-11-09)

Bug Fixes

  • Array/oddItem: fix spec (70df948)

Features

  • Array/oddItem: Returns an array which contains every odd (second) item of the original array. (2ec177d)

1.12.0 (2021-11-08)

Features

  • array/longest-string-length: Returns the length of the longest string entry of an Array of strings. (b0a1973)

1.11.0 (2021-11-05)

Bug Fixes

  • Array/ShortestStringLength: performance (af954f7)

Features

  • Array/shortestStringLength: Returns the length of the shortest string entry of an Array of strings. (2a41658)

1.10.3 (2021-11-02)

Bug Fixes

  • Array/lontestString: fix function, fix test (4874047)

1.10.2 (2021-11-02)

Bug Fixes

  • Array/splitInHalf: performance (f46bee1)

1.10.1 (2021-11-01)

Bug Fixes

  • Array/splitInHalf: performance (ceaf6b9)
  • Array/splitInHalf: performance (071c758)

1.10.0 (2021-11-01)

Features

  • Array/splitInHalf: split an Array in half (79c5a70)

1.9.0 (2021-10-31)

Bug Fixes

  • Array/indexOfLowestNumber: performance optimization. (fd42777)
  • Array/indexOfLowestNumber: performance optimization. (4b3765b)

Features

  • Array/indexOfHighestNumber: Returns the index of the highest numerical item of the array. (9bb569b)

1.8.0 (2021-10-30)

Features

  • Array/indexOfLowestNumber: Returns the index of the lowest numerical item of the array. (9b4ce66)

1.7.0 (2021-10-30)

Features

  • Array/closestNumber: Returns the numerical item closest to the given number. (ae8a6aa)

1.6.1 (2021-10-29)

Bug Fixes

  • documentation: modified install command (a2f7346)

1.6.0 (2021-10-29)

Features

  • Array/highestNumber: Returns the highest coerced numerical numerical item of the array.r (f5f9ffb)

1.5.0 (2021-10-27)

Features

  • Array/lowestNumber: Returns the lowest coerced numerical numerical item of the array.

1.4.0 (2021-10-25)

Features

  • Array/removeDuplicates: Returns a copy of the array. Removes duplicate entries.

    1.3.0 (2021-10-25)

    Features

  • Array/isEmpty: Returns a boolean false if the array is not empty or a boolean true if the array is empty.

1.2.0 (2021-10-24)

Features

  • Array/shallowClone: Creates a shallow-copied clone of the provided array.

    1.1.0 (2021-10-24)

Features

  • Array/occurrenceMap: Returns an object where the keys are the array entries and the values the number of their occurrences.