Skip to content

Instantly share code, notes, and snippets.

View tkharuk's full-sized avatar
🐢

Taras Kharuk tkharuk

🐢
View GitHub Profile
module.exports = (sheet) => {
const variableRegex = /\$(.+):\s+(.+);?/;
const variables = {};
sheet.split('\n').forEach((line) => {
const variable = variableRegex.exec(line);
if (!variable) return;
const name = variable[1].trim();
const value = variable[2].replace(/!default|!important/g, '').trim();
@tkharuk
tkharuk / Plural.js
Last active June 6, 2016 19:38 — forked from kjantzer/Plural.js
JavaScript: Plural - create a plural or singluar sentence based on a number
/**
* naive implementation of singular/plural sentence based on count.
* e.g.:
* var str = "Do you want to delete this? There {are|is} [num] book{s} attached."
*
* pluralize(str, 1); // => Do you want to delete this? There is 1 book attached."
* pluralize(str, 2); // => "Do you want to delete this? There are 2 books attached."
*
* @method function
*