6.10.94 • Published 10 months ago

@kollorg/animi-quisquam v6.10.94

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@kollorg/animi-quisquam

License: MIT Build Version Known Vulnerabilities GitHub last commit (branch) npm npm total codecov

Blazing fast, tree-shakeable, type-safe, modern utility library to sort any type of array

Docs : https://@kollorg/animi-quisquam.netlify.app/

Getting started

installation

The library is available as a npm package. To install the package, run:

npm install @kollorg/animi-quisquam
# or
yarn add @kollorg/animi-quisquam

Start using:

import {byString} from '@kollorg/animi-quisquam'

const unsorted = ["xxx", "bbbb", "zzz", "cccc", "aaa"];
const sorted = unsorted.sort(byString());

console.log(sorted); //(5) ["aaa", "bbbb", "cccc", "xxx", "zzz"]

Use directly in the browser

<script src='https://cdn.jsdelivr.net/npm/@kollorg/animi-quisquam/dist/index.umd.js'></script>
<script>
  const unsorted = ["xxx", "bbbb", "zzz", "cccc", "aaa"];
  const sorted = unsorted.sort(sort.byString());

  console.log(sorted); //(5) ["aaa", "bbbb", "cccc", "xxx", "zzz"]
</script>

//or via browser modules

<script type='module'>
  import {byString} from 'https://cdn.jsdelivr.net/npm/@kollorg/animi-quisquam/dist/index.mjs'

  const unsorted = ["xxx", "bbbb", "zzz", "cccc", "aaa"];
  const sorted = unsorted.sort(byString());

  console.log(sorted); //(5) ["aaa", "bbbb", "cccc", "xxx", "zzz"]
</script>

Some mind-blowing example

sort by a single property

//js or ts file
import {byValue, byNumber, byString} from '@kollorg/animi-quisquam'

const arrayUnsorted = [
  {prop: "xxx", foo: 34},
  {prop: "aaa", foo: 325},
  {prop: "zzz", foo: 15},
  {prop: "ccc", foo: 340},
  {prop: "bbb", foo: 0}
];

//this sort by the foo property ascending
const sortedByFoo = arrayUnsorted.sort(byValue((i) => i.foo, byNumber()));
console.log(sortedByFoo); //(5) [{prop: "bbb", foo : 0}, {prop: "zzz", foo: 15}, .....];

//this sort by the prop property descending
const sortedByProp = arrayUnsorted.sort(byValue((i) => i.prop, byString({desc: true})));
console.log(sortedByProp); //(5) [{prop: "zzz", foo : 15}, {prop: "xxx", foo: 34}, .....];

sort by a multiple property

//js or ts file
import {byNumber, byString, byValues} from "@kollorg/animi-quisquam";

const objsToSort = [
  {id: 2, name: 'teresa'},
  {id: 3, name: 'roberto'},
  {id: 2, name: 'roberto'}
];

//i sort by THEIR NAMES and THEN by their ids
const sortedObject = objsToSort.sort(byValues([
  [(x) => x.name, byString()],
  [(x) => x.id, byNumber()]
]));

console.log(sortedObject); //[{roberto, 2}, {roberto, 3}, {teresa, 2}];

//i sort by THEIR IDS and THEN by their names
const sortedObject2 = objsToSort.sort(byValues([
  [(x) => x.id, byNumber()],
  [(x) => x.name, byString()]
]));
console.log(sortedObject2); //[{roberto, 2}, {teresa, 2}, {roberto, 3}];

//i sort by THEIR IDS and THEN by their names DESCENDING
const sortedObject3 = objsToSort.sort(byValues([
  [(x) => x.id, byNumber()],
  [(x) => x.name, byString({desc: true})],
]));
console.log(sortedObject3); //[{teresa, 2}, {roberto, 2}, {roberto, 3}];

typescript types check

//ts file
import {byValue, byNumber, byString} from '@kollorg/animi-quisquam'

const objsArray = [{numbProp: 2, stringProp: 'a'}, {numbProp: 3, stringProp: 'f'}];

//Incorrect sort property
const incorrectSortedArray = objsArray.sort(byValue(i => i.numbProp, byString()));
//ts check error : Type 'number' is not assignable to type 'string'.

//Correct sort type
const sortedArray = objsArray.sort(byValue(i => i.numbProp, byNumber()))
//ts check ok

See full Docs

@kollorg/animi-quisquam.netlify.app

License

MIT © Cosimo chellini

WebSocketsUint8ArraybddrangeerrorrgbasterisksgenericsdependenciesMapunicodebannerrdscensorbyteOffsettapwritabletoolsfilejsdomsetterTypedArrayxhrreact poseamazonArray.prototype.flattenReactiveXES2015cloudwatchflagmergesomeAsyncIteratorhasOwnPropertyarktypespinnerArray.prototype.filteroptimistbusyastlanguagegesturesworkermochavalidationtypesresolvefastifyin_.extendenvironmentuninstalljQueryes5toobjecttapeespreevalidateshrinkwraptslibconfigurablereact-hook-formconsumetddURLSearchParamsschemajsxextratypanionroutingrulestrimStartloggersortbeanstalktshardlinksInt16Arrayes6jsonpackage.jsonproxytyped arraybabel-coreformatoptionprototyperegexpeslintconfigaccessorprotocol-buffersconfigsharedwarningatomPromiseObject.getPrototypeOfjson-schemamrucolumnses-shimssymlinksfixed-widthtextvalidreact-hookscompilerglobal this valuelistenersjasminemanipulationmapreducejson-schema-validatorclass-validatordroptypedarrayRFC-6455ECMAScript 2018asynccallbackqueueroute53mobilesinatrakeysefficient0transportispropcheckcommandweakmaplrulooknpmes7global objectWebSocketchromeimportexportmkdirsArray.prototype.findLastexpressspringObservableparentstacitassertsearchprefixObject.ismakephonenegative zero[[Prototype]]matchesdefinePropertyfull-widtharrayspackage managercollection.es6concatjavascriptdragtrimEndcompareArrayBuffermomentenvstreamslockfileTypeBoxflattenprunehasbrowserslistes2015utilsnodejsbinstructuredCloneglobalThissuperagentidentifiersfilterkeyECMAScriptmonorepo$.extendECMAScript 3copyObject.entriestoolkites-shim APIpropertywindowdotenvObject.keysfunctionawesomesauceworkspace:*letbyteLengthnodecliUnderscoreArrayBuffer.prototype.sliceArray.prototype.includesfantasy-landrequestsetPrototypeOfcloneES5typemkdirkoreanvariablesmetadataenderfind-upelasticachefast-deep-clonetypedarrayssymbolsquoteutilitiescjkpropertiesdebugESnextstableuuidmodulemkdirpflagsprivate datatrimLeftspinnersIteratorcreateWeakSetRxJSeslint-plugindirectorysideECMAScript 2022pushassertionglobalsArray.prototype.flatArrayfses2017toStringTagmovebytedescriptionrapidSymbol.toStringTagrmwriteMicrosoftreducerbundlerstringgitignorefindLastIndexreactArray.prototype.flatMapreversedlinkinternal slotuser-streamschildequalitylocalawsECMAScript 2015httptypesafeSystem.globalnamesmatchAllmatchreusedateajaxttyoffsettimeJSON-Schemastreammulti-packageenvironmentsbindRegExp.prototype.flagstesterdataViewbinariesbrowserlistObservablessyntaxemojitypedclassnamesECMAScript 2019jshinteffect-tsworkflowObject.definePropertygraphqlutilcircularstylinghelperxmlchromiumstylefastCSScall-boundebsfpcryptothreeUint16ArraystarterurlHyBiresttypeerrorES2016groupdescriptorshasOwncss-in-jsfunctionalObjectnativeutilitygetECMAScript 2017gdprtc39256importminimalwhichtrimrandomsqsacornanimationES2023-0Streamsendpointdeterministicgettercssimmereslintcharacterhookformwidthfastclonebufferpicomatch@@toStringTagformECMAScript 2020dirECMAScript 2016serializerforEachrouteframershell__proto__loggingiamrm -frtermglobboundregularnumber6to5es-abstractredirectUint8ClampedArrayreact animationnpmignorehas-ownRxEScloudtrailfast-deep-copynopesameValueZeroestreegetPrototypeOfES7instrumentationqueryscheme-validationfullwidthemitshebangreal-timeUint32Arrayarrayvpcpolyfilldefinedatareact-testing-libraryfindupcoverageappexecutefast-copyFloat64ArrayReflect.getPrototypeOfsetwhatwgregexartesYAMLponyfillexecfileString.prototype.trimerrorinferencestyleguideownrestfulsimpledbfroms3JSONyuppipeeast-asian-widthBigInt64Arrayshamtestingindicatordayjsreadcollectioncode pointscharactersexpressiononcedynamodbkarmasyntaxerrorjseslintpluginECMAScript 6colorsperformantmake dircallbindrouterString.prototype.matchAlli18nchailoadingrfc4122Array.prototype.containsArrayBuffer#slicetypescriptECMAScript 2023eventEmittergroupBydeep-copypatchguidrmdirwalkingES2020electronshimparserobjectES6toArrayinvariantdeepclonevisualCSSStyleDeclarationjoiintrinsicviewupSymbolflatidlintio-tsECMAScript 5packagesclientcolourrssconsolenameramdafullfetchqueueMicrotaskhigher-orderenumerableclassesmanagersettingsrobusttakeasciilengthslotincludescurriedtelephonezeroprotobufcurlcommand-linehtmlgetintrinsiccalljestwaapipyyamlterminalansivalueES2018subprocessspectranspile3dnegativebrowseriebinaryserializesetImmediateprivateagentpreprocessorautoprefixeroptimizerredacttestflatMapsnshttpsFunction.prototype.namemodulesinternalObject.valuescallboundec2reworkTypeScriptyamlreversejsdiffECMAScript 7pureistanbulcall-bindbuffersstoragegatewayforksharedarraybufferconcatMapregular expressionformsextendfolderstringify.envregular-expressionglaciercodesprettyisConcatSpreadablesuperstructbundlingspeedtraverseruntimeprocesscolorsafecloudfrontfnmatchinputES2019postcssschemereducefast-clonereduxhelperscloudsearchbabeldataviewequalWeakMapstringifierform-validationselfmapvalidatorargumentes2018jsonschemarequirefeedinspectdeepcopyimmutablecorelibphonenumberwebtranspilercommander
6.10.94

10 months ago

5.10.94

10 months ago

5.10.92

10 months ago

5.10.93

10 months ago

5.10.91

10 months ago

5.10.89

11 months ago

5.10.90

10 months ago

5.10.88

11 months ago

5.10.87

11 months ago

4.10.87

11 months ago

4.10.86

11 months ago

4.9.86

11 months ago

4.9.85

11 months ago

4.9.84

11 months ago

4.8.84

11 months ago

4.8.83

11 months ago

4.8.82

11 months ago

4.8.81

11 months ago

4.8.80

11 months ago

4.8.79

11 months ago

4.8.78

11 months ago

4.8.77

11 months ago

4.8.76

11 months ago

4.8.75

11 months ago

4.8.74

11 months ago

4.8.73

11 months ago

4.8.72

11 months ago

4.8.71

11 months ago

4.8.70

11 months ago

4.8.69

11 months ago

4.8.68

11 months ago

4.8.67

11 months ago

4.8.66

11 months ago

4.8.65

11 months ago

4.8.64

11 months ago

4.7.64

11 months ago

4.7.63

12 months ago

4.7.62

12 months ago

4.7.61

12 months ago

4.7.60

12 months ago

4.7.59

12 months ago

4.7.58

12 months ago

4.7.57

12 months ago

4.7.56

12 months ago

4.7.55

12 months ago

4.7.54

12 months ago

4.6.54

12 months ago

4.6.53

12 months ago

4.6.52

12 months ago

4.6.51

12 months ago

4.6.50

12 months ago

4.6.49

12 months ago

4.6.48

12 months ago

4.5.48

12 months ago

4.5.47

12 months ago

4.5.46

12 months ago

3.5.46

1 year ago

3.5.45

1 year ago

2.5.45

1 year ago

2.5.44

1 year ago

2.5.43

1 year ago

2.5.42

1 year ago

2.5.41

1 year ago

2.5.40

1 year ago

2.5.39

1 year ago

2.5.38

1 year ago

2.5.37

1 year ago

2.5.36

1 year ago

2.5.35

1 year ago

2.5.34

1 year ago

1.5.34

1 year ago

1.5.33

1 year ago

1.5.32

1 year ago

1.5.31

1 year ago

1.5.30

1 year ago

1.5.29

1 year ago

1.5.28

1 year ago

1.5.27

1 year ago

1.5.26

1 year ago

1.5.25

1 year ago

1.5.24

1 year ago

1.5.23

1 year ago

1.5.22

1 year ago

1.5.21

1 year ago

1.4.21

1 year ago

1.3.21

1 year ago

1.3.20

1 year ago

1.3.19

1 year ago

1.3.18

1 year ago

1.3.17

1 year ago

1.3.16

1 year ago

1.3.15

1 year ago

1.3.14

1 year ago

1.3.13

1 year ago

1.3.12

1 year ago

1.3.11

1 year ago

1.3.10

1 year ago

1.3.9

1 year ago

1.3.8

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago