Replaced log.js to tagol npm package (the same thing)

This commit is contained in:
dig 2019-06-09 00:04:14 +02:00
parent 4cc77eea8b
commit 8754738646
7 changed files with 75 additions and 58 deletions

49
log.js
View File

@ -1,49 +0,0 @@
// console fun with tagged String litteralstremplate
// To deactivate debug
// log.noop()
(function( global ){
var log = (ss,...p)=> log.level > 2 && console.log.apply(console, [ss.join('%')].concat(p));
log.level = 3; // 0> nothing, 1> errors, 2> infos, 3> logs, 4> accessors, 5> proxies
log.I = (ss,...p)=> log.level > 1 && console.info.apply(console, [ss.join('%')].concat(p));
log.E = (ss,...p)=> log.level > 0 && console.error.apply(console, [ss.join('%')].concat(p));
log.G = (ss,...p)=> log.level > 2 && console.groupCollapsed.apply(console, [ss.join('%')].concat(p));
log.noop = ()=> { log = o=>o; log.I = log.G = log.E = log; global.log = log }
global.log = log;
})( global || window )
/* exemples:
log `
window = ${window}o
innerHeight = ${`color:blue`}c${window.innerHeight}d${``}cpx
${`color:white;background:green`}cOK`
log.I `
Hello ${window}o, tu est grande de ${`color:blue`}c${window.innerHeight}d${``}c pixels !
${`color:green`}c Bravo!!`
log.E `
Hello ${window}o tu est grande que de ${window.innerHeight}d pixels !
${`color:white;background:red`}c Pas bien!!`
var bigreen = `color:white;background:green;font-size:1.2em;padding:0 .3em`
, bigred = `color:white;background:red;font-size:1.2em;padding:0 .3em`
log `${bigreen}cOK`
log `${bigred}cKO`
log `${window.innerHeight<500 ? bigred : bigreen}c${window.innerHeight<500 ? "trop petiiiiit!s" : "Ok mon grand .."}s`
// var toLog = window;
// log.G`[class ${'color: indigo'}c${toLog.constructor.name}s${''}c]
// this = ${window}o
// innerWidth = ${`color:blue`}c${window.innerWidth}d${``}cpx
// innerHeight = ${`color:blue`}c${window.innerHeight}d${``}cpx
// document = ${document}o
// title = ${`color:white;background:indigo`}c"${document.title}s"${``}c
// `
*/

65
package-lock.json generated
View File

@ -13,6 +13,14 @@
"negotiator": "0.6.1"
}
},
"ansi-styles": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"requires": {
"color-convert": "^1.9.0"
}
},
"array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
@ -49,6 +57,29 @@
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz",
"integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg="
},
"chalk": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
"integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
"requires": {
"ansi-styles": "^3.2.1",
"escape-string-regexp": "^1.0.5",
"supports-color": "^5.3.0"
}
},
"color-convert": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
"requires": {
"color-name": "1.1.3"
}
},
"color-name": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
},
"colors": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/colors/-/colors-1.2.1.tgz",
@ -107,6 +138,11 @@
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
},
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
},
"esm": {
"version": "3.0.28",
"resolved": "https://registry.npmjs.org/esm/-/esm-3.0.28.tgz",
@ -178,6 +214,11 @@
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
},
"has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0="
},
"http-errors": {
"version": "1.6.3",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz",
@ -204,6 +245,14 @@
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.6.0.tgz",
"integrity": "sha1-4/o1e3c9phnybpXwSdBVxyeW+Gs="
},
"log-symbols": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-3.0.0.tgz",
"integrity": "sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ==",
"requires": {
"chalk": "^2.4.2"
}
},
"media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@ -377,6 +426,22 @@
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz",
"integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew=="
},
"supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
"requires": {
"has-flag": "^3.0.0"
}
},
"tagol": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/tagol/-/tagol-1.0.0.tgz",
"integrity": "sha512-U6qyh9sZ6aKFpNGcdubc4tHjHFLoPzfQDI2fmzRrafAO/3JCUvBzIWHB+jwTGyeI1bSPCxw3FeN8EZSzzt7QEQ==",
"requires": {
"log-symbols": "^3.0.0"
}
},
"through": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",

View File

@ -14,6 +14,7 @@
"colors": "^1.2.1",
"esm": "^3.0.28",
"express": "^4.16.3",
"minimist": "^1.2.0"
"minimist": "^1.2.0",
"tagol": "^1.0.0"
}
}

View File

@ -1,5 +1,5 @@
import 'colors'
import 'log'
import 'tagol'
import fs from 'fs'
const empty = o=> typeof o == 'string' ? o.trim() != '' : o.length > 0
@ -10,7 +10,7 @@ export default function( file, watch = true )
load( file )
watch && fs.watchFile( file, (curr, prev) => {
log`The domain list file changed at: ${curr.mtime}s`
log `The domain list file changed at: ${curr.mtime}s`
domains.splice(0)
load( file )
})
@ -20,7 +20,7 @@ export default function( file, watch = true )
function load( path )
{
log`Loading the domains file ${path.yellow}s...`
log `Loading the domains file ${path.yellow}s...`
parse( fs.readFileSync(path, 'utf-8') )
.map( o=> domains.push(o) )

View File

@ -1,5 +1,5 @@
import 'colors'
import './log'
import 'tagol'
import minimist from 'minimist'
import bouncy from 'bouncy'
import domainParse from './domains-file-parse'

View File

@ -1,9 +1,9 @@
require('colors')
require('log')
require('tagol')
const domains = require('../src/domains.js')('domains-exemple')
const list = ()=> log`=====================================================
const list = ()=> log `=====================================================
${domains.map( D=>`
${D[0].yellow} ${D.test.toString().green}
>>> ${D[1].yellow} ${D.resolve('sub','dom','tld',['A','B','C']).green}

View File

@ -1,6 +1,6 @@
const args = require('minimist')( process.argv.splice(2) )
require('colors')
require('log')
require('tagol')
const domains = require('../src/domains.js')('domains-exemple')
const bouncy = require('./bouncy-mock.js')
@ -36,7 +36,7 @@ function test( host )
})*/
debug.length ?
log`===============================================
log `===============================================
${'Testing'.grey}s "${host.cyan}s"
-----------------
Split: ${(subDomain+'').bgWhite.red}s.${mainDomain.bgWhite.blue}s.${tld.grey}s