Skip to content

Instantly share code, notes, and snippets.

function utf8ToBytes (str) {
// TODO(user): Use native implementations if/when available
var p = 0
var buf = new ArrayBuffer(str.length * 1.5) // fixme Use better algo?
var out = new Uint8Array(buf)
for (var i = 0; i < str.length; i++) {
var c = str.charCodeAt(i)
if (c < 128) {
out[p++] = c
} else if (c < 2048) {
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Checklist to debug Cyclejs app

  • Check if sinks from app components connected to main app. May use .debug('sink name') on app sinks.
  • Check if .flatten() used on stream of streams that might return results async, maybe use .compose(flattenConcurrently) instead.

Errors

  • Uncaught TypeError: s[i]._add is not a function - often means that s[i] is not a stream and you forgot to return sink.
module.exports = {
entry: {
main: [appPath("src", "index.ts"), appPath("src", "css", "styles.scss")]
},
output: {
filename: "bundle.[hash].js",
path: appPath("build")
},
devServer: {
historyApiFallback: {
/**
* To avoid null state
*/
export const NullableComponent = (
component: Component,
vnodeForNull: VNode | null = null,
componentSinks: Array<string> = ["DOM", "onion"]
) => (sources: Sources): Sinks => {
const t$ = sources.onion.state$.map(
state =>
@baranovxyz
baranovxyz / incoming$
Last active September 25, 2017 13:25
const incomingFG$ = outgoing$
.filter(isOkRequest)
.filter(({ method }) => method === "find" || method === "get")
.map(({ service, method, query, _namespace }) =>
xs.create({
start: listener => {
socket.emit(`${service}::${method}`, query, (error, response) => {
if (error) listener.error(error);
listener.next({
service,
To make servers listen to connections on all network interfaces:
--bind all