Skip to main content

3 posts tagged with "JavaScript"

View All Tags

· 8 min read
Richard Haar

NPM#

NPM hosts over 1.7 million packages at the time of writing, with over 35 billion downloaded packages in the last week alone. Originally the package manager for Node.js, but taking over as the package manager for all of JavaScript. The cool thing with Node.js is that you can compile some C++ to a node addon, making it available for use in JavaScript, so you get the benefit of native code.

So for my first publicly uploaded NPM module, I wanted to create a Cyclic Redundancy Check (CRC) module that conformed to the AUTOSAR (AUTomotive Open System ARchitecture) spec but written in C++.

· 5 min read
Richard Haar

Browsing without a GUI#

Puppeteer allows you to control a Chrome or Chromium instance using NodeJs. The real benefit is running Puppeteer as a headless browser, meaning you don't have any GUI to interact with but you can navigate pages, interact with buttons and take screenshots all from your node script. For example:

 const puppeteer = require('puppeteer');  async function screenshot() {     const browser = await puppeteer.launch({});     const page = await browser.newPage();     await page.goto('https://www.google.com');     await page.screenshot({path: 'GoogleOn' + new Date().toDateString() + '.png'});     browser.close(); }  screenshot();

· 6 min read
Richard Haar

JavaScript lets you mix and match types quite happily, and in most cases the result might be exactly what you expect:

> 'Total : ' + 100'Total : 100'> '12' * 336

However you might not get what you expect:

> '15' + 1'151'> '15' - 114
> if([]) {... console.log('hello')... }helloundefined> [] == truefalse