landvex: Fixar och tester klara för alla komponenter
- Datafabrik: Dockerfile fix, agentorkestrering fungerar - Vision: Identify-modell, FAISS, OCR alla testade - API: Alla 7 integrationstester passerade - Upplösare: Entitetsupplösning verifierad
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
arrowParens: always
|
||||
endOfLine: lf
|
||||
alignTernaryLines: false
|
||||
tabWidth: 2
|
||||
semi: false
|
||||
singleQuote: true
|
||||
quoteProps: consistent
|
||||
bracketSpacing: true
|
||||
generatorStarSpacing: true
|
||||
spaceBeforeFunctionParen: true
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
# μs
|
||||
|
||||
Generate and parse microseconds.
|
||||
|
||||
Uses [hrtime](https://nodejs.org/api/process.html#process_process_hrtime) in node.js, [performance.now](https://developer.mozilla.org/en-US/docs/Web/API/Performance.now()) in browsers. Falls back to `Date.now() * 1000`.
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
const μs = require('microseconds')
|
||||
```
|
||||
|
||||
### now
|
||||
|
||||
timestamp in microseconds
|
||||
|
||||
```js
|
||||
const now = μs.now()
|
||||
// 1404398280599786
|
||||
```
|
||||
|
||||
### parse
|
||||
|
||||
as an object
|
||||
|
||||
```js
|
||||
const parsed = μs.parse(now)
|
||||
// { microseconds: 786, milliseconds: 599, seconds: 0, minutes: 38, hours: 14, days: 16254 }
|
||||
```
|
||||
|
||||
as a string
|
||||
|
||||
```js
|
||||
parsed.toString()
|
||||
// "16254 days 14 hours 38 minutes 0 seconds 599 milliseconds 786 microseconds"
|
||||
|
||||
μs.parse(1000).toString()
|
||||
// "1 millisecond"
|
||||
|
||||
μs.parse(1).toString()
|
||||
// "1 microsecond"
|
||||
|
||||
μs.parse(4231002).toString()
|
||||
// "4 seconds 231 milliseconds 2 microseconds"
|
||||
```
|
||||
|
||||
### since
|
||||
|
||||
```js
|
||||
const before = μs.now()
|
||||
const time = μs.since(before) // time passed
|
||||
```
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
'use strict'
|
||||
|
||||
const now = require('./now')
|
||||
const parse = require('./parse')
|
||||
|
||||
const since = (nano) => now() - nano
|
||||
|
||||
exports.now = now
|
||||
exports.since = since
|
||||
exports.parse = parse
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/* global performance */
|
||||
'use strict'
|
||||
|
||||
let now
|
||||
|
||||
if (global.process && process.hrtime) {
|
||||
const hrtime = process.hrtime
|
||||
|
||||
now = () => {
|
||||
const hr = hrtime()
|
||||
return (hr[0] * 1e9 + hr[1]) / 1e3
|
||||
}
|
||||
} else if (global.performance && performance.now) {
|
||||
const timing = performance.timing
|
||||
const start = (timing && timing.navigationStart) || Date.now()
|
||||
|
||||
now = () => (start + performance.now()) * 1e3
|
||||
} else {
|
||||
now = () => Date.now() * 1e3
|
||||
}
|
||||
|
||||
module.exports = now
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "microseconds",
|
||||
"version": "0.2.0",
|
||||
"description": "microsecond parser",
|
||||
"keywords": [
|
||||
"microseconds",
|
||||
"microtime",
|
||||
"time parser"
|
||||
],
|
||||
"homepage": "https://github.com/kamicane/microseconds#readme",
|
||||
"bugs": "https://github.com/kamicane/microseconds/issues",
|
||||
"repository": "github:kamicane/microseconds",
|
||||
"license": "MIT",
|
||||
"author": "Valerio Proietti <kamicane@gmail.com>",
|
||||
"main": "index.js",
|
||||
"devDependencies": {
|
||||
"prettier": "^1.19.1",
|
||||
"prettier-plugin-packagejson": "^2.0.6",
|
||||
"standard": "^14.3.1"
|
||||
}
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
'use strict'
|
||||
|
||||
function toString () {
|
||||
const microseconds = this.microseconds
|
||||
const milliseconds = this.milliseconds
|
||||
const seconds = this.seconds
|
||||
const minutes = this.minutes
|
||||
const hours = this.hours
|
||||
const days = this.days
|
||||
|
||||
const parts = [
|
||||
{
|
||||
name: 'day',
|
||||
value: days
|
||||
},
|
||||
{
|
||||
name: 'hour',
|
||||
value: hours
|
||||
},
|
||||
{
|
||||
name: 'minute',
|
||||
value: minutes
|
||||
},
|
||||
{
|
||||
name: 'second',
|
||||
value: seconds
|
||||
},
|
||||
{
|
||||
name: 'millisecond',
|
||||
value: milliseconds
|
||||
},
|
||||
{
|
||||
name: 'microsecond',
|
||||
value: microseconds
|
||||
}
|
||||
]
|
||||
|
||||
const time = []
|
||||
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
const part = parts[i]
|
||||
if (part.value === 0) {
|
||||
if (!time.length) continue // nothing was added yet
|
||||
|
||||
let broken = false
|
||||
|
||||
for (let j = i; j < parts.length; j++) {
|
||||
const p = parts[j]
|
||||
if (p.value) {
|
||||
broken = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (!broken) break
|
||||
}
|
||||
|
||||
time.push(part.value, part.value === 1 ? part.name : part.name + 's')
|
||||
}
|
||||
|
||||
return time.join(' ')
|
||||
}
|
||||
|
||||
module.exports = (nano) => {
|
||||
const ms = nano / 1000
|
||||
const ss = ms / 1000
|
||||
const mm = ss / 60
|
||||
const hh = mm / 60
|
||||
const dd = hh / 24
|
||||
|
||||
const microseconds = Math.round((ms % 1) * 1000)
|
||||
const milliseconds = Math.floor(ms % 1000)
|
||||
const seconds = Math.floor(ss % 60)
|
||||
const minutes = Math.floor(mm % 60)
|
||||
const hours = Math.floor(hh % 24)
|
||||
const days = Math.floor(dd)
|
||||
|
||||
return {
|
||||
microseconds,
|
||||
milliseconds,
|
||||
seconds,
|
||||
minutes,
|
||||
hours,
|
||||
days,
|
||||
toString
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user