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
// doesn't work w/o this interface creation | |
require('readline').createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
// stop process input | |
process.stdin.pause(); | |
// read from stdin 10 times per second to check if ctrl+c pressed |
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
const EXTENSION_TYPE = { | |
0x01: 'PlainText', | |
0xF9: 'GraphicControl', | |
0xFE: 'Comment', | |
0xFF: 'Application' | |
}; | |
/** | |
* Returns total length of data blocks sequence | |
* |
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
const csstree = require("css-tree"); | |
const cssDefinitions = ["color"]; | |
const ast = csstree.parse(` | |
.some-selector { | |
color: black; | |
border: 1px solid #fff; | |
} | |
`, { parseValue: false }); | |
csstree.walk(ast, { |
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
const cssTree = require("css-tree@1.0.0-alpha.29"); | |
function getSelectorParent(selector) { | |
const selectorAst = cssTree.parse(selector, { context: 'selector' }); | |
// solution #1 | |
selectorAst.children.prevUntil(selectorAst.children.tail, (node, item, list) => { | |
list.remove(item); | |
return node.type === 'Combinator' || node.type === 'WhiteSpace'; | |
}); |
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
const cssTree = require("css-tree@1.0.0-alpha.29"); | |
function getSelectorParent(selector) { | |
const selectorAst = cssTree.parse(selector, { context: 'selector' }); | |
// solution #1 | |
// selectorAst.children.prevUntil(selectorAst.children.tail, (node, item, list) => { | |
// list.remove(item); | |
// return node.type === 'Combinator' || node.type === 'WhiteSpace'; | |
// }); | |
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
const cssTree = require("css-tree@1.0.0-alpha.29"); | |
function getSelectorParent(selector) { | |
const selectorAst = cssTree.parse(selector, { context: 'selector' }); | |
// solution #1 | |
// selectorAst.children.prevUntil(selectorAst.children.tail, (node, item, list) => { | |
// list.remove(item); | |
// return node.type === 'Combinator' || node.type === 'WhiteSpace'; | |
// }); | |
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
// UPDATE: you can use ready to use package prop-types-definition | |
// https://github.com/avito-tech/prop-types-definition | |
module.exports = function(content) { | |
return content + ` | |
(function(ReactPropTypes) { | |
function unwrapValueItem(value) { | |
if (value) { | |
if (typeof value.getTypeDefinition === 'function') { | |
return value.getTypeDefinition(); |
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
const pngSignature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]); | |
const hashKey = 'react-snapshot-hash'; | |
const crcTable = []; | |
const initialCrc = 0xffffffff; | |
for (let n = 0; n < 256; n++) { | |
let c = n; | |
for (let k = 0; k < 8; k++) { | |
if (c & 1) { |
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
const csstree = require('css-tree'); | |
const ast1 = csstree.parse('.a { color: red }', { | |
filename: './a.css', | |
positions: true | |
}); | |
const ast2 = csstree.parse('.b { color: red }', { | |
filename: './b.css', | |
positions: true | |
}); |
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
const csstree = require('css-tree'); | |
const data = require('mdn-data/css/properties.json'); | |
Object.keys(data).forEach(name => { | |
const prop = data[name]; | |
if (Array.isArray(prop.initial)) { | |
return; | |
} |
NewerOlder