Codebase list node-color-string / 013d7d7
New upstream version 1.5.4 Xavier Guimard 3 years ago
8 changed file(s) with 126 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
0 root = true
1
2 [*]
3 indent_style = tab
4 end_of_line = lf
5 charset = utf-8
6 trim_trailing_whitespace = true
7 insert_final_newline = true
8
9 [*.coffee]
10 indent_style = space
11
12 [{package.json,*.yml}]
13 indent_style = space
14 indent_size = 2
15
16 [*.md]
17 trim_trailing_whitespace = false
6868 }
6969
7070 if (hexAlpha) {
71 rgb[3] = Math.round((parseInt(hexAlpha, 16) / 255) * 100) / 100;
71 rgb[3] = parseInt(hexAlpha, 16) / 255;
7272 }
7373 } else if (match = string.match(abbr)) {
7474 match = match[1];
7979 }
8080
8181 if (hexAlpha) {
82 rgb[3] = Math.round((parseInt(hexAlpha + hexAlpha, 16) / 255) * 100) / 100;
82 rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;
8383 }
8484 } else if (match = string.match(rgba)) {
8585 for (i = 0; i < 3; i++) {
00 {
11 "name": "color-string",
22 "description": "Parser and generator for CSS color strings",
3 "version": "1.5.3",
3 "version": "1.5.4",
44 "author": "Heather Arthur <fayearthur@gmail.com>",
55 "contributors": [
66 "Maxime Thirouin",
00 var assert = require('assert');
11 var string = require('../');
2
3 function normalizeAlpha(res) {
4 if (res.model === 'rgb' && res.value.length >= 4) {
5 res.value[3] = res.value[3].toFixed(2);
6 } else if (res.length >= 4) {
7 res[3] = res[3].toFixed(2);
8 }
9 return res;
10 }
211
312 assert.deepEqual(string.get.rgb('#fef'), [255, 238, 255, 1]);
413 assert.deepEqual(string.get.rgb('#fffFEF'), [255, 255, 239, 1]);
1524 assert.deepEqual(string.get('#fffFEF'), {model: 'rgb', value: [255, 255, 239, 1]});
1625 assert.deepEqual(string.get('#fffFEFff'), {model: 'rgb', value: [255, 255, 239, 1]});
1726 assert.deepEqual(string.get('#fffFEF00'), {model: 'rgb', value: [255, 255, 239, 0]});
18 assert.deepEqual(string.get('#fffFEFa9'), {model: 'rgb', value: [255, 255, 239, 0.66]});
27 assert.deepEqual(normalizeAlpha(string.get('#fffFEFa9')), {model: 'rgb', value: [255, 255, 239, '0.66']});
1928 assert.deepEqual(string.get('rgb(244, 233, 100)'), {model: 'rgb', value: [244, 233, 100, 1]});
2029 assert.deepEqual(string.get('rgb(100%, 30%, 90%)'), {model: 'rgb', value: [255, 77, 229, 1]});
2130 assert.deepEqual(string.get('transparent'), {model: 'rgb', value: [0, 0, 0, 0]});
5463 assert.deepEqual(string.get.rgb('blue'), [0, 0, 255, 1]);
5564
5665 // alpha
57 assert.deepEqual(string.get.rgb('#fffa'), [255, 255, 255, 0.67]);
66 assert.deepEqual(normalizeAlpha(string.get.rgb('#fffa')), [255, 255, 255, '0.67']);
5867 assert.deepEqual(string.get.rgb('#c814e933'), [200, 20, 233, 0.2]);
5968 assert.deepEqual(string.get.rgb('#c814e900'), [200, 20, 233, 0]);
6069 assert.deepEqual(string.get.rgb('#c814e9ff'), [200, 20, 233, 1]);
0 MIT License
1
2 Copyright (c) Microsoft Corporation. All rights reserved.
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE
0 # Installation
1 > `npm install --save @types/color-string`
2
3 # Summary
4 This package contains type definitions for color-string (https://github.com/qix-/color-string#readme).
5
6 # Details
7 Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/color-string
8
9 Additional Details
10 * Last updated: Sat, 22 Jul 2017 19:03:51 GMT
11 * Dependencies: none
12 * Global values: none
13
14 # Credits
15 These definitions were written by BendingBender <https://github.com/BendingBender>, Dan Marshall <https://github.com/danmarshall>.
0 // Type definitions for color-string 1.5
1 // Project: https://github.com/qix-/color-string#readme
2 // Definitions by: BendingBender <https://github.com/BendingBender>
3 // Dan Marshall <https://github.com/danmarshall>
4 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6 export type Color = [number, number, number, number];
7
8 export interface ColorDescriptor {
9 model: 'rgb' | 'hsl' | 'hwb';
10 value: Color;
11 }
12
13 export function get(colorString: string): ColorDescriptor | null;
14
15 export namespace get {
16 function hsl(colorString: string): Color | null;
17 function hwb(colorString: string): Color | null;
18 function rgb(colorString: string): Color | null;
19 }
20
21 export namespace to {
22 function hex(...args: Array<number | number[]>): string;
23 function rgb(...args: Array<number | number[]>): string;
24 namespace rgb {
25 function percent(...args: Array<number | number[]>): string;
26 }
27 function keyword(...args: Array<number | number[]>): string;
28 function hsl(...args: Array<number | number[]>): string;
29 function hwb(...args: Array<number | number[]>): string;
30 }
0 {
1 "name": "@types/color-string",
2 "version": "1.5.0",
3 "description": "TypeScript definitions for color-string",
4 "license": "MIT",
5 "contributors": [
6 {
7 "name": "BendingBender",
8 "url": "https://github.com/BendingBender"
9 },
10 {
11 "name": "Dan Marshall",
12 "url": "https://github.com/danmarshall"
13 }
14 ],
15 "main": "",
16 "repository": {
17 "type": "git",
18 "url": "https://www.github.com/DefinitelyTyped/DefinitelyTyped.git"
19 },
20 "scripts": {},
21 "dependencies": {},
22 "peerDependencies": {},
23 "typesPublisherContentHash": "ec3f34c8c1a1391a64046a9756fe9f2311ac8ce46531fe381f4d4c5a706b434a",
24 "typeScriptVersion": "2.0"
25 }