Update to v13 and add queue and completely change code

This commit is contained in:
a 2021-12-06 16:34:00 +01:00
parent dcef23d0ed
commit 55a38726a3
6706 changed files with 424137 additions and 61608 deletions

12
node_modules/human-time/Makefile generated vendored Normal file
View file

@ -0,0 +1,12 @@
CFLAGS = -Wall -Wextra -Werror -std=c99 -pedantic
BIN = human
all: $(BIN)
human: human.c
$(CC) $(CFLAGS) -o $@ $^
clean:
rm -rf $(BIN)
.PHONY: clean all

61
node_modules/human-time/README.md generated vendored Normal file
View file

@ -0,0 +1,61 @@
human
=====
show seconds in a human-readable form
Usage
-----
This repository comes with a couple of implementations of the base algorithm in
different languages. You can use any by simply dropping the logic into your
source code.
Node.JS
-------
You can install the javascript version of this with
npm install human-time
and use it like
``` js
var human = require('human-time');
human(754);
// => "12 minutes ago"
human(new Date(Date.now() + 5 * 1000))
// => "5 seconds from now"
human(new Date(Date.now() - 5 * 1000))
// => "5 seconds ago"
```
Example (C)
-----------
compile
make
run
$ ./human 65
1 minute
$ ./human 600
10 minutes
With the C example, you can optionally pass `-s` to get a suffix
$ ./human 57483
15 hours
$ ./human -s 57483
15 hours from now
$ ./human -s -57483
15 hours ago
License
-------
MIT

42
node_modules/human-time/human.bash generated vendored Executable file
View file

@ -0,0 +1,42 @@
#!/usr/bin/env bash
#
# Print a human readable timestamp to the terminal
# given a number representing seconds
#
# Author: Dave Eddy <dave@daveeddy.com>
# Date: 8/18/2014
# License: MIT
human() {
local seconds=$1
if ((seconds < 0)); then
((seconds *= -1))
fi
local times=(
$((seconds / 60 / 60 / 24 / 365)) # years
$((seconds / 60 / 60 / 24 / 30)) # months
$((seconds / 60 / 60 / 24 / 7)) # weeks
$((seconds / 60 / 60 / 24)) # days
$((seconds / 60 / 60)) # hours
$((seconds / 60)) # minutes
$((seconds)) # seconds
)
local names=(year month week day hour minute second)
local i j
for ((i = 0; i < ${#names[@]}; i++)); do
if ((${times[$i]} > 1)); then
echo "${times[$i]} ${names[$i]}s"
return
elif ((${times[$i]} == 1)); then
echo "${times[$i]} ${names[$i]}"
return
fi
done
echo '0 seconds'
}
for seconds in "$@"; do
human "$seconds"
done

88
node_modules/human-time/human.c generated vendored Normal file
View file

@ -0,0 +1,88 @@
/**
* Print a human readable timestamp to the terminal
* given a number representing seconds
*
* Author: Dave Eddy <dave@daveeddy.com>
* Date: 8/18/2014
* License: MIT
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FROM_NOW "from now"
#define AGO "ago"
static char *names[] = {"year", "month", "week", "day", "hour", "minute", "second"};
void usage(FILE *stream) {
fprintf(stream, "usage: human <seconds> ...\n");
fprintf(stream, "\n");
fprintf(stream, "options\n");
fprintf(stream, " -h print this message and exit\n");
fprintf(stream, " -s include a suffix like \"from now\" or \"ago\"\n");
}
void human(int seconds, int dosuffix) {
char *suffix = FROM_NOW;
if (seconds < 0) {
seconds *= -1;
suffix = AGO;
}
int times[] = {
seconds / 60 / 60 / 24 / 365, // years
seconds / 60 / 60 / 24 / 30, // months
seconds / 60 / 60 / 24 / 7, // weeks
seconds / 60 / 60 / 24, // days
seconds / 60 / 60, // hours
seconds / 60, // minutes
seconds, // seconds
};
for (int i = 0; i < (int)(sizeof(times) / sizeof(*times)); i++) {
if (times[i] == 0)
continue;
if (times[i] > 1)
printf("%d %ss", times[i], names[i]);
else
printf("%d %s", times[i], names[i]);
if (dosuffix)
printf(" %s", suffix);
printf("\n");
return;
}
printf("right now\n");
}
int main(int argc, char **argv) {
int dosuffix = 0;
if (argc <= 1) {
usage(stderr);
return 1;
}
// purposefully avoid getopt, because it will try to read
// negative numbers as arguments
if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) {
usage(stdout);
return 0;
}
if (strcmp(argv[1], "-s") == 0 || strcmp(argv[1], "--suffix") == 0) {
dosuffix = 1;
argc--;
argv++;
}
for (int i = 1; i < argc; i++) {
human(atoi(argv[i]), dosuffix);
}
return 0;
}

39
node_modules/human-time/human.js generated vendored Normal file
View file

@ -0,0 +1,39 @@
/**
* Print a human readable timestamp to the terminal
* given a number representing seconds
*
* Author: Dave Eddy <dave@daveeddy.com>
* Date: 8/18/2014
* License: MIT
*/
module.exports = human;
function human(seconds) {
if (seconds instanceof Date)
seconds = Math.round((Date.now() - seconds) / 1000);
var suffix = seconds < 0 ? 'from now' : 'ago';
seconds = Math.abs(seconds);
var times = [
seconds / 60 / 60 / 24 / 365, // years
seconds / 60 / 60 / 24 / 30, // months
seconds / 60 / 60 / 24 / 7, // weeks
seconds / 60 / 60 / 24, // days
seconds / 60 / 60, // hours
seconds / 60, // minutes
seconds // seconds
];
var names = ['year', 'month', 'week', 'day', 'hour', 'minute', 'second'];
for (var i = 0; i < names.length; i++) {
var time = Math.floor(times[i]);
var name = names[i];
if (time > 1)
name += 's';
if (time >= 1)
return time + ' ' + name + ' ' + suffix;
}
return '0 seconds ' + suffix;
}

26
node_modules/human-time/package.json generated vendored Normal file
View file

@ -0,0 +1,26 @@
{
"name": "human-time",
"version": "0.0.2",
"description": "show seconds in a human-readable form",
"main": "human.js",
"scripts": {
"test": "node tests/javascript.js"
},
"repository": {
"type": "git",
"url": "https://github.com/bahamas10/human.git"
},
"keywords": [
"human",
"relative",
"date",
"ago",
"time"
],
"author": "Dave Eddy <dave@daveeddy.com> (http://www.daveeddy.com)",
"license": "MIT",
"bugs": {
"url": "https://github.com/bahamas10/human/issues"
},
"homepage": "https://github.com/bahamas10/human"
}

19
node_modules/human-time/tests/javascript.js generated vendored Normal file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env node
var assert = require('assert');
var human = require('../');
[
[600, '10 minutes ago'],
[60, '1 minute ago'],
[new Date(), '0 seconds ago']
].forEach(function (o) {
var t = o[0];
var s = o[1];
var rel = human(t);
console.log('human(%j) [%j] == %j', t, rel, s);
assert.equal(rel, s);
});