This is a PURE ES6 library do NOT load into ES5 projects. I will not be transpiling it at all. If someone wants that branch and create your own project. This is for the future and for my own knowledge.
A port of typecodes to ES6 I did a lot of work and testing of typecodes and no one used it. Maybe if I port the work to es6 someone will branch it and create a transpiled project.
The design will use multiple modules imported to make management of the code easier.
import {typetools as tt} from "../index.js";
var str = 'A fox and a hound played all day';
if (tt.is(str, tt.CODE.STRING)) {
var foxIndex = str.indexOf('fox');
var houndIndex = str.indexOf('hound');
}
Determines the type through duck typing and returns a code.
import {typetools as tt} from "../index.js";
var str = 'A fox and a hound played all day';
var code = tt.get(str);
if (code === tt.CODE.STRING) {
var foxIndex = str.indexOf('fox');
var houndIndex = str.indexOf('hound');
}
Spits out a string to know what type was detected. Mostly to be used in the console while debugging.
import {typetools as tt} from "../index.js";
var str = 'A fox and a hound played all day';
var code = tt.get(str);
if (code === tt.CODE.STRING) {
var foxIndex = str.indexOf('fox');
var houndIndex = str.indexOf('hound');
} else {
console.log(tt.str(code));
}
A recursive compare function that uses the type awareness to NOT compare and fail if the types to NOT match. No string and integer matching for example.
All value compares will be the === format.
function performWork(request) {
var previousRequest = JSON.parse(sessionStorage.getItem('myApp.previousRequest'));
if (tt.compare(request, previousRequest)) {
return;
} else {
// WS call.
}
}
A clone that at the lowest level uses Object.assign().
var defaultProps = {
PI: Math.PI,
AVOGADRO: 6.022e23,
display: 'The quick brown fox jumped over the lazy dog.'
};
// use to combine default options with parameters passed in...
var defaultSetting = {
showDialogs: true,
loglevel: 4
};
var result = tt.deepAssign(defaultSetting, {
loglevel: 1
});
SO far can't get tests to run. everything seems to think I want to transpile when I do not. This was kind of close. https://medium.com/@valkyrie_be/js-testing-in-2018-write-in-es6-test-in-es6-df7321ea8398
Tried things and plugin from this page. karma-runner/karma#3335 https://github.com/open-wc/open-wc/tree/master/packages/karma-esm
Still getting 404 on import instruction in test file.
Need to figure out coverage setup. https://medium.com/@gunnarlium/es6-code-coverage-with-babel-jspm-karma-jasmine-and-istanbul-2c1918c5bb23 And we need to figure out packaging and minifying... https://www.reddit.com/r/javascript/comments/54atmc/how_to_minify_es6/
Maybe this... https://github.com/babel/minify
Sick of it...tests pass on my dev ssytem. Can't get them to run on circleci. Looking at github actions...next...
Got build passing trying to figure out coverage. Apparently istanbul has been replaced with nyc. We might be able to do it...but have to do all the steps manually including sending the results directly to coveralls.io directly with this. https://github.com/okkez/coveralls-lcov
Right now if I put coverage as reporter it runs but fails parsing of files. If I put coverage-es6 it fails to even run saying I do not have it...maybe I need plugin...
Trued this which did run tests but did not actually cover code... https://github.com/monounity/karma-coverage-istanbul-instrumenter
maybe we need a different reporter.
Nest trick for simplifying the browser name. https://github.com/gunnarlium/babel-jspm-karma-jasmine-istanbul/blob/master/karma.conf.js
where it looks like we will have to figure out coverage tools on our end then...add steps to actually upload to coveralls.io.