Notes-03-28-digital-signing-webpack-dynamic-import-JsonRest-Promise-pattern-performance.measure()

Digital Signing

Terms:

digest: hash of the doc

Normal flow:

Sender

var digest = hash(doc);
send({ 
    counterpart: doc.copy(), 
    encryption: encrypt(digest)
})

Receiver

var digestByCounterpart = hash(counterpart);
var digest = decrypt(encryption);
isEqual(
    digestByCounterpart,
    digest
);

With CA:

Sender

Receiver

Keys

  • CA need to be trusted

  • TODO

Webpack Dynamic Import

  1. Use import(${path}), webpack resolves it in a jsonp way

  2. webpack will do code splitting (generate different bundle) for each module that is NOT in the dependency tree of App.js (not imported yet)

  3. webpack will download the splitted js file when imported is called

  4. webpack uses webpackJsonp() as a global callback to inject the module into the main bundle (main dependency tree)

  5. Once the dynamic import is done, the next same import will be static

  6. if the dynamic imported file is already in main dependency tree(be imported my some other file), it will not be code splitted, dynamic import will be transformed to static as 5 does

Promise pattern JSONRest

Promise Pattern

sync Promise

In runkit:

will print out:

chaining

Reference Link

will output

Measure Regexp

Regex check

with create regex everytime

with cached regex object

for manual check

Last updated

Was this helpful?