Skip to content

Instantly share code, notes, and snippets.

Simon Sturmer sstur

Block or report user

Report or block sstur

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View index.js
// node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _helperPluginUtils() {
@sstur
sstur / package.json
Created Feb 18, 2019 — forked from darcien/package.json
Jest configuration for RN with expo
View package.json
{
"jest": {
"preset": "jest-expo",
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js",
"^.+\\.tsx?$": "ts-jest"
},
"testMatch": [
"**/__tests__/**/*.ts?(x)",
"**/?(*.)+(spec|test).ts?(x)"
@sstur
sstur / promise-streams.js
Last active Feb 13, 2018
[RFC] Node Streams to Promise-based Streams
View promise-streams.js
// @flow
import fs from 'fs';
import {join} from 'path';
async function main() {
let filePath = join(__dirname, '../assets/image.jpg');
// The first one uses Promise-based readable stream.
await getFileSizeOne(filePath);
// The second one uses "for await" async iterator approach.
await getFileSizeTwo(filePath);
@sstur
sstur / asyncAwait.js
Last active Feb 21, 2017 — forked from oshimayoan/asyncAwait.js
Fetching github users, orgs, and repos and print it.
View asyncAwait.js
// @flow
/* global fetch */
/* eslint-disable babel/no-await-in-loop */
type JSONData = null | string | number | boolean | {[key: string]: JSONData} | Array<JSONData>;
function handleResponseJSON(response: Response): Promise<JSONData> {
return response.json();
}
View App-Fetching.js
import React from 'react';
import './App.css';
class App extends React.Component {
constructor() {
super();
this.state = {
error: null,
data: null,
};
View http-server.js
const http = require('http');
let server = http.createServer();
server.on('request', (request, response) => {
let {method, url, headers} = request;
console.log(`Received ${method} request for "${url}".`);
for (let headerName of Object.keys(headers)) {
let headerValue = headers[headerName];
View createDate-variable-args.js
// ES5
var getBound = Function.prototype.apply.bind(Function.prototype.bind)
function createDate() {
for (var i = 0, length = arguments.length, args = new Array(length + 1); i < length; i++) {
args[i + 1] = arguments[i];
}
var BoundDate = getBound(Date, args);
return new BoundDate();
View StatefulRichTextEditor.js
import RichTextEditor from 'react-rte';
import React from 'react';
class StatefulRichTextEditor {
constructor() {
this.state = {
value: RichTextEditor.createEmptyValue(),
};
}
@sstur
sstur / MyArray.js
Created Jul 7, 2015
Extend (subclass) native Array
View MyArray.js
function MyArray() {
var array = [];
if (arguments.length) {
array.push.apply(array, arguments);
}
// note: use `Object.setPrototypeOf` instead of __proto__ to be truly standards-compliant
array.__proto__ = MyArray.prototype;
return array;
}
@sstur
sstur / MyDate.js
Last active Aug 29, 2015
Extend (subclass) native Date
View MyDate.js
function MyDate(a, b, c, d, e, f, g) {
var date;
switch (arguments.length) {
case 0:
date = new Date();
break;
case 1:
date = new Date(a);
break;
case 2:
You can’t perform that action at this time.