stateDiagram-v2
# Consume optional 0xFEFF char
BEGIN
# Only space characters are allowed outside root element
TEXT
function humanize(num){ | |
var ones = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', | |
'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', | |
'seventeen', 'eighteen', 'nineteen']; | |
var tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', | |
'ninety']; | |
var numString = num.toString(); | |
if (num < 0) throw new Error('Negative numbers are not supported.'); |
export EDITOR='code_wait_new_window' | |
export VISUAL='code_wait_new_window' |
(aka "Algebraic JavaScript Specification")
This project specifies the behavior of a number of methods that may optionally be added to any object. The motivation behind this is to encourage greater code reuse. You can create functions that just rely on objects having implementations of the methods below, and in doing so you can make them work with a wide variety of different, but related data structures.
For the purposes of this, spec, an "entity" is an object that has an [[equivalent]]
operation (see bellow) and may implement some or all of the other methods.
I ran this benchmark for react-native with both bluebird and promise to compare the two.
I think it's worth noting that the margin for error on this benchmark is significant. I do not attempt to claim that Promise is actually faster than Bluebird, but I do claim that the gap between them is small enough to make performance an irrelevant consideration when deciding which one to use.
Bluebird summary:
#ofRuns: 100
Average: 2501.6 ms
Median: 2354.5 ms
There are now 3 modes for versioning
UNAMBIGUOUS
- This is the default now, it will succeed only if it would make no difference which of the other two modes you chose. If the other two modes would have different outcomes, it will fail the release and force you to specify a mode.ALWAYS_INCREASING
- This mode is best for publishing applications, it also most closely resembles the behaviour of Rolling Versions before this change. It will treat the maximum published version as the current version, regardless of which branch you are releasing from. This means that each new release is guaranteed to have a higher version number than the previous release.BY_BRANCH
- This mode can be useful for libraries. It allows you to create separate branches for different major versions, and release patches to old major versions. When determining the current version, it will only consider git tags/versions that were released on the current branch. This makes it possible to release 1.0.1 after having already releas
{ | |
"attributes": {"hello": "world"}, | |
"data": {"my": "event"} | |
} |
import type { SQLQuery, Queryable } from '@databases/pg'; | |
/** | |
* A query for multiple records that has not yet been sent to the database | |
*/ | |
export interface SelectQuery<TRecord> { | |
all(): Promise<TRecord[]>; | |
orderByAsc(key: keyof TRecord): OrderedSelectQuery<TRecord>; | |
orderByDesc(key: keyof TRecord): OrderedSelectQuery<TRecord>; | |
select<TKeys extends (keyof TRecord)[]>(...fields: TKeys): SelectQuery<Pick<TRecord, TKeys[number]>>; |
function testSimpleArray(size) { | |
const results = []; | |
let queue = []; | |
for (let run = 0; run < 10000; run++) { | |
for (let i = 0; i < size; i++) { | |
queue.push(i); | |
} | |
for (let i = 0; i < size; i++) { | |
results.push(queue.shift()); | |
} |
// based on: https://github.com/brianc/node-postgres/blob/a536afb1a8baa6d584bd460e7c1286d75bb36fe3/lib/client.js#L275-L299 | |
function safeText(str: string) { | |
let hasBackslash = false; | |
let escaped = `'`; | |
for (const c of normalizeUnicode(str)) { | |
if (c === `'`) { | |
escaped += c + c; | |
} else if (c === `\\`) { | |
escaped += c + c; |