Giter VIP home page Giter VIP logo

xlib's Introduction

ToC

REWRITE IN PROGRESS

Xlib is being rewritten from first principles. The current master branch of this repo is dedicated to this rewrite. The current npm xlib package points to [email protected] which is a stable, high quality core/util library for node. See the v17 branch for it's source.

The v17 branch is:

  • highly stable
  • full featured
  • used in production
  • available as the default npm xlib package

The problems with v17

  • too opinionated: had debugging and logging interactions built into the runtime. v18 includes a logger and source-map-support but doesn't do these automatically.
  • obsolete features
    • required Bluebird promises: bluebird was great before promises became a native part of javascript. v18 has xlib.promise which supports any promise implementation you use.
    • brittle axios: axios "works" but fails for advanced features (proxy, network failures, authentication). v18 uses gaxios instead and is less strongly tied to it.
    • no use of async/await: not in itself a reason to rewrite, but supporting async/await by default simplifies the api
  • node only: v18 targets browsers and node equally

The remainder of this readme is dedicated to the v18 rewrite.

XLIB v18+

Your isomorphic toolbox

Goals

  • Monorepo: the core xlib, tooling, and build verification projects all live in this repo
  • Docs: full online documentation
  • Promises: async / await by default
  • Isometric: full support for node and browser
  • Performance: take advantage of worker threads where it makes sense
  • Full Featured: aim to provide 80% of utility needs
  • Professional: no hacks, fully documented, deployment environment aware
  • Dev Experience: will include dev-env scafolding scripts and an easy build system
  • Lightweight: A library, not framework. No unexpected logging to console, tree-shake support

Non-Goals

  • Legacy browser support: Ignoring IE, but Edge-Classic support will be attempted
  • Legacy Node support: Development is done on Node 14.x. Node 12.x should work fine.
  • Dev Tooling Agnostism: Development is done on VSCode via ubuntu. You should be able to build/dev on windows, but it's not tested.
    • Win10 Tip: Use WSL for development!

R&D Status

Current v18.x is of develop build quality (meaning: do not use this right now).

Critical R&D complete. Now porting most useful xlib features to the new codebase.

The following signifiers will be attached to the v18 rewrite as work progresses

  • develop: not suitable for any use.
  • alpha: usable for PoC projects only.
  • beta: can be used for production, but features may be missing, and breaking changes should be expected between xlib versions

COMPLETE

  • isomorphic: xlib feature parity for browser and node projects
    • Full test suite runs (and passes) under Node and Evergreen Firefox + Chrome
  • typings: ensure dependent projects get sub-package typings automatically
    • basically, tsconfig.json has to be setup properly. for example, esModuleInterop:true
  • debugging: ensure dependent projects can debug into xlib's *.ts source files
    • dependent project's launch.json needs to properly setup the outFiles setting. see build-examples/xlib-node-basic
    • browser debugging properly sourcemaps to original .ts files
  • monorepo: develop xlib ecosystem as seperate projects within the same repository
    • use npm @microsoft/rush
  • upgradeability: ensure dependent modules can be properly upgraded in a reliable way
    • use rush check and rush dep-check and rush dep-upgrade for this workflow
  • documentation: proper code documentation, auto-gen from source
  • testing: isometric testing supported: mocha used in browsers, jest used in node.
    • jest doesn't work in browsers. didn't switch to full mocha because heft nicely runs jest tests when it builds typescript, and I don't want to spend the time figuring out to do similar with mocha.
    • however there is a problem, in that jest's expect library isn't available cross-platform and it doesn't seem easy to register another assertion lib to globally override jest's in node.
    • so currently working on building the xlib.diagnostics.logging module to handle this kind of work.

PENDING

  • publishing: ensure xlib ecosystem can be published to npm
  • basic react e2e: proof of concept using react to setup a real app (including ssl and dev vs production env)
  • doc site: a documenation site with full text search and versioning
  • modern promise libary
    • probably just use builtin promises
  • enterprise grade logging system (without the enterprise plumbing requirement)
    • ??? some plugable listener lib probably
  • isomorphic worker threads: currently using npm threads which works, but is brittle

xlib's People

Contributors

dependabot[bot] avatar jasonswearingen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mcroker

xlib's Issues

add numHelper.aboutEqual()

function aboutEqual( input: number, checkAgainst: number, maxDeviationPercent: number, extraSpreadBuffer:number=0 ): boolean {
	return ( (input * ( 1 + maxDeviationPercent ))+extraSpreadBuffer > checkAgainst ) && (( input * ( 1 - maxDeviationPercent ))-extraSpreadBuffer < checkAgainst );
}

code quality: ensure tslint can catch accidental function references (vs calls)

in some private code I found some accidental calls like such:

const loadAvg = ( nlib.os.loadavg[ 0 ] / nlib.os.cpus.length );

this is a bug because cpus is actually a function that needs to be called as such: cpus().length

same with loadavg. it's a function.

however it is valid JS code so compiler didn't catch it. find a tslint rule that can catch these mistakes and set it to error

add reflection.getFunctionName()

something like:

/** get the name of the current function, and all functions under it in the call stack */
function getFunctionName(
/** where to start on the call stack.   default is 0 (the immediate caller) */
stackDepth=0
): { name:  parameters:[] target:string} []

security: update JSONX.parse() to reject proto keys

as shown here, json.parse() has exploit possibility: https://github.com/hapijs/bourne

either use bourne or port it's proto inspection regex into our jsonx util

this security issue isn't exploitable by default. it requires mallicious user input to be parsed and then assigned via object.assign() for the payload to become activated. This isn't a super common workflow, but This proposed fix would make the risk moot.

debloat: minimalize features

some features have been rarely used by novaleaf in the last few years.

these features increase load times, and potentially collide with typescript type definitions.

remove these and list as removed in the readme.

if we get load on demand working sometime in the future, these can be considered for readding

switch from ```axios``` to ```request```

axios has a lot of systemic bugs that you don't discover until using it a lot. for example: https proxy support, http(s) agent bugs (like lack of connection pooling), and unhandled promise exceptions.

rework the network sub-module to switch to the request library, however unsure if that works in a browser. maybe not.

usability: if new Exception message already contains innerError message, don't append it again

expected usage of innerError is:

const oldErr;
const err = new xlib.diagnostics.Exception("my msg",{innerError:oldErr});

the above will paste the innerError.message as part of the new err.message.

however, if the user manually pastes in the innerError.message as the following, we should not double-paste it.

const oldErr;
const err = new xlib.diagnostics.Exception("my msg.  innerErr="+oldErr.message,{innerError:oldErr});

async version of jsonx stringify+parse

json.stringify()/parse() speed is dependent on input complexity. jsonx is the same, but as usercode is slower.

however as we hold the source, we can promiseify and defer execution

consider doing this, however if node v12 comes out before hand, consider just doing #9 instead.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.