Skip to content

Commit

Permalink
Modify typing.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Sep 2, 2019
1 parent 2630e9d commit 9b3fa8e
Show file tree
Hide file tree
Showing 11 changed files with 1,230 additions and 83 deletions.
2 changes: 1 addition & 1 deletion lib/color-safe.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var colors = {};
module['exports'] = colors;
module.exports = colors;

var defineProps = Object.defineProperties;
var styles_data = require('./styles-name')
Expand Down
312 changes: 257 additions & 55 deletions index.d.ts → lib/color.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export interface Color {
(text: string): string;


black_bbt: Color;
red_bbt: Color;
green_bbt: Color;
Expand Down Expand Up @@ -47,6 +46,263 @@ export interface Color {
inverse: Color;
conceal: Color;
strike: Color;

x0: Color;
x1: Color;
x2: Color;
x3: Color;
x4: Color;
x5: Color;
x6: Color;
x7: Color;
x8: Color;
x9: Color;
x10: Color;
x11: Color;
x12: Color;
x13: Color;
x14: Color;
x15: Color;
x16: Color;
x17: Color;
x18: Color;
x19: Color;
x20: Color;
x21: Color;
x22: Color;
x23: Color;
x24: Color;
x25: Color;
x26: Color;
x27: Color;
x28: Color;
x29: Color;
x30: Color;
x31: Color;
x32: Color;
x33: Color;
x34: Color;
x35: Color;
x36: Color;
x37: Color;
x38: Color;
x39: Color;
x40: Color;
x41: Color;
x42: Color;
x43: Color;
x44: Color;
x45: Color;
x46: Color;
x47: Color;
x48: Color;
x49: Color;
x50: Color;
x51: Color;
x52: Color;
x53: Color;
x54: Color;
x55: Color;
x56: Color;
x57: Color;
x58: Color;
x59: Color;
x60: Color;
x61: Color;
x62: Color;
x63: Color;
x64: Color;
x65: Color;
x66: Color;
x67: Color;
x68: Color;
x69: Color;
x70: Color;
x71: Color;
x72: Color;
x73: Color;
x74: Color;
x75: Color;
x76: Color;
x77: Color;
x78: Color;
x79: Color;
x80: Color;
x81: Color;
x82: Color;
x83: Color;
x84: Color;
x85: Color;
x86: Color;
x87: Color;
x88: Color;
x89: Color;
x90: Color;
x91: Color;
x92: Color;
x93: Color;
x94: Color;
x95: Color;
x96: Color;
x97: Color;
x98: Color;
x99: Color;
x100: Color;
x101: Color;
x102: Color;
x103: Color;
x104: Color;
x105: Color;
x106: Color;
x107: Color;
x108: Color;
x109: Color;
x110: Color;
x111: Color;
x112: Color;
x113: Color;
x114: Color;
x115: Color;
x116: Color;
x117: Color;
x118: Color;
x119: Color;
x120: Color;
x121: Color;
x122: Color;
x123: Color;
x124: Color;
x125: Color;
x126: Color;
x127: Color;
x128: Color;
x129: Color;
x130: Color;
x131: Color;
x132: Color;
x133: Color;
x134: Color;
x135: Color;
x136: Color;
x137: Color;
x138: Color;
x139: Color;
x140: Color;
x141: Color;
x142: Color;
x143: Color;
x144: Color;
x145: Color;
x146: Color;
x147: Color;
x148: Color;
x149: Color;
x150: Color;
x151: Color;
x152: Color;
x153: Color;
x154: Color;
x155: Color;
x156: Color;
x157: Color;
x158: Color;
x159: Color;
x160: Color;
x161: Color;
x162: Color;
x163: Color;
x164: Color;
x165: Color;
x166: Color;
x167: Color;
x168: Color;
x169: Color;
x170: Color;
x171: Color;
x172: Color;
x173: Color;
x174: Color;
x175: Color;
x176: Color;
x177: Color;
x178: Color;
x179: Color;
x180: Color;
x181: Color;
x182: Color;
x183: Color;
x184: Color;
x185: Color;
x186: Color;
x187: Color;
x188: Color;
x189: Color;
x190: Color;
x191: Color;
x192: Color;
x193: Color;
x194: Color;
x195: Color;
x196: Color;
x197: Color;
x198: Color;
x199: Color;
x200: Color;
x201: Color;
x202: Color;
x203: Color;
x204: Color;
x205: Color;
x206: Color;
x207: Color;
x208: Color;
x209: Color;
x210: Color;
x211: Color;
x212: Color;
x213: Color;
x214: Color;
x215: Color;
x216: Color;
x217: Color;
x218: Color;
x219: Color;
x220: Color;
x221: Color;
x222: Color;
x223: Color;
x224: Color;
x225: Color;
x226: Color;
x227: Color;
x228: Color;
x229: Color;
x230: Color;
x231: Color;
x232: Color;
x233: Color;
x234: Color;
x235: Color;
x236: Color;
x237: Color;
x238: Color;
x239: Color;
x240: Color;
x241: Color;
x242: Color;
x243: Color;
x244: Color;
x245: Color;
x246: Color;
x247: Color;
x248: Color;
x249: Color;
x250: Color;
x251: Color;
x252: Color;
x253: Color;
x254: Color;
x255: Color;
}

export const black_bbt: Color;
Expand Down Expand Up @@ -351,57 +607,3 @@ export const x252: Color;
export const x253: Color;
export const x254: Color;
export const x255: Color;

declare global {
interface String {

black_bbt: string;
red_bbt: string;
green_bbt: string;
yellow_bbt: string;
blue_bbt: string;
magenta_bbt: string;
cyan_bbt: string;
white_bbt: string;

black_bt: string;
red_bt: string;
green_bt: string;
yellow_bt: string;
blue_bt: string;
magenta_bt: string;
cyan_bt: string;
white_bt: string;

black_b: string;
red_b: string;
green_b: string;
yellow_b: string;
blue_b: string;
magenta_b: string;
cyan_b: string;
white_b: string;

black: string;
red: string;
green: string;
yellow: string;
blue: string;
magenta: string;
cyan: string;
white: string;

// @ts-ignore
bold: string;
faint: string;
italic: string;
underline: string;
// @ts-ignore
blink: string;
overline: string;
inverse: string;
conceal: string;
// @ts-ignore
strike: string;
}
}
18 changes: 2 additions & 16 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
var aa = require('./color')
const color = require('./color');

exports = module.exports = aa;

exports.toxic = function() {
// 在String原型上扩展
// 不建议在原型对象上扩展
var colors = exports.color;
Object.keys(colors).forEach(function(key) {
var fn = colors[key];
Object.defineProperty(String.prototype, key, {
get: function() {
return fn(this.valueOf());
}
});
});
};
exports = module.exports = color;
22 changes: 20 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9b3fa8e

Please sign in to comment.