Skip to content

Commit

Permalink
Merge branch 'angus-c:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
EvandroLG authored Feb 11, 2024
2 parents f73c527 + d8c5dd1 commit 78454c1
Show file tree
Hide file tree
Showing 36 changed files with 1,419 additions and 21,589 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 18.x]
node-version: [14.x, 16.x, 18.x]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 Angus Croll
Copyright (c) 2016-2023 Angus Croll

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
131 changes: 123 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ A [REPL](https://anguscroll.com/just) for every utility (powered by [RunKit](htt
All packages support ES module or Common JS syntax without requiring transpilation
```
// esm (node / bundler)
import clone from 'just-clone';
import clone from 'just-clone';
// esm (native browser code)
import clone from './node_modules/just-clone/index.mjs';
import clone from './node_modules/just-clone/index.mjs';
// cjs
const clone = require('just-clone');
const clone = require('just-clone');
```
## TypeScript <img src="images/ts.png" width="18"/>

Expand Down Expand Up @@ -92,6 +92,7 @@ Most utilities still work with any platform that supports ES5, but these are the
- [just-shuffle](#just-shuffle)
- [just-split](#just-split)
- [just-split-at](#just-split-at)
- [just-order-by](#just-order-by)
- [just-sort-by](#just-sort-by)
- [just-partition](#just-partition)
- [just-permutations](#just-permutations)
Expand Down Expand Up @@ -915,10 +916,6 @@ const obj3 = {a: {aa: {aaa: 2}}};
set(obj3, 'a.aa.aaa', 3); // true
obj3; // {a: {aa: {aaa: 3}}}

// don't clobber existing
const obj4 = {a: {aa: {aaa: 2}}};
set(obj4, 'a.aa', {bbb: 7}); // false

const obj5 = {a: {}};
const sym = Symbol();
set(obj5.a, sym, 7); // true
Expand Down Expand Up @@ -1342,6 +1339,124 @@ splitAt(null, 1); // throws
splitAt(undefined, 1); // throws
```
### [just-order-by](https://www.npmjs.com/package/just-order-by)
[source](https://github.com/angus-c/just/tree/master/packages/array-order-by)
[`🍦 Try it`](https://anguscroll.com/just/just-order-by)
```shell
npm install just-order-by
```
```shell
yarn add just-order-by
```
Produces a new array, sorted in given order
```js
import orderBy from 'just-order-by';

orderBy([10, 1, 5, 20, 15, 35, 30, 6, 8]); // [1, 5, 6, 8, 10, 15, 20, 30, 35]

orderBy(
[
{ user: 'fabio', details: { city: 'Milan', age: 34 } },
{ user: 'max', details: { city: 'Munich', age: 29 } },
{ user: 'zacarias', details: { city: 'Sao Paulo', age: 44 } },
{ user: 'robert', details: { city: 'Manchester', age: 28 } },
{ user: 'max', details: { city: 'Zurich', age: 38 } },
],
[
{
property(v) {
return v.details.age;
},
},
]
);

/*
[
{user: 'robert', age: 28},
{user: 'max', age: 29},
{user: 'fabio', age: 34},
{user: 'klaus', age: 38},
{user: 'zacarias', age: 44},
]
*/

orderBy(
[
{user: 'fabio', age: 34},
{user: 'max', age: 29},
{user: 'zacarias', age: 44},
{user: 'robert', age: 28},
{user: 'klaus', age: 38},
],
[
{
property: 'user',
},
]
);

/*
[
{user: 'fabio', age: 34},
{user: 'klaus', age: 38},
{user: 'max', age: 29},
{user: 'robert', age: 28},
{user: 'zacarias', age: 44},
]
*/

orderBy(
[
{ user: 'fabio', age: 34 },
{ user: 'max', age: 29 },
{ user: 'zacarias', age: 44 },
{ user: 'moris', age: 28 },
{ user: 'max', age: 38 },
],
[
{
property: 'user',
order: 'desc',
},
{
property(v) {
return v.age;
},
},
]
);

/*
[
{
user: 'zacarias',
age: 44
},
{
user: 'moris',
age: 28
},
{
user: 'max',
age: 29
},
{
user: 'max',
age: 38
},
{
user: 'fabio',
age: 34
}
]
*/
```
### [just-sort-by](https://www.npmjs.com/package/just-sort-by)
[source](https://github.com/angus-c/just/tree/master/packages/array-sort-by)
Expand Down Expand Up @@ -1441,7 +1556,7 @@ yarn add just-permutations
Returns all permutations of the length N of the elements of the given Array
```js
import permutations from 'just-array-permutations;
import permutations from 'just-permutations';

permutations([1, 2, 3]); // [[1, 2, 3], [2, 1, 3], [2, 3, 1], [1, 3, 2], [3, 1, 2], [3, 2, 1]]
permutations([]); // []
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"lerna": "2.0.0-beta.23",
"lerna": "3.20.2",
"version": "independent"
}
114 changes: 109 additions & 5 deletions md-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,114 @@
"mode(null); // throws"
]
},
"just-order-by": {
"packageName": "just-order-by",
"dir": "array-order-by",
"description": "Produces a new array, sorted in given order",
"examples": [
"import orderBy from 'just-order-by';",
"",
"orderBy([10, 1, 5, 20, 15, 35, 30, 6, 8]); // [1, 5, 6, 8, 10, 15, 20, 30, 35]",
"",
"orderBy(",
" [",
" { user: 'fabio', details: { city: 'Milan', age: 34 } },",
" { user: 'max', details: { city: 'Munich', age: 29 } },",
" { user: 'zacarias', details: { city: 'Sao Paulo', age: 44 } },",
" { user: 'robert', details: { city: 'Manchester', age: 28 } },",
" { user: 'max', details: { city: 'Zurich', age: 38 } },",
" ],",
" [",
" {",
" property(v) {",
" return v.details.age;",
" },",
" },",
" ]",
");",
"",
"/*",
"[",
" {user: 'robert', age: 28},",
" {user: 'max', age: 29},",
" {user: 'fabio', age: 34},",
" {user: 'klaus', age: 38},",
" {user: 'zacarias', age: 44},",
"]",
"*/",
"",
"orderBy(",
" [",
" {user: 'fabio', age: 34},",
" {user: 'max', age: 29},",
" {user: 'zacarias', age: 44},",
" {user: 'robert', age: 28},",
" {user: 'klaus', age: 38},",
" ],",
" [",
" {",
" property: 'user',",
" },",
" ]",
");",
"",
"/*",
"[",
" {user: 'fabio', age: 34},",
" {user: 'klaus', age: 38},",
" {user: 'max', age: 29},",
" {user: 'robert', age: 28},",
" {user: 'zacarias', age: 44},",
"]",
"*/",
"",
"orderBy(",
" [",
" { user: 'fabio', age: 34 },",
" { user: 'max', age: 29 },",
" { user: 'zacarias', age: 44 },",
" { user: 'moris', age: 28 },",
" { user: 'max', age: 38 },",
" ],",
" [",
" {",
" property: 'user',",
" order: 'desc',",
" },",
" {",
" property(v) {",
" return v.age;",
" },",
" },",
" ]",
");",
"",
"/*",
"[",
" {",
" user: 'zacarias',",
" age: 44",
" },",
" {",
" user: 'moris',",
" age: 28",
" },",
" {",
" user: 'max',",
" age: 29",
" },",
" {",
" user: 'max',",
" age: 38",
" },",
" {",
" user: 'fabio',",
" age: 34",
" }",
"]",
"*/"
]
},
"just-partition": {
"packageName": "just-partition",
"dir": "array-partition",
Expand Down Expand Up @@ -193,7 +301,7 @@
"dir": "array-permutations",
"description": "Returns all permutations of the length N of the elements of the given Array",
"examples": [
"import permutations from 'just-array-permutations;",
"import permutations from 'just-permutations';",
"",
"permutations([1, 2, 3]); // [[1, 2, 3], [2, 1, 3], [2, 3, 1], [1, 3, 2], [3, 1, 2], [3, 2, 1]]",
"permutations([]); // []",
Expand Down Expand Up @@ -1340,10 +1448,6 @@
"set(obj3, 'a.aa.aaa', 3); // true",
"obj3; // {a: {aa: {aaa: 3}}}",
"",
"// don't clobber existing",
"const obj4 = {a: {aa: {aaa: 2}}};",
"set(obj4, 'a.aa', {bbb: 7}); // false",
"",
"const obj5 = {a: {}};",
"const sym = Symbol();",
"set(obj5.a, sym, 7); // true",
Expand Down
Loading

0 comments on commit 78454c1

Please sign in to comment.