3.5.104 • Published 12 months ago

@patrtorg/ullam-eum v3.5.104

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

@patrtorg/ullam-eum

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://@patrtorg/ullam-eum.netlify.app/

Getting started

installation

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

npm install @patrtorg/ullam-eum
# or
yarn add @patrtorg/ullam-eum

Start using:

import {byString} from '@patrtorg/ullam-eum'

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/@patrtorg/ullam-eum/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/@patrtorg/ullam-eum/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 '@patrtorg/ullam-eum'

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 "@patrtorg/ullam-eum";

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 '@patrtorg/ullam-eum'

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

@patrtorg/ullam-eum.netlify.app

License

MIT © Cosimo chellini

descriptorqueueelmAsyncIteratorArray.prototype.containsespreefindjswarningArray.prototype.includesSystem.globalqueueMicrotaskcensorclass-validatorpoint-freeboundvestdropebsperformanceelbutilsvarsurlgraphqlbabelstatepruneexecirqsymbollruESWebSocketsrdsidleinterruptsBigInt64ArrayECMAScript 2020fetchposeperformantformcss variabletoolscsscolorsgradients css3servicebrowserlistString.prototype.trimjwtclassesapolloprivate dataeventEmitterIteratorgroupglobal this valueexpressioncommand-lineObject.getPrototypeOftouchFunction.prototype.namemonorepoECMAScriptjQueryPushbabel-coreansiiteratorgetPrototypeOfmetadataunicodeagentendpointmergeformsajaxmakeemrenvironmentsprettydom-testing-librarytoStringTagregexString.prototype.matchAllconstRegExp#flagscolourstylesheetsetterObject.fromEntriescryptovalidationartwritecreaterobustplugines6function.lengthdescriptorsFloat64Arrayviewpackage managerstatusfast-copyjshinthigher-orderconfigurabletacitautoscalingreduceres2016glacierquerystringworkflowhashschemaasterisksECMAScript 3JSON-Schemacss-in-jsInt32ArrayvpcoptimistidentifiersECMAScript 2015ReactiveExtensionscloudtrailelasticacheES2022negative zerocodescompile lessacornmatchimportexportauthenticationtranspilergetOwnPropertyDescriptorES7assertionruntimespeedtextcss lesseffect-tsworkspace:*SetArray.prototype.flattenpyyamloutputiepostcssfsvariables in cssInt8Arrayoperating-systemprototypestreammockingsetImmediatecurriedweakmapsortedstylelintpureselfquotemixinsregular-expressionlazyeslintconfigcryptback-endisConcatSpreadablevisualreact-componentminimalmrudirserializationconsolestreamsformatwindowargsECMAScript 2021datastructurebundlingrapidcopylesscallbackpostcss-plugin-0TypeScript__proto__asciizxserializerinternal slotobjhandlersspecjsonstructuredClonechecknegative[[Prototype]]awesomesaucepatchonceapiclassnametrimEndArray.prototype.flatMaplinkArrayuser-streamssetPrototypeOftermsequenceprefixgetintrinsicserializesnsarktypefastcopyloadingextrafront-endstylingsymlinkoptiontypedarrayargumentutilitypasswordSymbol.toStringTagfluxiamenvFloat32Arraymodulenested cssprotocol-buffersstarterbcrypts3figlethastakenopeES6arrayssidebinddataviewenvironmentES2018consumejestRxJSES2015es2015fixed-widthxhrbusyWebSocketprivatees5ArrayBuffer.prototype.sliceflagsArray.prototype.filtersharedarraycolumnsrequiresuperstructwindowslinuxreadUnderscorecachecallbindless mixinsstyleguidecallvalidaterequestbootstrap lessignoreECMAScript 2019.gitignorefunctionswaapishamiterationES2019framertypeerrorlistenersflatMapwhichshellfastramdaReflect.getPrototypeOfdirectoryprogresschromeswfsqsinferencecolumnmobilerangeerrorenumerabledomES2017cloudfrontschemees8enderlibphonenumberiteratesliceglobalsECMAScript 6Array.prototype.findLastphoneflagomiteast-asian-widthexit-codeCSSes7ES3settelephonemkdirptypedparserECMAScript 2023toolkitassertserrorbufferswafajvl10nfast-clonetc39ArrayBuffer#slicetestequalworkerservereslintpredictableoffsetchannelinstallerpromisedefinecall-boundzerotimeutilhelpersform-validationBigUint64Arraykoreancomputed-typesES2016japanesespinnerutilitiesmkdirslocalforEachcollectionjsonschemaRegExp.prototype.flagsreact posereact animationnpmignoreUint32Arraywgetslotdeep-copydeepcloneresolvenameswhatwghandlerdescriptionstylesECMAScript 2018amazonclientpositivesyntaxtypestrimLeftgdpruninstallconcatMapassertvariablessubprocesslasttrimRightsomecss nestingsignalcollection.es6lockfilepreserve-symlinksArrayBuffersortdateexecfilergbmanagerponyfillObject.assignReactiveXfastifyreduceasyncexecuteMicrosoftdiffpropertiescommandprotoforkPromiseelectronwidthdayjspushletObjectglobalThisaccessibilitylogshrinkwrapES8hasOwnPropertytoArrayquerydynamodbcjkargvstringifyhasOwnwalkpolyfillless compilerrandomgenericsfast-deep-clonettyspawnfromgroupByECMAScript 2022certificatesjoixtermtrimStartflattenSymbolcloudsearchbrowserslistcolorECMAScript 7error-handling$.extendregexptypescripttrimincludesmkdirismatchesassignvarcompilerbyteOffsetformattingreadablestreamintrinsicfunctionaldeep-cloneescapetsrulesbootstrap csscharacterpropinstallES5bddESnextmomentjsxbyteLengthesJSONawsfpsexpressindicatorproxysymbolstyped arraybuffermockdataViewbeanstalkkinesisgethas-ownownuploadreal-timeroutingmulti-packagefileentriesi18ntypeofgetterzodObject.entriessesrecursivegitignoreemitairbnbgesturesfunctionObservablesdefinePropertyimmerjson-schema-validatorloadbalancingECMAScript 2016sigintimmutablestringECMAScript 5bundlermoveglobal objectfnmatchautoprefixerUint8ClampedArraybytelanguageec2sigtermfindLastIndexdependenciesWeakMapflata11ytoobjectmapchromiumconfighookscontainssafeStreamkeysUint16ArrayTypeBoxeventDispatcherencryptionfile systemreact-hooksvaluetypedarrayses-shim APIObservablecurlcorebannerpathstringifierfindLastdeepcopycore-jsmodulespackage.jsonObject.valuesjsdiffinternalbinarytranspilesharedarraybufferwaitprocessclassnamesinvariantjson-schema-validationcircularWeakSetincloudformation6to5coercibleURLSearchParamstransportwritablejsdomlivenumber256deepreduxsimpledbredirecttestingarraybufferchildmacosstoragegatewayglobyupTypedArraysameValueZeroStyleSheetcall-bindYAMLyamldragHyBidotenvreadablespringgetoptharmonypreprocessorstatelesstslibhttpreactdeterministicprotobufsignedfpObject.isaccessorredactnodeloggingtesterefficienthookformjson-schemasettingseslint-plugincloudwatchinputastES2021Int16Arrayhotextendchaipopmotiondependency managerfantasy-landvalidshebanglesscssroutetddglobalcloneoptimizertraverseutil.inspectreact-testing-librarypnpm9typesafe@@toStringTages2017nativejavascriptinspecthttpsimportnodejsbinexitconcatfullopensslUint8Arraynpmhelperweaksetreplayes-shimsmake dirlocationhardlinkskeychineseobjectsuperagentqsestreeroute53persistent3dcallboundECMAScript 2017Object.keysio-tsterminalshimStreamsanimationless.jsgradients css_.extendreact-hook-formArray.prototype.flatsyntaxerrorregular expressionredux-toolkitregularremoveeveryeslintpluginecmascriptmatchAllfull-widthclispinnersRFC-6455less cssvaluesmapreduceObject.definePropertyfilterbinariestypanionMapstyled-componentses2018fast-deep-copypackagesfastcloneloggerscheme-validationdatapinofullwidthES2020deletetostringtagequalitycommandernameparsestablees-abstractURLlengthauththreeeventsproperty
3.5.102

