Skip to content

Instantly share code, notes, and snippets.

View ppraksa's full-sized avatar
👋

Pawel ppraksa

👋
View GitHub Profile
class Person {
constructor(name) {
this.name = name;
}
count() {
return Person.prototype.counter++;
}
}
Person.prototype.counter = 0;
class Humanoid {
constructor(name) {
this.name = name;
}
say() {
console.log(this.name);
}
}
class Human extends Humanoid {
function Device(power) {
this.power = power;
this.turnPower = function() { this.power = !this.power };
}
Device.prototype.sayHello = function() { this.power ? console.log('hello, the power is on') : ''}
function Computer(proccessor, memory) {
this.proccessor = proccessor;
this.memory = memory;
const asyncReducerFactory = (name) => {
return (state = { data: null, isLoading: false, error: null }, action) => {
switch (action.type) {
case `FETCH_${name}_STARTED`:
return { data: null, isLoading: true, error: null };
case `FETCH_${name}_SUCCESS`:
return { data: action.payload, isLoading: false, error: null };
case `FETCH_${name}_ERROR`:
return { data: null, isLoading: false, error: action.payload };
default:
// jasmine
const customMatchers = {
toBeArray: function () {
return {
compare: function (item) {
const result = {
pass: item instanceof Array,
message: ''
};
@ppraksa
ppraksa / constans.js
Created July 22, 2019 12:30
simple const implementation
function Constans(arg, value) {
return Object.defineProperty(this, arg, {
value: value,
writable: false
});
}
Constans('test', 2);
test; //2
function makeIterator(arr) {
var index = 0;
return {
next : function() {
return index < arr.length ? {
value: arr[index++],
done: false
} : {
value: arr[index],
done: true
<!DOCTYPE html>
<html lang="5">
<head>
<meta charset="UTF-8">
<title>Pierwszy komponent w React.js</title>
<script src="https://unpkg.com/react/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone/babel.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.css">
</head>
<!DOCTYPE html>
<html lang="5">
<head>
<meta charset="UTF-8">
<title>Pierwszy komponent w React.js</title>
<script src="https://unpkg.com/react/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone/babel.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.css">
</head>
Array.prototype.map2 = function(fn) {
this.forEach(function(e) {
fn.call(this,e);
});
}