mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 05:13:33 -06:00
Initial commit
This commit is contained in:
2
node_modules/pipetteur/.coveralls.yml
generated
vendored
Normal file
2
node_modules/pipetteur/.coveralls.yml
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
service_name: travis-ci
|
||||
repo_token: GCx0wlRbg5PGnG94TC7TP87RqjIxRh4dc
|
19
node_modules/pipetteur/.editorconfig
generated
vendored
Normal file
19
node_modules/pipetteur/.editorconfig
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
; EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
; top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
; Unix style line endings
|
||||
end_of_line = lf
|
||||
|
||||
; Always end file on newline
|
||||
insert_final_newline = true
|
||||
|
||||
; Indentation
|
||||
indent_style = space
|
||||
indent_size = 4
|
2
node_modules/pipetteur/.jshintignore
generated
vendored
Normal file
2
node_modules/pipetteur/.jshintignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
coverage
|
95
node_modules/pipetteur/.jshintrc
generated
vendored
Normal file
95
node_modules/pipetteur/.jshintrc
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
{
|
||||
// JSHint Default Configuration File (as on JSHint website)
|
||||
// See http://jshint.com/docs/ for more details
|
||||
|
||||
"maxerr" : 50, // {int} Maximum error before stopping
|
||||
|
||||
// Enforcing
|
||||
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
|
||||
"camelcase" : false, // true: Identifiers must be in camelCase
|
||||
"curly" : true, // true: Require {} for every new block or scope
|
||||
"eqeqeq" : true, // true: Require triple equals (===) for comparison
|
||||
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
|
||||
"immed" : true, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
|
||||
"indent" : 4, // {int} Number of spaces to use for indentation
|
||||
"latedef" : true, // true: Require variables/functions to be defined before being used
|
||||
"newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()`
|
||||
"noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
|
||||
"noempty" : true, // true: Prohibit use of empty blocks
|
||||
"nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment)
|
||||
"plusplus" : true, // true: Prohibit use of `++` & `--`
|
||||
"quotmark" : "single", // Quotation mark consistency:
|
||||
// false : do nothing (default)
|
||||
// true : ensure whatever is used is consistent
|
||||
// "single" : require single quotes
|
||||
// "double" : require double quotes
|
||||
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
|
||||
"unused" : true, // true: Require all defined variables be used
|
||||
"strict" : false, // true: Requires all functions run in ES5 Strict Mode
|
||||
"trailing" : true, // true: Prohibit trailing whitespaces
|
||||
"maxparams" : false, // {int} Max number of formal params allowed per function
|
||||
"maxdepth" : false, // {int} Max depth of nested blocks (within functions)
|
||||
"maxstatements" : false, // {int} Max number statements per function
|
||||
"maxcomplexity" : false, // {int} Max cyclomatic complexity per function
|
||||
"maxlen" : false, // {int} Max number of characters per line
|
||||
|
||||
// Relaxing
|
||||
"asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
|
||||
"boss" : false, // true: Tolerate assignments where comparisons would be expected
|
||||
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
|
||||
"eqnull" : false, // true: Tolerate use of `== null`
|
||||
"es5" : false, // true: Allow ES5 syntax (ex: getters and setters)
|
||||
"esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`)
|
||||
// (ex: `for each`, multiple try/catch, function expression…)
|
||||
"evil" : false, // true: Tolerate use of `eval` and `new Function()`
|
||||
"expr" : false, // true: Tolerate `ExpressionStatement` as Programs
|
||||
"funcscope" : false, // true: Tolerate defining variables inside control statements"
|
||||
"globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
|
||||
"iterator" : false, // true: Tolerate using the `__iterator__` property
|
||||
"lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
|
||||
"laxbreak" : false, // true: Tolerate possibly unsafe line breakings
|
||||
"laxcomma" : false, // true: Tolerate comma-first style coding
|
||||
"loopfunc" : false, // true: Tolerate functions being defined in loops
|
||||
"multistr" : false, // true: Tolerate multi-line strings
|
||||
"proto" : false, // true: Tolerate using the `__proto__` property
|
||||
"scripturl" : false, // true: Tolerate script-targeted URLs
|
||||
"smarttabs" : false, // true: Tolerate mixed tabs/spaces when used for alignment
|
||||
"shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
|
||||
"sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
|
||||
"supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
|
||||
"validthis" : false, // true: Tolerate using this in a non-constructor function
|
||||
|
||||
// Environments
|
||||
"browser" : true, // Web Browser (window, document, etc)
|
||||
"couch" : false, // CouchDB
|
||||
"devel" : true, // Development/debugging (alert, confirm, etc)
|
||||
"dojo" : false, // Dojo Toolkit
|
||||
"jquery" : true, // jQuery
|
||||
"mootools" : false, // MooTools
|
||||
"node" : false, // Node.js
|
||||
"nonstandard" : true, // Widely adopted globals (escape, unescape, etc)
|
||||
"prototypejs" : false, // Prototype and Scriptaculous
|
||||
"rhino" : false, // Rhino
|
||||
"worker" : false, // Web Workers
|
||||
"wsh" : false, // Windows Scripting Host
|
||||
"yui" : false, // Yahoo User Interface
|
||||
|
||||
// Legacy
|
||||
"nomen" : false, // true: Prohibit dangling `_` in variables
|
||||
"onevar" : true, // true: Allow only one `var` statement per function
|
||||
"passfail" : false, // true: Stop on first error
|
||||
"white" : true, // true: Check against strict whitespace and indentation rules
|
||||
|
||||
// Custom Globals
|
||||
"predef" : [ // additional predefined global variables
|
||||
"process",
|
||||
"module",
|
||||
"exports",
|
||||
"require",
|
||||
"define",
|
||||
"__dirname",
|
||||
"__filename",
|
||||
"describe",
|
||||
"it"
|
||||
]
|
||||
}
|
2
node_modules/pipetteur/.npmignore
generated
vendored
Normal file
2
node_modules/pipetteur/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
coverage
|
15
node_modules/pipetteur/.travis.yml
generated
vendored
Normal file
15
node_modules/pipetteur/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
node_js:
|
||||
- '4'
|
||||
- '3'
|
||||
- '2'
|
||||
- '1'
|
||||
- '0.12'
|
||||
- '0.10'
|
||||
|
||||
script: "npm run-script travis"
|
||||
after_success: "<coverage/lcov.info ./node_modules/coveralls/bin/coveralls.js"
|
87
node_modules/pipetteur/README.md
generated
vendored
Normal file
87
node_modules/pipetteur/README.md
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
Pipetteur
|
||||
=========
|
||||
[](http://badge.fury.io/js/pipetteur)
|
||||
[](https://travis-ci.org/Munter/pipetteur)
|
||||
[](https://coveralls.io/r/Munter/pipetteur)
|
||||
[](https://david-dm.org/Munter/pipetteur)
|
||||
|
||||
A module to find all color syntax substrings in a string with their offsets and their color instance.
|
||||
It's an automated eyedropper tool for your text, css, html, svg etc.
|
||||
|
||||
It takes a single string argument and returns an array of objects like this:
|
||||
|
||||
``` javascript
|
||||
{
|
||||
match: '#FF0000', // The found color match
|
||||
index: 0, // Zero based index of the match in the string
|
||||
line: 1, // 1-based line number
|
||||
column: 1, // 1-based column number
|
||||
color: <one-color>
|
||||
}
|
||||
```
|
||||
|
||||
The color object returned is an instance of [one-color](https://github.com/One-com/one-color/#usage), giving you instant access to highlevel color manipulation without having to think about color space conversions.
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
``` javascript
|
||||
var pipetteur = require('pipetteur');
|
||||
|
||||
pipetteur('Roses are rgb(255,0,0), violet are #00f');
|
||||
|
||||
[ { index: 10,
|
||||
line: 1,
|
||||
column: 11,
|
||||
match: 'rgb(255,0,0)',
|
||||
color:
|
||||
{ _red: 1,
|
||||
_green: 0,
|
||||
_blue: 0,
|
||||
_alpha: 1 } },
|
||||
{ index: 24,
|
||||
line: 1,
|
||||
column: 25,
|
||||
match: 'violet',
|
||||
color:
|
||||
{ _red: 0.9333333333333333,
|
||||
_green: 0.5098039215686274,
|
||||
_blue: 0.9333333333333333,
|
||||
_alpha: 1 } },
|
||||
{ index: 35,
|
||||
line: 1,
|
||||
column: 36,
|
||||
match: '#00f',
|
||||
color:
|
||||
{ _red: 0,
|
||||
_green: 0,
|
||||
_blue: 1,
|
||||
_alpha: 1 } } ]
|
||||
```
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Peter Müller <munter@fumle.dk>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
100
node_modules/pipetteur/package.json
generated
vendored
Normal file
100
node_modules/pipetteur/package.json
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"pipetteur@^2.0.0",
|
||||
"/Users/pmarsceill/_projects/just-the-docs/node_modules/colorguard"
|
||||
]
|
||||
],
|
||||
"_from": "pipetteur@>=2.0.0 <3.0.0",
|
||||
"_id": "pipetteur@2.0.3",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/pipetteur",
|
||||
"_nodeVersion": "4.4.4",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-16-east.internal.npmjs.com",
|
||||
"tmp": "tmp/pipetteur-2.0.3.tgz_1465991578021_0.3095195039641112"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "munter@fumle.dk",
|
||||
"name": "munter"
|
||||
},
|
||||
"_npmVersion": "3.9.2",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "pipetteur",
|
||||
"raw": "pipetteur@^2.0.0",
|
||||
"rawSpec": "^2.0.0",
|
||||
"scope": null,
|
||||
"spec": ">=2.0.0 <3.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/colorguard"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/pipetteur/-/pipetteur-2.0.3.tgz",
|
||||
"_shasum": "1955760959e8d1a11cb2a50ec83eec470633e49f",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "pipetteur@^2.0.0",
|
||||
"_where": "/Users/pmarsceill/_projects/just-the-docs/node_modules/colorguard",
|
||||
"author": {
|
||||
"email": "munter@fumle.dk",
|
||||
"name": "Peter Müller"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Munter/pipetteur/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"onecolor": "^3.0.4",
|
||||
"synesthesia": "^1.0.1"
|
||||
},
|
||||
"description": "A function to extract any colors from a string",
|
||||
"devDependencies": {
|
||||
"coveralls": "^2.11.9",
|
||||
"istanbul": "^0.4.3",
|
||||
"jshint": "^2.9.2",
|
||||
"mocha": "^2.5.3",
|
||||
"mocha-lcov-reporter": "^1.2.0",
|
||||
"unexpected": "^10.13.3"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "1955760959e8d1a11cb2a50ec83eec470633e49f",
|
||||
"tarball": "https://registry.npmjs.org/pipetteur/-/pipetteur-2.0.3.tgz"
|
||||
},
|
||||
"gitHead": "c7c66bb8c023721628dbaccaa6f294157fdc4226",
|
||||
"homepage": "https://github.com/Munter/pipetteur",
|
||||
"keywords": [
|
||||
"color",
|
||||
"extract",
|
||||
"hex",
|
||||
"hsl",
|
||||
"hsv",
|
||||
"match",
|
||||
"names",
|
||||
"rbg",
|
||||
"string"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "pipetteur.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "munter",
|
||||
"email": "munter@fumle.dk"
|
||||
}
|
||||
],
|
||||
"name": "pipetteur",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Munter/pipetteur.git"
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "istanbul cover _mocha -- --reporter dot",
|
||||
"lint": "jshint .",
|
||||
"test": "npm run lint && mocha",
|
||||
"travis": "npm run lint && npm run coverage"
|
||||
},
|
||||
"version": "2.0.3"
|
||||
}
|
32
node_modules/pipetteur/pipetteur.js
generated
vendored
Normal file
32
node_modules/pipetteur/pipetteur.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
var synesthesia = require('synesthesia');
|
||||
var color = require('onecolor');
|
||||
|
||||
var pipetteur = function (str) {
|
||||
if (typeof str !== 'string') {
|
||||
throw new Error('pipetteur: Expected string input, got ' + typeof str);
|
||||
}
|
||||
|
||||
var matches = [],
|
||||
match,
|
||||
lines;
|
||||
|
||||
// Match colors incrementally
|
||||
while ((match = synesthesia.all.exec(str)) !== null) {
|
||||
lines = str.slice(0, match.index).split('\n');
|
||||
|
||||
matches.push({
|
||||
index: match.index,
|
||||
line: lines.length,
|
||||
column: lines[lines.length - 1].length + 1,
|
||||
match: match[0],
|
||||
color: color(match[0])
|
||||
});
|
||||
}
|
||||
|
||||
// Reset search indexes
|
||||
synesthesia.all.lastIndex = 0;
|
||||
|
||||
return matches;
|
||||
};
|
||||
|
||||
module.exports = pipetteur;
|
21
node_modules/pipetteur/test/errors.js
generated
vendored
Normal file
21
node_modules/pipetteur/test/errors.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
var expect = require('unexpected');
|
||||
var pipetteur = require('../pipetteur');
|
||||
|
||||
describe('Error handling', function () {
|
||||
it('should throw on invalid input', function (done) {
|
||||
var types = [
|
||||
undefined,
|
||||
null,
|
||||
true,
|
||||
0,
|
||||
[],
|
||||
{},
|
||||
function () { return; }
|
||||
];
|
||||
expect(types, 'to be an array whose items satisfy', function (type) {
|
||||
expect(pipetteur.bind(null, type), 'to throw');
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
232
node_modules/pipetteur/test/hex.js
generated
vendored
Normal file
232
node_modules/pipetteur/test/hex.js
generated
vendored
Normal file
@@ -0,0 +1,232 @@
|
||||
var expect = require('unexpected');
|
||||
var pipetteur = require('../pipetteur');
|
||||
|
||||
describe('Hex match', function () {
|
||||
it('should match a set of valid 6-char hex strings', function (done) {
|
||||
var hexes = [
|
||||
'#000000',
|
||||
'#FFFFFF',
|
||||
'#ffffff',
|
||||
'#123456',
|
||||
'#abcdef',
|
||||
'#ABCDEF',
|
||||
'#fedcba',
|
||||
'#FEDCBA'
|
||||
];
|
||||
|
||||
expect(hexes, 'to be an array whose items satisfy', function (hex) {
|
||||
var matches = pipetteur(hex);
|
||||
|
||||
return expect(matches, 'to satisfy', [
|
||||
{
|
||||
line: 1,
|
||||
column: 1,
|
||||
index: 0,
|
||||
match: hex,
|
||||
color: function (color) {
|
||||
expect(color, 'to satisfy', {
|
||||
isColor: true,
|
||||
});
|
||||
|
||||
expect(color.hex(), 'to be', hex.toLowerCase());
|
||||
}
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should match a set of valid 3-char hex strings', function (done) {
|
||||
var hexes = [
|
||||
'#000',
|
||||
'#FFF',
|
||||
'#fff',
|
||||
'#123',
|
||||
'#abc',
|
||||
'#ABC',
|
||||
'#cba',
|
||||
'#CBA'
|
||||
];
|
||||
|
||||
expect(hexes, 'to be an array whose items satisfy', function (hex) {
|
||||
var matches = pipetteur(hex);
|
||||
|
||||
return expect(matches, 'to satisfy', [
|
||||
{
|
||||
line: 1,
|
||||
column: 1,
|
||||
index: 0,
|
||||
match: hex,
|
||||
color: {
|
||||
isColor: true
|
||||
}
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should match a set of valid 6-char hex substrings', function (done) {
|
||||
var hexes = [
|
||||
{
|
||||
string: 'foo #000000 bar',
|
||||
hex: '#000000',
|
||||
index: 4
|
||||
},
|
||||
{
|
||||
string: 'one, two, #FFFFFF, three',
|
||||
hex: '#FFFFFF',
|
||||
index: 10
|
||||
},
|
||||
{
|
||||
string: 'hvid (#ffffff) er pænt',
|
||||
hex: '#ffffff',
|
||||
index: 6
|
||||
},
|
||||
{
|
||||
string: '#123456 are numbers',
|
||||
hex: '#123456',
|
||||
index: 0
|
||||
},
|
||||
{
|
||||
string: 'alphabet song: #abcdef',
|
||||
hex: '#abcdef',
|
||||
index: 15
|
||||
},
|
||||
{
|
||||
string: '#alphab et #ABCDEF gehijkl',
|
||||
hex: '#ABCDEF',
|
||||
index: 11
|
||||
},
|
||||
{
|
||||
string: 'background:#fedcba',
|
||||
hex: '#fedcba',
|
||||
index: 11
|
||||
},
|
||||
{
|
||||
string: '$color=#FEDCBA',
|
||||
hex: '#FEDCBA',
|
||||
index: 7
|
||||
}
|
||||
];
|
||||
|
||||
expect(hexes, 'to be an array whose items satisfy', function (obj) {
|
||||
var matches = pipetteur(obj.string);
|
||||
|
||||
return expect(matches, 'to satisfy', [
|
||||
{
|
||||
line: 1,
|
||||
column: obj.index + 1,
|
||||
index: obj.index,
|
||||
match: obj.hex,
|
||||
color: {
|
||||
isColor: true
|
||||
}
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should match a set of valid 3-char hex substrings', function (done) {
|
||||
var hexes = [
|
||||
{
|
||||
string: 'foo #000 bar',
|
||||
hex: '#000',
|
||||
index: 4
|
||||
},
|
||||
{
|
||||
string: 'one, two, #FFF, three',
|
||||
hex: '#FFF',
|
||||
index: 10
|
||||
},
|
||||
{
|
||||
string: 'hvid (#fff) er pænt',
|
||||
hex: '#fff',
|
||||
index: 6
|
||||
},
|
||||
{
|
||||
string: '#123 are numbers',
|
||||
hex: '#123',
|
||||
index: 0
|
||||
},
|
||||
{
|
||||
string: 'alphabet song: #abc',
|
||||
hex: '#abc',
|
||||
index: 15
|
||||
},
|
||||
{
|
||||
string: '#alphab et #ABC gehijkl',
|
||||
hex: '#ABC',
|
||||
index: 11
|
||||
},
|
||||
{
|
||||
string: 'background:#fed',
|
||||
hex: '#fed',
|
||||
index: 11
|
||||
},
|
||||
{
|
||||
string: '$color=#FED',
|
||||
hex: '#FED',
|
||||
index: 7
|
||||
}
|
||||
];
|
||||
|
||||
expect(hexes, 'to be an array whose items satisfy', function (obj) {
|
||||
var matches = pipetteur(obj.string);
|
||||
|
||||
return expect(matches, 'to satisfy', [
|
||||
{
|
||||
line: 1,
|
||||
column: obj.index + 1,
|
||||
index: obj.index,
|
||||
match: obj.hex,
|
||||
color: {
|
||||
isColor: true
|
||||
}
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should not match non-hex strings', function (done) {
|
||||
var hexes = [
|
||||
'#',
|
||||
'#0',
|
||||
'#00',
|
||||
'#0000',
|
||||
'#00000',
|
||||
'#0000000'
|
||||
];
|
||||
|
||||
expect(hexes, 'to be an array whose items satisfy', function (hex) {
|
||||
var matches = pipetteur(hex);
|
||||
|
||||
expect(matches, 'to be an empty array');
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should match multiple colors in the same string', function (done) {
|
||||
var strings = [
|
||||
'#000000 #ffffff',
|
||||
'#123456 and #234567',
|
||||
'First: #123, Second: #fff000',
|
||||
'Unlikely combination: #123#321'
|
||||
];
|
||||
|
||||
expect(strings, 'to be an array whose items satisfy', function (str) {
|
||||
var matches = pipetteur(str);
|
||||
|
||||
expect(matches, 'to have length', 2);
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
107
node_modules/pipetteur/test/rgba.js
generated
vendored
Normal file
107
node_modules/pipetteur/test/rgba.js
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
var expect = require('unexpected');
|
||||
var pipetteur = require('../pipetteur');
|
||||
|
||||
describe('RGB match', function () {
|
||||
it('should match a set of valid RGB strings', function (done) {
|
||||
var colors = [
|
||||
'rgb(0, 0, 0)',
|
||||
'rgb(255, 0, 0)',
|
||||
'rgb(0, 255, 0)',
|
||||
'rgb(0, 0, 255)',
|
||||
'rgb(255, 255, 255)',
|
||||
'rgba(0, 0, 0, 0)',
|
||||
'rgba(255, 0, 0, 0)',
|
||||
'rgba(0, 255, 0, 0)',
|
||||
'rgba(0, 0, 255, 0)',
|
||||
'rgba(255, 255, 255, 0)',
|
||||
];
|
||||
|
||||
expect(colors, 'to be an array whose items satisfy', function (rgba) {
|
||||
var matches = pipetteur(rgba);
|
||||
|
||||
expect(matches, 'to be a non-empty array');
|
||||
expect(matches, 'to have length', 1);
|
||||
expect(matches[0], 'to have properties', ['index', 'match']);
|
||||
expect(matches[0].line, 'to be', 1);
|
||||
expect(matches[0].column, 'to be', 1);
|
||||
expect(matches[0].index, 'to be', 0);
|
||||
expect(matches[0].match, 'to be', rgba);
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should match a set of valid 6-char hex substrings', function (done) {
|
||||
var hexes = [
|
||||
{
|
||||
string: 'foo rgb(0, 0, 0) bar',
|
||||
hex: 'rgb(0, 0, 0)',
|
||||
index: 4
|
||||
},
|
||||
{
|
||||
string: 'one, two, rgb(255, 255, 255), three',
|
||||
hex: 'rgb(255, 255, 255)',
|
||||
index: 10
|
||||
},
|
||||
{
|
||||
string: 'hvid (rgb(255, 255, 255)) er pænt',
|
||||
hex: 'rgb(255, 255, 255)',
|
||||
index: 6
|
||||
},
|
||||
{
|
||||
string: 'rgb(18, 52, 86) are numbers',
|
||||
hex: 'rgb(18, 52, 86)',
|
||||
index: 0
|
||||
},
|
||||
{
|
||||
string: 'alphabet song: rgb(171, 205, 239)',
|
||||
hex: 'rgb(171, 205, 239)',
|
||||
index: 15
|
||||
},
|
||||
{
|
||||
string: '#alphab et rgb(171, 205, 239) gehijkl',
|
||||
hex: 'rgb(171, 205, 239)',
|
||||
index: 11
|
||||
},
|
||||
{
|
||||
string: 'background:rgb(254, 220, 186)',
|
||||
hex: 'rgb(254, 220, 186)',
|
||||
index: 11
|
||||
},
|
||||
{
|
||||
string: '$color=rgb(254, 220, 186)',
|
||||
hex: 'rgb(254, 220, 186)',
|
||||
index: 7
|
||||
}
|
||||
];
|
||||
|
||||
expect(hexes, 'to be an array whose items satisfy', function (obj) {
|
||||
var matches = pipetteur(obj.string);
|
||||
|
||||
expect(matches, 'to be a non-empty array');
|
||||
expect(matches, 'to have length', 1);
|
||||
expect(matches[0], 'to have properties', ['index', 'match']);
|
||||
expect(matches[0].index, 'to be', obj.index);
|
||||
expect(matches[0].match, 'to be', obj.hex);
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should match multiple colors in the same string', function (done) {
|
||||
var strings = [
|
||||
'rgb(0,0,0) rgb(255,255,255)',
|
||||
'rgb(100.1, 200.1, 123) and rgba(1, 100, 200, 0.5), not rgb(0,0) or rgba(0,0,0)',
|
||||
'First: rgba(0, 0, 0, 0), Second: rgb(0, 255, 0)',
|
||||
'Unlikely combination: rgb(0, 255, 0)rgb(0, 255, 0)'
|
||||
];
|
||||
|
||||
expect(strings, 'to be an array whose items satisfy', function (str) {
|
||||
var matches = pipetteur(str);
|
||||
|
||||
expect(matches, 'to have length', 2);
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user