This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { enforce_immutability, LastMigrationStep, MigrationStep, generic_migrate_to_latest } from '@offirmo-private/state-utils' | |
import { LIB, SCHEMA_VERSION } from './consts' | |
import { UState, TState } from './types' | |
import { OMRSoftExecutionContext } from './sec' | |
// some hints may be needed to migrate to demo state | |
// need to export them for composing tests | |
export const MIGRATION_HINTS_FOR_TESTS: any = enforce_immutability({ | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////////////////// | |
// __dirname, __filename | |
// https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#pure-esm-package | |
// https://nodejs.org/api/globals.html | |
import * as path from 'node:path' | |
import { fileURLToPath } from 'node:url' | |
const __dirname = path.dirname(fileURLToPath(import.meta.url)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AwesomeKaleGleaner | |
function grid(seedCount) { | |
const s = Math.sqrt(seedCount) | |
const res = [ Math.floor(s) , Math.ceil(s) ] | |
if (res[0] * res[1] < seedCount ) | |
res[0]++ | |
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
State, | |
set_age, | |
} from './state.ts' | |
const state: State = { ... } | |
// currying | |
const curried1_set_age = change_age.bind(null, state) // hard to read |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- https://devdocs.io/html/element/a --> | |
<a href="https://github.com/Offirmo/offirmo-monorepo/issues" target="_blank" rel="noopener,external">report here</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import EventEmitter from 'emittery' | |
const EMITTER_EVT = 'change' | |
const emitter = new EventEmitter<{ [EMITTER_EVT]: string }>() | |
emitter.emit(EMITTER_EVT, `[in-mem]`) | |
const unbind = emitter.on(EMITTER_EVT, (src: string) => { ... }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://storybook.js.org/basics/guide-react/#write-your-stories | |
// https://storybook.js.org/basics/writing-stories/ | |
// "Component Story Format" | |
// https://storybook.js.org/docs/react/api/csf | |
import { Story, Meta } from '@storybook/react' | |
import HelloWorld, { HelloWorldProps } from '.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://react.dev/learn/typescript | |
import React from 'react' | |
// really? or import * as React from 'react' ?? https://github.com/facebook/react/pull/18102 ALSO https://www.typescriptlang.org/tsconfig/#allowSyntheticDefaultImports | |
// or not even need to import React? https://parceljs.org/recipes/react/#jsx | |
import React, { Component } from 'react' | |
// (from .d.ts) | |
type ReactNode = | |
| ReactElement |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript | |
// TODO improved enums! | |
const OPERATORS = [ '*', '/', '+', '-' ] as const | |
type Operator = typeof OPERATORS[number] | |
// reduce: need to hint when acc is not Element | |
const complex_children_count = children.reduce<number>((acc, child) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/ | |
http://bradfrost.com/blog/post/atomic-web-design/#atoms | |
zqsmm.qiniucdn.com/data/20110511083224/index.html | |
*/ | |
.block {} | |
.block__element {} | |
.block--modifier {} |