12 months ago

3.5.103

12 months ago

3.5.104

12 months ago

3.5.101

12 months ago

3.5.100

12 months ago

3.5.99

12 months ago

3.5.98

1 year ago

3.4.98

1 year ago

3.4.97

1 year ago

3.4.96

1 year ago

3.4.95

1 year ago

3.4.94

1 year ago

3.4.93

1 year ago

3.4.92

1 year ago

3.4.91

1 year ago

3.4.90

1 year ago

3.4.89

1 year ago

3.4.88

1 year ago

3.4.87

1 year ago

3.4.86

1 year ago

3.4.85

1 year ago

3.4.84

1 year ago

3.4.83

1 year ago

3.3.83

1 year ago

3.2.83

1 year ago

3.2.82

1 year ago

3.2.81

1 year ago

3.2.80

1 year ago

3.2.79

1 year ago

3.2.78

1 year ago

3.2.77

1 year ago

3.2.76

1 year ago

3.2.75

1 year ago

3.2.74

1 year ago

3.2.73

1 year ago

3.2.72

1 year ago

3.2.71

1 year ago

3.2.70

1 year ago

3.2.69

1 year ago

3.2.68

1 year ago

3.2.67

1 year ago

3.2.66

1 year ago

3.2.65

1 year ago

3.2.64

1 year ago

3.2.63

1 year ago

3.2.62

1 year ago

3.2.61

1 year ago

3.2.60

1 year ago

3.2.59

1 year ago

3.1.59

1 year ago

3.1.58

1 year ago

3.1.57

1 year ago

3.1.56

1 year ago

3.1.55

1 year ago

3.1.54

1 year ago

3.1.53

1 year ago

3.1.52

1 year ago

3.1.51

1 year ago

3.1.50

1 year ago

3.1.49

1 year ago

3.1.48

1 year ago

3.1.47

1 year ago

3.1.46

1 year ago

3.1.45

1 year ago

3.1.44

1 year ago

3.1.43

1 year ago

3.1.42

1 year ago

3.1.41

1 year ago

3.1.40

1 year ago

3.1.39

1 year ago

3.1.38

1 year ago

3.1.37

1 year ago

3.1.36

1 year ago

3.1.35

1 year ago

3.1.34

1 year ago

3.1.33

1 year ago

3.1.32

1 year ago

3.1.31

1 year ago

3.1.30

1 year ago

3.1.29

1 year ago

3.0.29

1 year ago

3.0.28

1 year ago

3.0.27

1 year ago

3.0.26

1 year ago

3.0.25

1 year ago

3.0.24

1 year ago

3.0.23

1 year ago

3.0.22

1 year ago

2.0.22

1 year ago

2.0.21

1 year ago

2.0.20

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

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago