2.11.114 • Published 11 months ago

@devtea2026/sunt-deserunt-est-harum v2.11.114

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

@devtea2026/sunt-deserunt-est-harum

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://@devtea2026/sunt-deserunt-est-harum.netlify.com/

Getting started

installation

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

npm install @devtea2026/sunt-deserunt-est-harum
# or
yarn add @devtea2026/sunt-deserunt-est-harum

Start using:

import {byString} from '@devtea2026/sunt-deserunt-est-harum'

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/@devtea2026/sunt-deserunt-est-harum/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/@devtea2026/sunt-deserunt-est-harum/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 '@devtea2026/sunt-deserunt-est-harum'

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 "@devtea2026/sunt-deserunt-est-harum";

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 '@devtea2026/sunt-deserunt-est-harum'

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

@devtea2026/sunt-deserunt-est-harum.netlify.com

License

MIT © Cosimo chellini

shebangFloat32Arraywarningjestcolourprivateimmutableoutputes-shim APIbrowserslistsyntaxerrortaskECMAScript 7stablerequestfastcopymergedescriptorpnpm9nativeTypeBoxcopypackage.jsonmatchAllparentchineseobjectemrexit-codeebstermcjksafestringcomparejQueryregularStreames2017collectionECMAScript 2022numbercorevarsimportexportdebugJSON-Schemafast-deep-copycore-jshashvisualwriteES3shellequaltoobjectcompile lessgroupByvpcstyled-componentstapfastifyratewritableECMAScript 2019typescripttesterbindglobjoigraphqlagentRxJSBigInt64Arraytypedarraynopequotechromeonceminimalscheme-validationes2016predictableJSONlinewrapemojiopensyntaxduplexRxzodECMAScript 2021textinternalrequireeast-asian-widthbootstrap lessregular expressionCSStraverseisConcatSpreadableinternal slotStyleSheetwafECMAScript 2015fromindicatordefinelastthrottleURLtestnegative zeroES2019mimettyInt32Arrayworkflowclass-validatorcode pointsdeep-copyconcurrencybundlerstatusassertsaccessibilitypathlessexitentriesECMAScript 2020findLastdotenvArray.prototype.findLastIndexstatelesspruneparsingidentifiersarraybufferstreams2Uint16Arrayspeedtypees6Object.entriessetImmediatebluebirdloadbalancingUnderscorecreateconsoletestingspecweakmapYAML_.extendtc39airbnbconcatcomputed-typesfast-copyvariablesRFC-6455extranegativeObject.fromEntriesArray.prototype.flattenreactfindupjshintMicrosoftwhichES7AsyncIteratorimmergdprformattrimEndobjbrowseroptionhookformproxyfolderReactiveXvestreal-timecacheframeworkdataprotobufstatecssless.jsbootstrap cssnamesboundglaciermakelrudiffReactiveExtensionshigher-orderinvariantwatchrouterregexppropertiestakeECMAScript 2017call-boundrestbreakprototypecss-in-jschannelreadablehasOwnPropertySetvalidationredux-toolkitxtermstdlibclassnamescallbackloggingbundlingsimpledbsharedinstallertoSortedmochalazyInt16ArraytrimStartreact-testing-librarydataviewrobustiteratecircularclidataViewsomeargumentstylesrmfastclonepyyamlremovepropwordbreakcloudwatchWeakSetwhatwgrmdirhardlinksbufferstypanionmapcallbusyslottelephoneES5flagscall-bindvalidatereact-hook-formArray.prototype.filtertypedlistenersregular expressionsreducesameValueZeroless cssuninstallless compilerredacttostringtagsequence0iterationArray.prototype.includescharacterseslintconfigcss nestingcolorsidleponyfillObservabledynamodbwaitECMAScript 2016searchslicewgetestreewebfindLastIndexmoveInt8ArrayIteratorpromisereducernodejsES2016extendrangeerrorenderbatchpostcss-plugindescriptioncurlmkdirsglobalforEachyupvalueclientqueueMicrotaskfind-uppackagesexpressionexecless mixinsglobalscss variablewindowsbyteURLSearchParamstouchmetadatamkdireverysymlinkrm -frmiddlewareinspectartauthenticationaccessorflatMapmake dirapollostylesheetapisuperstructsymlinksschemastreamstrimhelpersEShttpfast-deep-cloneObject.assignencryptiontapepackage managerArray.prototype.flatMapHyBistringifiersymbolssharedarraybuffer__proto__autoscalingcolorworkerCSSStyleDeclarationflattencodesbyteOffsetArray.prototype.flatappcharactermime-dbenumerableawesomesauceautoprefixermkdirpECMAScript 2018Function.prototype.namefssetterarktypelinklimitedxhrObject.getPrototypeOffilejwtlintsigtermrm -rfRegExp.prototype.flagscheckviewinterruptsqscloudsearchreduxguidmoduletypesafefast-clonereusekarmaArray.prototype.findLastdomnametypeofutilregexdeepcopydrop@@toStringTaginstallauthsetpatchPromisemulti-packageio-tsargvsideES8has-ownyamlpipeawaittimeperformanceArrayBuffer.prototype.sliceamazonmomentcommanddeepsuperagenttoStringTagconfigurableObject.definePropertygetOwnPropertyDescriptorcoercibletoolspreprocessorMaputil.inspectflatdeterministices-abstractfunctionalbrowserlistparsees7promisesasyncextensionES2020rgbimportprettyObject.valuestskoreangetterparentsuuidArray.prototype.containsunicodelanguage$.extendkeyWeakMapprotomixinsECMAScript 3keysrfc4122swfjapaneseformsdebuggerwrapescapeiamhasOwndependency managerlesscssschemedeep-clonetypedarraysdeleteshampersistentserializationurlrandomsortedasciienvironmentObjectES2018runtimeArrayBufferl10ncryptoclonefind-0protocol-buffersenvefficientreadablestreamreact-hooksstylinginferencefull-widthrestfulchromiumargparseassertcontainsirqtrimLeftelectronpolyfilllookerror-handlingstreamhooksqueuejsdomtslibbeanstalkutilitiesdayjstrimRightesES2023httpsObject.isfile systemUint32Arrayi18noptimizerthroat.enviteratorsqsphonepreserve-symlinksjsdiffmimetypeseslintplugincolumnsincludesownelmansigenericsenvironmentsbuffersignalgetoptexpressprivate dataString.prototype.matchAllECMAScript 6Uint8ClampedArraysinatraclassesarraysetPrototypeOfworkspace:*kinesisString.prototype.trimdependenciesprefixjavascriptTypeScriptdescriptorsprogressnodefigletparsercollection.es6PushelasticacherecursivestarterfpsES6intrinsic256s3readtoolkitformattingspinnerscensortoArrayshimgetintrinsicinputjasminetyped arraystringifygradients cssfluxgetperformantfullwidthratelimitquerystringlengthObject.keyswalkajvcommand-linelinuxArrayBuffer#sliceoperating-systema11yecmascriptsymbolweaksetES2021flagcloudtrailarraysECMAScript 2023functionsStreamssigintmodulesstylepushec2corsargscallboundjsxequalityconsumeeslint-pluginform-validationcloudformationlook-upfetchconcatMapSymbolqueryfsevents
2.11.112

11 months ago

2.11.113

11 months ago

2.11.114

11 months ago

2.11.108

11 months ago

2.11.109

11 months ago

2.11.110

11 months ago

2.11.111

11 months ago

2.11.107

11 months ago

2.0.37

1 year ago

2.0.38

1 year ago

2.5.47

1 year ago

2.5.48

1 year ago

2.5.49

1 year ago

2.9.89

12 months ago

2.7.66

1 year ago

2.7.65

1 year ago

2.9.88

12 months ago

2.5.46

1 year ago

2.7.69

1 year ago

2.7.68

1 year ago

2.7.67

1 year ago

2.11.101

11 months ago

2.9.92

12 months ago

2.11.102

11 months ago

2.9.93

12 months ago

2.11.103

11 months ago

2.9.90

12 months ago

2.11.104

11 months ago

2.9.91

12 months ago

2.11.105

11 months ago

2.9.96

11 months ago

2.7.73

1 year ago

2.11.106

11 months ago

2.9.97

11 months ago

2.7.72

1 year ago

2.9.94

12 months ago

2.7.71

1 year ago

2.9.95

11 months ago

2.7.70

1 year ago

2.5.58

1 year ago

2.5.59

1 year ago

2.7.77

12 months ago

2.5.54

1 year ago

2.7.76

1 year ago

2.5.55

1 year ago

2.7.75

1 year ago

2.5.56

1 year ago

2.7.74

1 year ago

2.5.57

1 year ago

2.5.50

1 year ago

2.5.51

1 year ago

2.7.79

12 months ago

2.5.52

1 year ago

2.7.78

12 months ago

2.5.53

1 year ago

2.7.80

12 months ago

2.7.84

12 months ago

2.7.83

12 months ago

2.7.82

12 months ago

2.7.81

12 months ago

2.10.97

11 months ago

2.10.98

11 months ago

2.10.99

11 months ago

2.3.45

1 year ago

2.7.88

12 months ago

2.7.87

12 months ago

2.7.86

12 months ago

2.7.85

12 months ago

2.1.38

1 year ago

2.1.39

1 year ago

2.10.101

11 months ago

2.10.100

11 months ago

2.6.59

1 year ago

2.1.41

1 year ago

1.0.22

1 year ago

2.1.42

1 year ago

2.1.40

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.29

1 year ago

2.6.60

1 year ago

1.0.28

1 year ago

2.6.61

1 year ago

1.0.27

1 year ago

2.4.46

1 year ago

1.0.33

1 year ago

2.8.88

12 months ago

1.0.32

1 year ago

2.4.45

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

2.6.62

1 year ago

1.0.37

1 year ago

2.6.63

1 year ago

1.0.36

1 year ago

2.6.64

1 year ago

1.0.35

1 year ago

2.6.65

1 year ago

1.0.34

1 year ago

2.2.44

1 year ago

2.2.45

1 year ago

2.2.42

1 year ago

2.2.43

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago