diff --git a/README.md b/README.md index c5ff86b..cc69fca 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,6 @@ utilities modules for my projects. And most of the time using too many external smaller modules might be a problem for security and complexity (node_modules bombs anyone?). -This project is the very first step taken to debundle the [Expresser](https://github.com/igoramadas/expresser) -framework into smaller, standalone libraries. - ## What types of utilities? They're separated on the following areas: @@ -36,3 +33,12 @@ throw an exception. Exceptions thrown on methods might have a `friendlyMessage` property appended to them with extra information. + +## API documentation + +You can browse the full API documentation at https://jaul.devv.com. + +Or check these following modules that are using Jaul: + +* [Expresser](https://travis-ci.org/igoramadas/expresser) +* [Monitorado](https://travis-ci.org/igoramadas/monitorado) diff --git a/docs/assets/js/search.js b/docs/assets/js/search.js index 1ef4099..c33e8df 100644 --- a/docs/assets/js/search.js +++ b/docs/assets/js/search.js @@ -1,3 +1,3 @@ var typedoc = typedoc || {}; typedoc.search = typedoc.search || {}; - typedoc.search.data = {"kinds":{"1":"External module","32":"Variable","128":"Class","256":"Interface","1024":"Property","2048":"Method"},"rows":[{"id":0,"kind":1,"name":"\"data\"","url":"modules/_data_.html","classes":"tsd-kind-external-module"},{"id":1,"kind":128,"name":"DataUtils","url":"classes/_data_.datautils.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"data\""},{"id":2,"kind":2048,"name":"removeFromString","url":"classes/_data_.datautils.html#removefromstring","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"data\".DataUtils"},{"id":3,"kind":2048,"name":"maskString","url":"classes/_data_.datautils.html#maskstring","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"data\".DataUtils"},{"id":4,"kind":2048,"name":"minifyJson","url":"classes/_data_.datautils.html#minifyjson","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"data\".DataUtils"},{"id":5,"kind":2048,"name":"uuid","url":"classes/_data_.datautils.html#uuid","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"data\".DataUtils"},{"id":6,"kind":32,"name":"_","url":"modules/_data_.html#_","classes":"tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"data\""},{"id":7,"kind":1,"name":"\"index\"","url":"modules/_index_.html","classes":"tsd-kind-external-module"},{"id":8,"kind":1,"name":"\"io\"","url":"modules/_io_.html","classes":"tsd-kind-external-module"},{"id":9,"kind":128,"name":"IOUtils","url":"classes/_io_.ioutils.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"io\""},{"id":10,"kind":2048,"name":"getFilePath","url":"classes/_io_.ioutils.html#getfilepath","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"io\".IOUtils"},{"id":11,"kind":2048,"name":"copyFileSync","url":"classes/_io_.ioutils.html#copyfilesync","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"io\".IOUtils"},{"id":12,"kind":2048,"name":"mkdirRecursive","url":"classes/_io_.ioutils.html#mkdirrecursive","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"io\".IOUtils"},{"id":13,"kind":2048,"name":"sleep","url":"classes/_io_.ioutils.html#sleep","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"io\".IOUtils"},{"id":14,"kind":32,"name":"fs","url":"modules/_io_.html#fs","classes":"tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"io\""},{"id":15,"kind":32,"name":"path","url":"modules/_io_.html#path","classes":"tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"io\""},{"id":16,"kind":1,"name":"\"network\"","url":"modules/_network_.html","classes":"tsd-kind-external-module"},{"id":17,"kind":128,"name":"NetworkUtils","url":"classes/_network_.networkutils.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"network\""},{"id":18,"kind":2048,"name":"getIP","url":"classes/_network_.networkutils.html#getip","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"network\".NetworkUtils"},{"id":19,"kind":2048,"name":"getSingleIPv4","url":"classes/_network_.networkutils.html#getsingleipv4","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"network\".NetworkUtils"},{"id":20,"kind":2048,"name":"getSingleIPv6","url":"classes/_network_.networkutils.html#getsingleipv6","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"network\".NetworkUtils"},{"id":21,"kind":2048,"name":"getClientIP","url":"classes/_network_.networkutils.html#getclientip","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"network\".NetworkUtils"},{"id":22,"kind":2048,"name":"ipInRange","url":"classes/_network_.networkutils.html#ipinrange","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"network\".NetworkUtils"},{"id":23,"kind":32,"name":"_","url":"modules/_network_.html#_","classes":"tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"network\""},{"id":24,"kind":32,"name":"ipaddr","url":"modules/_network_.html#ipaddr","classes":"tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"network\""},{"id":25,"kind":32,"name":"os","url":"modules/_network_.html#os","classes":"tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"network\""},{"id":26,"kind":1,"name":"\"system\"","url":"modules/_system_.html","classes":"tsd-kind-external-module"},{"id":27,"kind":256,"name":"GetInfoOptions","url":"interfaces/_system_.getinfooptions.html","classes":"tsd-kind-interface tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"system\""},{"id":28,"kind":1024,"name":"labels","url":"interfaces/_system_.getinfooptions.html#labels","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".GetInfoOptions"},{"id":29,"kind":256,"name":"SystemMetrics","url":"interfaces/_system_.systemmetrics.html","classes":"tsd-kind-interface tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"system\""},{"id":30,"kind":1024,"name":"uptime","url":"interfaces/_system_.systemmetrics.html#uptime","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".SystemMetrics"},{"id":31,"kind":1024,"name":"hostname","url":"interfaces/_system_.systemmetrics.html#hostname","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".SystemMetrics"},{"id":32,"kind":1024,"name":"title","url":"interfaces/_system_.systemmetrics.html#title","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".SystemMetrics"},{"id":33,"kind":1024,"name":"platform","url":"interfaces/_system_.systemmetrics.html#platform","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".SystemMetrics"},{"id":34,"kind":1024,"name":"memoryTotal","url":"interfaces/_system_.systemmetrics.html#memorytotal","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".SystemMetrics"},{"id":35,"kind":1024,"name":"memoryUsage","url":"interfaces/_system_.systemmetrics.html#memoryusage","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".SystemMetrics"},{"id":36,"kind":1024,"name":"loadAvg","url":"interfaces/_system_.systemmetrics.html#loadavg","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".SystemMetrics"},{"id":37,"kind":1024,"name":"cpuCores","url":"interfaces/_system_.systemmetrics.html#cpucores","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".SystemMetrics"},{"id":38,"kind":1024,"name":"process","url":"interfaces/_system_.systemmetrics.html#process","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".SystemMetrics"},{"id":39,"kind":256,"name":"CpuLoad","url":"interfaces/_system_.cpuload.html","classes":"tsd-kind-interface tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"system\""},{"id":40,"kind":1024,"name":"idle","url":"interfaces/_system_.cpuload.html#idle","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".CpuLoad"},{"id":41,"kind":1024,"name":"total","url":"interfaces/_system_.cpuload.html#total","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".CpuLoad"},{"id":42,"kind":128,"name":"SystemUtils","url":"classes/_system_.systemutils.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"system\""},{"id":43,"kind":2048,"name":"getInfo","url":"classes/_system_.systemutils.html#getinfo","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"system\".SystemUtils"},{"id":44,"kind":2048,"name":"getCpuLoad","url":"classes/_system_.systemutils.html#getcpuload","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"system\".SystemUtils"},{"id":45,"kind":32,"name":"moment","url":"modules/_system_.html#moment","classes":"tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"system\""},{"id":46,"kind":32,"name":"os","url":"modules/_system_.html#os","classes":"tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"system\""},{"id":47,"kind":32,"name":"path","url":"modules/_system_.html#path","classes":"tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"system\""},{"id":48,"kind":32,"name":"lastCpuLoad","url":"modules/_system_.html#lastcpuload","classes":"tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"system\""}]}; \ No newline at end of file + typedoc.search.data = {"kinds":{"1":"External module","128":"Class","256":"Interface","1024":"Property","2048":"Method"},"rows":[{"id":0,"kind":1,"name":"\"data\"","url":"modules/_data_.html","classes":"tsd-kind-external-module"},{"id":1,"kind":128,"name":"DataUtils","url":"classes/_data_.datautils.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"data\""},{"id":2,"kind":2048,"name":"removeFromString","url":"classes/_data_.datautils.html#removefromstring","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"data\".DataUtils"},{"id":3,"kind":2048,"name":"maskString","url":"classes/_data_.datautils.html#maskstring","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"data\".DataUtils"},{"id":4,"kind":2048,"name":"minifyJson","url":"classes/_data_.datautils.html#minifyjson","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"data\".DataUtils"},{"id":5,"kind":2048,"name":"uuid","url":"classes/_data_.datautils.html#uuid","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"data\".DataUtils"},{"id":6,"kind":1,"name":"\"index\"","url":"modules/_index_.html","classes":"tsd-kind-external-module"},{"id":7,"kind":1,"name":"\"io\"","url":"modules/_io_.html","classes":"tsd-kind-external-module"},{"id":8,"kind":128,"name":"IOUtils","url":"classes/_io_.ioutils.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"io\""},{"id":9,"kind":2048,"name":"getFilePath","url":"classes/_io_.ioutils.html#getfilepath","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"io\".IOUtils"},{"id":10,"kind":2048,"name":"copyFileSync","url":"classes/_io_.ioutils.html#copyfilesync","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"io\".IOUtils"},{"id":11,"kind":2048,"name":"mkdirRecursive","url":"classes/_io_.ioutils.html#mkdirrecursive","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"io\".IOUtils"},{"id":12,"kind":2048,"name":"sleep","url":"classes/_io_.ioutils.html#sleep","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"io\".IOUtils"},{"id":13,"kind":1,"name":"\"network\"","url":"modules/_network_.html","classes":"tsd-kind-external-module"},{"id":14,"kind":128,"name":"NetworkUtils","url":"classes/_network_.networkutils.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"network\""},{"id":15,"kind":2048,"name":"getIP","url":"classes/_network_.networkutils.html#getip","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"network\".NetworkUtils"},{"id":16,"kind":2048,"name":"getSingleIPv4","url":"classes/_network_.networkutils.html#getsingleipv4","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"network\".NetworkUtils"},{"id":17,"kind":2048,"name":"getSingleIPv6","url":"classes/_network_.networkutils.html#getsingleipv6","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"network\".NetworkUtils"},{"id":18,"kind":2048,"name":"getClientIP","url":"classes/_network_.networkutils.html#getclientip","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"network\".NetworkUtils"},{"id":19,"kind":2048,"name":"ipInRange","url":"classes/_network_.networkutils.html#ipinrange","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"network\".NetworkUtils"},{"id":20,"kind":1,"name":"\"system\"","url":"modules/_system_.html","classes":"tsd-kind-external-module"},{"id":21,"kind":256,"name":"GetInfoOptions","url":"interfaces/_system_.getinfooptions.html","classes":"tsd-kind-interface tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"system\""},{"id":22,"kind":1024,"name":"labels","url":"interfaces/_system_.getinfooptions.html#labels","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".GetInfoOptions"},{"id":23,"kind":256,"name":"SystemMetrics","url":"interfaces/_system_.systemmetrics.html","classes":"tsd-kind-interface tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"system\""},{"id":24,"kind":1024,"name":"uptime","url":"interfaces/_system_.systemmetrics.html#uptime","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".SystemMetrics"},{"id":25,"kind":1024,"name":"hostname","url":"interfaces/_system_.systemmetrics.html#hostname","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".SystemMetrics"},{"id":26,"kind":1024,"name":"title","url":"interfaces/_system_.systemmetrics.html#title","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".SystemMetrics"},{"id":27,"kind":1024,"name":"platform","url":"interfaces/_system_.systemmetrics.html#platform","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".SystemMetrics"},{"id":28,"kind":1024,"name":"memoryTotal","url":"interfaces/_system_.systemmetrics.html#memorytotal","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".SystemMetrics"},{"id":29,"kind":1024,"name":"memoryUsage","url":"interfaces/_system_.systemmetrics.html#memoryusage","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".SystemMetrics"},{"id":30,"kind":1024,"name":"loadAvg","url":"interfaces/_system_.systemmetrics.html#loadavg","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".SystemMetrics"},{"id":31,"kind":1024,"name":"cpuCores","url":"interfaces/_system_.systemmetrics.html#cpucores","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".SystemMetrics"},{"id":32,"kind":1024,"name":"process","url":"interfaces/_system_.systemmetrics.html#process","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".SystemMetrics"},{"id":33,"kind":256,"name":"CpuLoad","url":"interfaces/_system_.cpuload.html","classes":"tsd-kind-interface tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"system\""},{"id":34,"kind":1024,"name":"idle","url":"interfaces/_system_.cpuload.html#idle","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".CpuLoad"},{"id":35,"kind":1024,"name":"total","url":"interfaces/_system_.cpuload.html#total","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"system\".CpuLoad"},{"id":36,"kind":128,"name":"SystemUtils","url":"classes/_system_.systemutils.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"system\""},{"id":37,"kind":2048,"name":"getInfo","url":"classes/_system_.systemutils.html#getinfo","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"system\".SystemUtils"},{"id":38,"kind":2048,"name":"getCpuLoad","url":"classes/_system_.systemutils.html#getcpuload","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"system\".SystemUtils"}]}; \ No newline at end of file diff --git a/docs/classes/_data_.datautils.html b/docs/classes/_data_.datautils.html index 7ec7882..0c3fb89 100644 --- a/docs/classes/_data_.datautils.html +++ b/docs/classes/_data_.datautils.html @@ -103,7 +103,7 @@

Static maskString

  • @@ -148,7 +148,7 @@

    Static minifyJson

  • @@ -186,7 +186,7 @@

    Static removeFromStrin
  • @@ -225,7 +225,7 @@

    Static uuid

  • @@ -286,9 +286,6 @@

    Returns string
      -
    • - _ -

    diff --git a/docs/classes/_io_.ioutils.html b/docs/classes/_io_.ioutils.html index eee1003..581adeb 100644 --- a/docs/classes/_io_.ioutils.html +++ b/docs/classes/_io_.ioutils.html @@ -103,7 +103,7 @@

    Static copyFileSync
    @@ -140,7 +140,7 @@

    Static getFilePath

    @@ -180,7 +180,7 @@

    Static mkdirRecursive

  • @@ -212,7 +212,7 @@

    Static sleep

  • @@ -279,12 +279,6 @@

    Returns Promise

    diff --git a/docs/classes/_network_.networkutils.html b/docs/classes/_network_.networkutils.html index 0133da1..5551f13 100644 --- a/docs/classes/_network_.networkutils.html +++ b/docs/classes/_network_.networkutils.html @@ -104,7 +104,7 @@

    Static getClientIP

  • @@ -136,7 +136,7 @@

    Static getIP

  • @@ -168,7 +168,7 @@

    Static getSingleIPv4

  • @@ -191,7 +191,7 @@

    Static getSingleIPv6

  • @@ -214,7 +214,7 @@

    Static ipInRange

  • @@ -293,15 +293,6 @@

    Returns boolean

    diff --git a/docs/classes/_system_.systemutils.html b/docs/classes/_system_.systemutils.html index 9e53c27..782af0c 100644 --- a/docs/classes/_system_.systemutils.html +++ b/docs/classes/_system_.systemutils.html @@ -101,7 +101,7 @@

    Static getCpuLoad

  • @@ -124,7 +124,7 @@

    Static getInfo

  • @@ -197,18 +197,6 @@

    Returns SystemMetrics

  • -
  • - lastCpuLoad -
  • -
  • - moment -
  • -
  • - os -
  • -
  • - path -
  • diff --git a/docs/index.html b/docs/index.html index cc29337..2e238a0 100644 --- a/docs/index.html +++ b/docs/index.html @@ -71,8 +71,6 @@

    What? Why?

    utilities modules for my projects. And most of the time using too many external smaller modules might be a problem for security and complexity (node_modules bombs anyone?).

    -

    This project is the very first step taken to debundle the Expresser - framework into smaller, standalone libraries.

    What types of utilities?

    They're separated on the following areas:

      @@ -89,6 +87,13 @@

      If it fails, it throws

      Exceptions with friendly messages

      Exceptions thrown on methods might have a friendlyMessage property appended to them with extra information.

      +

      API documentation

      +

      You can browse the full API documentation at https://jaul.devv.com.

      +

      Or check these following modules that are using Jaul:

      +

  • SystemMetrics
  • -
  • - lastCpuLoad -
  • -
  • - moment -
  • -
  • - os -
  • -
  • - path -
  • diff --git a/docs/interfaces/_system_.getinfooptions.html b/docs/interfaces/_system_.getinfooptions.html index 95be29e..f8fe740 100644 --- a/docs/interfaces/_system_.getinfooptions.html +++ b/docs/interfaces/_system_.getinfooptions.html @@ -103,7 +103,7 @@

    labels

    labels: boolean
    @@ -160,18 +160,6 @@

    labels

  • SystemMetrics
  • -
  • - lastCpuLoad -
  • -
  • - moment -
  • -
  • - os -
  • -
  • - path -
  • diff --git a/docs/interfaces/_system_.systemmetrics.html b/docs/interfaces/_system_.systemmetrics.html index 290a09a..8914065 100644 --- a/docs/interfaces/_system_.systemmetrics.html +++ b/docs/interfaces/_system_.systemmetrics.html @@ -104,7 +104,7 @@

    cpuCores

    cpuCores: number
    @@ -119,7 +119,7 @@

    hostname

    hostname: string
    @@ -134,7 +134,7 @@

    loadAvg

    loadAvg: any
    @@ -149,7 +149,7 @@

    memoryTotal

    memoryTotal: any
    @@ -164,7 +164,7 @@

    memoryUsage

    memoryUsage: any
    @@ -179,7 +179,7 @@

    platform

    platform: string
    @@ -194,7 +194,7 @@

    process

    process: any
    @@ -209,7 +209,7 @@

    title

    title: string
    @@ -224,7 +224,7 @@

    uptime

    uptime: string
    @@ -305,18 +305,6 @@

    uptime

    diff --git a/docs/modules/_data_.html b/docs/modules/_data_.html index 19e20ea..2842cf5 100644 --- a/docs/modules/_data_.html +++ b/docs/modules/_data_.html @@ -74,30 +74,6 @@

    Classes

  • DataUtils
  • -
    -

    Variables

    -
      -
    • _
    • -
    -
    -
    - - -
    -

    Variables

    -
    - -

    Const _

    -
    _: any = require("lodash")
    - -
    -
    -

    JAUL: Data utilities

    -
    @@ -130,9 +106,6 @@

    Const _

  • DataUtils
  • -
  • - _ -
  • diff --git a/docs/modules/_io_.html b/docs/modules/_io_.html index 8e33a58..c006c03 100644 --- a/docs/modules/_io_.html +++ b/docs/modules/_io_.html @@ -74,43 +74,8 @@

    Classes

  • IOUtils
  • -
    -

    Variables

    - -
    -
    - - -
    -

    Variables

    -
    - -

    Const fs

    -
    fs: any = require("fs")
    - -
    -
    -

    JAUL: IO utilities

    -
    -
    - -

    Const path

    -
    path: any = require("path")
    - -
    diff --git a/docs/modules/_network_.html b/docs/modules/_network_.html index 8008d45..41e3756 100644 --- a/docs/modules/_network_.html +++ b/docs/modules/_network_.html @@ -74,54 +74,8 @@

    Classes

  • NetworkUtils
  • -
    -

    Variables

    - -
    -
    - - -
    -

    Variables

    -
    - -

    Const _

    -
    _: any = require("lodash")
    - -
    -
    -

    JAUL: Network utilities

    -
    -
    - -

    Const ipaddr

    -
    ipaddr: any = require("ipaddr.js")
    - -
    -
    - -

    Const os

    -
    os: any = require("os")
    - -
    diff --git a/docs/modules/_system_.html b/docs/modules/_system_.html index 3e1f1d4..d3792e4 100644 --- a/docs/modules/_system_.html +++ b/docs/modules/_system_.html @@ -82,66 +82,9 @@

    Interfaces

  • SystemMetrics
  • -
    -

    Variables

    - -
    -
    -

    Variables

    -
    - -

    Let lastCpuLoad

    -
    lastCpuLoad: any = null
    - -
    -
    - -

    Const moment

    -
    moment: any = require("moment")
    - -
    -
    -

    JAUL: System utilities

    -
    -
    -
    -
    - -

    Const os

    -
    os: any = require("os")
    - -
    -
    - -

    Const path

    -
    path: any = require("path")
    - -
    -
    diff --git a/lib/data.d.ts b/lib/data.d.ts index d478727..e88c47e 100644 --- a/lib/data.d.ts +++ b/lib/data.d.ts @@ -1,6 +1,3 @@ -/** - * JAUL: Data utilities - */ declare class DataUtils { /** * Removes all the specified characters from a string. For example you can cleanup diff --git a/lib/data.js b/lib/data.js index 4967c17..e6e5095 100644 --- a/lib/data.js +++ b/lib/data.js @@ -1,7 +1,6 @@ "use strict"; -/** - * JAUL: Data utilities - */ +// JAUL: data.ts +/** @hidden */ const _ = require("lodash"); class DataUtils { /** diff --git a/lib/index.d.ts b/lib/index.d.ts index 183d740..60faa53 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -4,7 +4,4 @@ declare const _default: { network: any; system: any; }; -/** - * Just Another Utilities Library - */ export = _default; diff --git a/lib/index.js b/lib/index.js index 18d3539..99a9d4f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,4 +1,5 @@ "use strict"; +// JAUL: index.ts module.exports = { data: require("./data"), io: require("./io"), diff --git a/lib/io.d.ts b/lib/io.d.ts index 875232c..81fcf4c 100644 --- a/lib/io.d.ts +++ b/lib/io.d.ts @@ -1,6 +1,3 @@ -/** - * JAUL: IO utilities - */ declare class IOUtils { /** * Finds the correct path to the file looking first on the (optional) base path diff --git a/lib/io.js b/lib/io.js index 2930101..98046c6 100644 --- a/lib/io.js +++ b/lib/io.js @@ -1,8 +1,8 @@ "use strict"; -/** - * JAUL: IO utilities - */ +// JAUL: io.ts +/** @hidden */ const fs = require("fs"); +/** @hidden */ const path = require("path"); class IOUtils { /** @@ -32,6 +32,7 @@ class IOUtils { // Try running directory. filename = path.resolve(process.cwd(), originalFilename); hasFile = fs.existsSync(filename); + /* istanbul ignore if */ if (hasFile) { return filename; } @@ -81,11 +82,13 @@ class IOUtils { else { let stat; try { + stat = fs.statSync(p); } catch (ex1) { ex1.friendlyMessage = `Can't create directory: ${p}`; throw ex1; } + /* istanbul ignore if */ if (!stat.isDirectory()) { ex.friendlyMessage = `Target ${p} is a file.`; throw ex; diff --git a/lib/network.d.ts b/lib/network.d.ts index 3b3ac62..f33d0ec 100644 --- a/lib/network.d.ts +++ b/lib/network.d.ts @@ -1,6 +1,3 @@ -/** - * JAUL: Network utilities - */ declare class NetworkUtils { /** * Returns a list of valid server IPv4 and/or IPv6 addresses. diff --git a/lib/network.js b/lib/network.js index 0b4c1cc..74c7e95 100644 --- a/lib/network.js +++ b/lib/network.js @@ -1,9 +1,10 @@ "use strict"; -/** - * JAUL: Network utilities - */ +// JAUL: network.ts +/** @hidden */ const _ = require("lodash"); +/** @hidden */ const ipaddr = require("ipaddr.js"); +/** @hidden */ const os = require("os"); class NetworkUtils { /** @@ -33,9 +34,10 @@ class NetworkUtils { */ static getSingleIPv4() { const ips = this.getIP("ipv4"); - if ((ips != null ? ips.length : undefined) > 0) { + if (ips && ips.length > 0) { return ips[0]; } + /* istanbul ignore next */ return null; } /** @@ -44,9 +46,10 @@ class NetworkUtils { */ static getSingleIPv6() { const ips = this.getIP("ipv6"); - if ((ips != null ? ips.length : undefined) > 0) { + if (ips && ips.length) { return ips[0]; } + /* istanbul ignore next */ return null; } /** @@ -68,10 +71,10 @@ class NetworkUtils { // Get remote address. if (reqOrSocket.connection && reqOrSocket.connection.remoteAddress) { return reqOrSocket.connection.remoteAddress; - } + } /* istanbul ignore next */ else if (reqOrSocket.handshake && reqOrSocket.handshake.address) { return reqOrSocket.handshake.address; - } + } /* istanbul ignore next */ else if (reqOrSocket.request && reqOrSocket.request.connection && reqOrSocket.request.connection.remoteAddress) { return reqOrSocket.request.connection.remoteAddress; } diff --git a/lib/system.d.ts b/lib/system.d.ts index fb254ac..44957c8 100644 --- a/lib/system.d.ts +++ b/lib/system.d.ts @@ -1,6 +1,3 @@ -/** - * JAUL: System utilities - */ /** Options for {@link SystemUtils.getInfo} */ interface GetInfoOptions { /** If false, labels won't be added to the output (%, MB, etc). Default is true. */ diff --git a/lib/system.js b/lib/system.js index 2b8e423..756bdda 100644 --- a/lib/system.js +++ b/lib/system.js @@ -1,11 +1,12 @@ "use strict"; -/** - * JAUL: System utilities - */ +// JAUL: system.ts +/** @hidden */ const moment = require("moment"); +/** @hidden */ const os = require("os"); +/** @hidden */ const path = require("path"); -// Temporary variable used to calculate CPU usage. +/** @hidden */ let lastCpuLoad = null; class SystemUtils { /** diff --git a/package-lock.json b/package-lock.json index 4486f92..2cb28b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "jaul", - "version": "0.9.1", + "version": "0.9.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -215,6 +215,12 @@ "negotiator": "0.6.1" } }, + "after": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", + "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=", + "dev": true + }, "ajv": { "version": "6.10.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", @@ -263,6 +269,12 @@ "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=", "dev": true }, + "arraybuffer.slice": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz", + "integrity": "sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog==", + "dev": true + }, "asn1": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", @@ -284,6 +296,12 @@ "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, + "async-limiter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", + "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", + "dev": true + }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -302,12 +320,24 @@ "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", "dev": true }, + "backo2": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", + "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=", + "dev": true + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, + "base64-arraybuffer": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz", + "integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=", + "dev": true + }, "bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", @@ -317,6 +347,21 @@ "tweetnacl": "^0.14.3" } }, + "better-assert": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz", + "integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=", + "dev": true, + "requires": { + "callsite": "1.0.0" + } + }, + "blob": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz", + "integrity": "sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig==", + "dev": true + }, "body-parser": { "version": "1.18.3", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", @@ -374,6 +419,12 @@ "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=", "dev": true }, + "callsite": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", + "integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=", + "dev": true + }, "camelcase": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", @@ -482,12 +533,24 @@ "dev": true, "optional": true }, + "component-bind": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", + "integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=", + "dev": true + }, "component-emitter": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", "dev": true }, + "component-inherit": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz", + "integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=", + "dev": true + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -660,6 +723,55 @@ "once": "^1.4.0" } }, + "engine.io-client": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.3.2.tgz", + "integrity": "sha512-y0CPINnhMvPuwtqXfsGuWE8BB66+B6wTtCofQDRecMQPYX3MYUZXFNKDhdrSe3EVjgOu4V3rxdeqN/Tr91IgbQ==", + "dev": true, + "requires": { + "component-emitter": "1.2.1", + "component-inherit": "0.0.3", + "debug": "~3.1.0", + "engine.io-parser": "~2.1.1", + "has-cors": "1.1.0", + "indexof": "0.0.1", + "parseqs": "0.0.5", + "parseuri": "0.0.5", + "ws": "~6.1.0", + "xmlhttprequest-ssl": "~1.5.4", + "yeast": "0.1.2" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "engine.io-parser": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.1.3.tgz", + "integrity": "sha512-6HXPre2O4Houl7c4g7Ic/XzPnHBvaEmN90vtRO9uLmwtRqQmTOw0QMevL1TOfL2Cpu1VzsaTmMotQgMdkzGkVA==", + "dev": true, + "requires": { + "after": "0.8.2", + "arraybuffer.slice": "~0.0.7", + "base64-arraybuffer": "0.1.5", + "blob": "0.0.5", + "has-binary2": "~1.0.2" + } + }, "es-abstract": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", @@ -1027,6 +1139,29 @@ "function-bind": "^1.1.1" } }, + "has-binary2": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz", + "integrity": "sha512-G1LWKhDSvhGeAQ8mPVQlqNcOB2sJdwATtZKl2pDKKHfpf/rYj24lkinxf69blJbnsvtqqNU+L3SL50vzZhXOnw==", + "dev": true, + "requires": { + "isarray": "2.0.1" + }, + "dependencies": { + "isarray": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", + "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=", + "dev": true + } + } + }, + "has-cors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz", + "integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk=", + "dev": true + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -1083,6 +1218,12 @@ "safer-buffer": ">= 2.1.2 < 3" } }, + "indexof": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", + "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", + "dev": true + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -2548,6 +2689,12 @@ "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", "dev": true }, + "object-component": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz", + "integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE=", + "dev": true + }, "object-keys": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", @@ -2665,6 +2812,24 @@ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, + "parseqs": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", + "integrity": "sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=", + "dev": true, + "requires": { + "better-assert": "~1.0.0" + } + }, + "parseuri": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.5.tgz", + "integrity": "sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=", + "dev": true, + "requires": { + "better-assert": "~1.0.0" + } + }, "parseurl": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", @@ -2980,6 +3145,79 @@ "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true }, + "socket.io-client": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.2.0.tgz", + "integrity": "sha512-56ZrkTDbdTLmBIyfFYesgOxsjcLnwAKoN4CiPyTVkMQj3zTUh0QAx3GbvIvLpFEOvQWu92yyWICxB0u7wkVbYA==", + "dev": true, + "requires": { + "backo2": "1.0.2", + "base64-arraybuffer": "0.1.5", + "component-bind": "1.0.0", + "component-emitter": "1.2.1", + "debug": "~3.1.0", + "engine.io-client": "~3.3.1", + "has-binary2": "~1.0.2", + "has-cors": "1.1.0", + "indexof": "0.0.1", + "object-component": "0.0.3", + "parseqs": "0.0.5", + "parseuri": "0.0.5", + "socket.io-parser": "~3.3.0", + "to-array": "0.1.4" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "socket.io-parser": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.3.0.tgz", + "integrity": "sha512-hczmV6bDgdaEbVqhAeVMM/jfUfzuEZHsQg6eOmLgJht6G3mPKMxYm75w2+qhAQZ+4X+1+ATZ+QFKeOZD5riHng==", + "dev": true, + "requires": { + "component-emitter": "1.2.1", + "debug": "~3.1.0", + "isarray": "2.0.1" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "isarray": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", + "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=", + "dev": true + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -3092,6 +3330,12 @@ "has-flag": "^3.0.0" } }, + "to-array": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", + "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=", + "dev": true + }, "to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", @@ -3360,6 +3604,21 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, + "ws": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.4.tgz", + "integrity": "sha512-eqZfL+NE/YQc1/ZynhojeV8q+H050oR8AZ2uIev7RU10svA9ZnJUddHcOUZTJLinZ9yEfdA2kSATS2qZK5fhJA==", + "dev": true, + "requires": { + "async-limiter": "~1.0.0" + } + }, + "xmlhttprequest-ssl": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz", + "integrity": "sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4=", + "dev": true + }, "y18n": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", @@ -3477,6 +3736,12 @@ } } } + }, + "yeast": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", + "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=", + "dev": true } } } diff --git a/package.json b/package.json index d530fe8..cc9b489 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jaul", - "version": "0.9.1", + "version": "0.9.2", "description": "Just another utilities library. But a very good one.", "keywords": [ "jaul", @@ -37,6 +37,7 @@ "nyc": "^13.3.0", "mocha": "^6.1.1", "mocha-lcov-reporter": "^1.3.0", + "socket.io-client": "^2.2.0", "supertest": "^4.0.2", "typedoc": "^0.14.2", "typescript": "^3.4.2" diff --git a/src/data.ts b/src/data.ts index 04cb6cb..94d15b2 100644 --- a/src/data.ts +++ b/src/data.ts @@ -1,7 +1,6 @@ -/** - * JAUL: Data utilities - */ +// JAUL: data.ts +/** @hidden */ const _ = require("lodash") class DataUtils { diff --git a/src/index.ts b/src/index.ts index 8d2e34a..568de7b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,9 @@ -/** - * Just Another Utilities Library - */ +// JAUL: index.ts + export = { data: require("./data"), io: require("./io"), network: require("./network"), system: require("./system") } + diff --git a/src/io.ts b/src/io.ts index 7dacec9..8778fe1 100644 --- a/src/io.ts +++ b/src/io.ts @@ -1,8 +1,8 @@ -/** - * JAUL: IO utilities - */ +// JAUL: io.ts +/** @hidden */ const fs = require("fs") +/** @hidden */ const path = require("path") class IOUtils { @@ -36,6 +36,7 @@ class IOUtils { // Try running directory. filename = path.resolve(process.cwd(), originalFilename) hasFile = fs.existsSync(filename) + /* istanbul ignore if */ if (hasFile) { return filename } @@ -91,11 +92,15 @@ class IOUtils { callback(p) } else { let stat + try { + stat = fs.statSync(p) } catch (ex1) { ex1.friendlyMessage = `Can't create directory: ${p}` throw ex1 } + + /* istanbul ignore if */ if (!stat.isDirectory()) { ex.friendlyMessage = `Target ${p} is a file.` throw ex diff --git a/src/network.ts b/src/network.ts index 7cb552e..9396d3b 100644 --- a/src/network.ts +++ b/src/network.ts @@ -1,9 +1,10 @@ -/** - * JAUL: Network utilities - */ +// JAUL: network.ts +/** @hidden */ const _ = require("lodash") +/** @hidden */ const ipaddr = require("ipaddr.js") +/** @hidden */ const os = require("os") class NetworkUtils { @@ -38,10 +39,11 @@ class NetworkUtils { static getSingleIPv4(): string { const ips = this.getIP("ipv4") - if ((ips != null ? ips.length : undefined) > 0) { + if (ips && ips.length > 0) { return ips[0] } + /* istanbul ignore next */ return null } @@ -52,10 +54,11 @@ class NetworkUtils { static getSingleIPv6(): string { const ips = this.getIP("ipv6") - if ((ips != null ? ips.length : undefined) > 0) { + if (ips && ips.length) { return ips[0] } + /* istanbul ignore next */ return null } @@ -80,9 +83,9 @@ class NetworkUtils { // Get remote address. if (reqOrSocket.connection && reqOrSocket.connection.remoteAddress) { return reqOrSocket.connection.remoteAddress - } else if (reqOrSocket.handshake && reqOrSocket.handshake.address) { + } /* istanbul ignore next */ else if (reqOrSocket.handshake && reqOrSocket.handshake.address) { return reqOrSocket.handshake.address - } else if (reqOrSocket.request && reqOrSocket.request.connection && reqOrSocket.request.connection.remoteAddress) { + } /* istanbul ignore next */ else if (reqOrSocket.request && reqOrSocket.request.connection && reqOrSocket.request.connection.remoteAddress) { return reqOrSocket.request.connection.remoteAddress } diff --git a/src/system.ts b/src/system.ts index 857ad01..2bcc84f 100644 --- a/src/system.ts +++ b/src/system.ts @@ -1,12 +1,13 @@ -/** - * JAUL: System utilities - */ +// JAUL: system.ts +/** @hidden */ const moment = require("moment") +/** @hidden */ const os = require("os") +/** @hidden */ const path = require("path") -// Temporary variable used to calculate CPU usage. +/** @hidden */ let lastCpuLoad = null /** Options for {@link SystemUtils.getInfo} */ diff --git a/test/test-data.js b/test/test-data.js index e2357e4..08f4321 100644 --- a/test/test-data.js +++ b/test/test-data.js @@ -87,20 +87,16 @@ describe("JAUL Data tests", function() { comment */ { "something": true, - "somethingElse": " space ", //comments here + "somethingElse": " space " //comments here // end /* Multiline comment * something else */ - - "something": "abc", // inline comments - "somethingElse": {/*hello there*/ "test": true}, - "escaped": "This is escaped \\" a" } /* // More inline - /* + */ ` let minified = jaul.data.minifyJson(original) diff --git a/test/test-io.js b/test/test-io.js index 244f8b9..26214ea 100644 --- a/test/test-io.js +++ b/test/test-io.js @@ -111,7 +111,7 @@ describe("JAUL IO Tests", function() { } }) - it("Fails to create recursive directory due to exiting file", function(done) { + it("Fails to create recursive directory due to existing file", function(done) { try { jaul.io.mkdirRecursive("./package.json") diff --git a/test/test-network.js b/test/test-network.js index e05b96d..42069b2 100644 --- a/test/test-network.js +++ b/test/test-network.js @@ -12,6 +12,7 @@ let it = mocha.it chai.should() describe("JAUL Network Tests", function() { + let port = null let jaul = null let app = null let server = null @@ -19,8 +20,7 @@ describe("JAUL Network Tests", function() { before(async function() { jaul = require("../index") - - let port = await getPort(3000) + port = await getPort(3000) app = express() server = app.listen(port) @@ -97,6 +97,35 @@ describe("JAUL Network Tests", function() { supertest.get("/").set("X-Forwarded-For", "10.1.2.3").expect(200, body, done) }) + it("Get valid IP from socket connection", function(done) { + let options = { + transports: ["websocket"], + forceNew: true, + reconnection: false + } + + let socketIO = require("socket.io-client") + let sender = socketIO(`http://localhost:${port}`, options) + let receiver = socketIO(`http://localhost:${port}`, options) + let called = false + + app.use(function(req, res, next) { + if (!called) { + if (req.path.indexOf("socket.io") >= 0) { + called = true + let clientIP = jaul.network.getClientIP(req) + if (clientIP) { + done() + } else { + done("Could not fetch IP from socket connection.") + } + } + } + }) + + sender.emit("message", "abc") + }) + it("Fails to get IP from invalid objects", function(done) { let ip = jaul.network.getClientIP("invalid")