UNPKG

ninjs-lodash

Version:
366 lines (299 loc) 10.4 kB
/** * Test */ 'use strict' const _ = require('../lib/lodash') exports = module.exports = { settings: function(t) { return _.jslog(_.$()) } } _.nstest(exports) // OBJ // _.reflect(module, exports, { something: { whatevs: 5, arr:[ {name: 'steve', enabled: false }, 10 ] } }) // _.jslog(exports.reflect()) // _.log(module) // URL // let GIT_REPO = "git+https://github.com/snapptop/ninjs-lodash.git" // let obj = _.url.all(GIT_REPO) // _.jslog(obj) // let A_URL = _.url.join('http://blah.com', 'shiz', 'user', 2342356, 'index.html') // _.log(_.url.join(_.url.dir(A_URL), _.url.name(GIT_REPO))) // _.log(_.url.dir(A_URL)) // ┌─────────────────────────────────────────────────────────────────────────────┐ // │ href │ // ├──────────┬┬───────────┬─────────────────┬───────────────────────────┬───────┤ // │ protocol ││ auth │ host │ path │ hash │ // │ ││ ├──────────┬──────┼──────────┬────────────────┤ │ // │ ││ │ hostname │ port │ pathname │ search │ │ // │ ││ │ │ │ ├─┬──────────────┤ │ // │ ││ │ │ │ │ │ query │ │ // " http: // user:pass @ host.com : 8080 /p/a/t/h ? query=string #hash " // │ ││ │ │ │ │ │ │ │ // └──────────┴┴───────────┴──────────┴──────┴──────────┴─┴──────────────┴───────┘ // (all spaces in the "" line should be ignored -- they're purely for formatting) // // Original // //runCase('Model') // runCase('parse') // runCase('resolve') // runCase('resolveObject') // runCase('format') // // Extra // runCase('isValid') // runCase('protocol') // runCase('slashes') // runCase('auth') // runCase('host') // runCase('port') // runCase('hostname') // runCase('hash') // runCase('search') // runCase('query') // runCase('jquery') // runCase('pathname') // runCase('path') // runCase('href') // runCase('hostpath') // runCase('home') // runCase('cleanUrl') // runCase('subdomain') // /** // * Helpers // */ // /** // * Api // */ // /** // * _.url.Url(src) // */ // function Model() { // //let src = 'https://subdomain.google.com/?remember=true&ps=10&p=4&filter=false' // let model = new _.url.Url(TEST_URL) // //console.log(_.functionsIn(_.url.Url)) // render(TEST_URL, model) // } // /** // * _.url.parse(src) // */ // function parse() { // //let src = 'https://subdomain.google.com/?remember=true&ps=10&p=4&filter=false' // render(TEST_URL, _.url.parse(TEST_URL)) // } // /** // * _.url.resolve(src) // */ // function resolve() { // //let src = 'https://subdomain.google.com/' // render(TEST_URL, _.url.resolve(TEST_URL, 'controller', '?remember=true&ps=10&p=4&filter=false')) // } // /** // * _.url.resolveObject(src) // */ // function resolveObject() { // //let src = 'https://subdomain.google.com/?remember=true&ps=10&p=4&filter=false' // let obj = _.url.parse(TEST_URL) // render(TEST_URL, _.url.resolveObject(obj)) // } // /** // * _.url.format(src) // */ // function format() { // //let src = 'https://subdomain.google.com/?remember=true&ps=10&p=4&filter=false' // let obj = _.url.parse(TEST_URL) // render(TEST_URL, _.url.format(obj)) // } // /** // * _.url.isValid(src) // */ // function _isValid(url) { // _.log(`${_.padEnd(_.url.isValid(url), 8)}: ${url}`) // } // function isValid() { // const GOOD_URLS = [ // 'https://google.com/?notsure=true&ps=10&p=4&filter=false', // 'http://www.foufos.gr', // 'https://www.foufos.gr', // 'http://foufos.gr', // 'http://www.foufos.gr/kino', // 'http://www.t.co', // 'http://t.co', // 'http://werer.gr', // 'www.foufos.gr' // ] // const BAD_URLS = [ // 'www.foufos', // 'http:www.foufos', // 'http:/www.foufos', // 'http://www.foufos', // 'http://foufos', // 'https://google.com/?notsure=true?ps=10&p=4&filter=false' // ] // _.log('\nShould be TRUE') // _.each(GOOD_URLS, _isValid) // _.log('\nShould be FALSE') // _.each(BAD_URLS, _isValid) // _.log() // } // /** // * _.url.protocol(src) // */ // function protocol() { // //let src = 'https://google.com/?notsure=true?ps=10&p=4&filter=false' // render(TEST_URL, _.url.protocol(TEST_URL)) // } // /** // * _.url.slashes(src) // */ // function slashes() { // //let src = 'https://google.com/?notsure=true?ps=10&p=4&filter=false' // render(TEST_URL, _.url.slashes(TEST_URL)) // } // /** // * _.url.auth(src) // */ // function auth() { // //let src = 'https://google.com/?notsure=true?ps=10&p=4&filter=false' // render(TEST_URL, _.url.auth(TEST_URL)) // } // /** // * _.url.host(src) // */ // function host() { // //let src = 'https://google.com/?notsure=true?ps=10&p=4&filter=false' // render(TEST_URL, _.url.host(TEST_URL)) // } // /** // * _.url.port(src) // */ // function port() { // //let src = 'https://google.com:098234/?notsure=true?ps=10&p=4&filter=false' // render(TEST_URL, _.url.port(TEST_URL)) // } // /** // * _.url.hostname(src) // */ // function hostname() { // //let src = 'https://google.com/?notsure=true?ps=10&p=4&filter=false' // render(TEST_URL, _.url.hostname(TEST_URL)) // } // /** // * _.url.hash(src) // */ // function hash() { // //let src = 'https://google.com/?notsure=true#hashval' // render(TEST_URL, _.url.hash(TEST_URL)) // } // /** // * _.url.search(src) // */ // function search() { // //let src = 'https://google.com/?notsure=true?ps=10&p=4&filter=false' // render(TEST_URL, _.url.search(TEST_URL)) // } // /** // * _.url.query(src) // */ // function query() { // //let src = 'https://google.com/?notsure=true?ps=10&p=4&filter=false' // render(TEST_URL, _.url.query(TEST_URL)) // } // /** // * _.url.jquery(src) // */ // function jquery() { // //let src = 'https://google.com/?notsure=true?ps=10&p=4&filter=false' // render(TEST_URL, _.url.jquery(TEST_URL)) // } // /** // * _.url.queries(src) // */ // function pathname() { // //let src = 'https://google.com/?notsure=true?ps=10&p=4&filter=false' // render(TEST_URL, _.url.pathname(TEST_URL)) // } // /** // * _.url.queries(src) // */ // function path() { // //let src = 'https://google.com/?notsure=true?ps=10&p=4&filter=false' // render(TEST_URL, _.url.path(TEST_URL)) // } // /** // * _.url.queries(src) // */ // function href() { // //let src = 'https://google.com/?notsure=true?ps=10&p=4&filter=false' // render(TEST_URL, _.url.href(TEST_URL)) // } // /** // * _.url.queries(src) // */ // function hostpath() { // //let src = 'https://google.com/?notsure=true?ps=10&p=4&filter=false' // render(TEST_URL, _.url.hostpath(TEST_URL)) // } // /** // * _.url.queries(src) // */ // function home() { // //let src = 'https://google.com/?notsure=true?ps=10&p=4&filter=false' // render(TEST_URL, _.url.home(TEST_URL)) // } // /** // * _.url.queries(src) // */ // function cleanUrl() { // //let src = 'https://google.com/?notsure=true?ps=10&p=4&filter=false' // render(TEST_URL, _.url.cleanUrl(TEST_URL)) // } // /** // * _.url.queries(src) // */ // function subdomain() { // //let src = 'https://google.com/?notsure=true?ps=10&p=4&filter=false' // render(TEST_URL, _.url.subdomain(TEST_URL)) // } // LIBS // console.log(_.jav()) // SETTINGS // _.jslog(_.$(), { wrap: 200, align: true }) // _.jslog(_.omit(_.$(), ['js', 'json', 'launch', 'vs']), { wrap: 200, align: true }) // _.jslog(_.omit(_.$(), ['snapp', 'ninjs', 'vscode'])) // _.log(_.$('env.jargv._[2]')) // console.log(_.$('paths.target', 'sites', 'snapptop.com', 'apps', 'cdn.snapptop.com')) // _.exec({ cwd: __dirname, cmd:'npm c ls -l' }, _.logcb) // FILES // let blah = _.files.js.toPretty(_.$(), { wrap:160, align:true, colors: false }) // _.outputFile(_.path.join(__dirname, 'temp', 'settings.json'), blah, _.logcb) // CLI // let CLI_LOOKUP = { // "ams": { // "info": { // "help": `Prints @snapptop/ams api toJSON`, // "options": { "wow": "here", "andmore": { stuff: false }, "env": "production", "name": "sally" }, // "prop": function(options, callback) { return _.done(options, callback) }, // "cb": function(err, result) { return err ? _.log(err) : result ? _.jslog(result) : null } // } // } // } // _.help('snapptop', CLI_LOOKUP) // _.cli(CLI_LOOKUP) // CMD // _.exec({ // cwd: _.path.join(_.$('paths.storage'), 'libs'), // cmd: 'git', // args: ['clone', 'https://github.com/ExodusMovement/varstruct-cstring.git'] // }, // (err, result) => { // if(err) return console.log(err) // console.log(result) // }) // FS // _.scanJs({ path: _.path.join('F:', 'modules', 'ninjs') }, _.logcb) // _.scanMd({ path: _.path.join('F:', 'modules') }, _.logcb) // _.scanPackages({ path: _.path.join('F:', 'modules', 'ninjs') }, _.logcb) // _.scanPackageDirs({ path: _.path.join('F:', 'sites') }, _.logcb) // _.pkgs({ path: _.path.join('F:', 'sites') }, _.logcb) // _.pkg({ name: 'cdn.snapptop.com' }, _.logcb) // _.writepkg(_.path.join(__dirname, 'temp', 'mypackage.json'), require('./package.json'), _.logcb) // _.tree({ path:__dirname, excludes:['node_modules', '.git'] }, _.logcb)