Friday, November 20, 2015

Bower install returns "Error: ENOTEMPTY, rename xxx" error

I added jquery-mousewheel to bower.json, then ran

bower install jquery-mousewheel

But got  below error

bower jquery-mousewheel#*    ENOTEMPTY ENOTEMPTY, rename '/Users/jimz/.cache/bower/packages/c1d6f178dc1d8767625f6e478b014cf2/3.1.13'

Stack trace:
Error: ENOTEMPTY, rename '/Users/jimz/.cache/bower/packages/c1d6f178dc1d8767625f6e478b014cf2/3.1.13'
    at Error (native)

Console trace:
Trace
    at StandardRenderer.error (/usr/local/lib/node_modules/bower/lib/renderers/StandardRenderer.js:74:17)
    at Logger.<anonymous> (/usr/local/lib/node_modules/bower/bin/bower:109:18)
    at Logger.emit (events.js:107:17)
    at Logger.emit (/usr/local/lib/node_modules/bower/node_modules/bower-logger/lib/Logger.js:29:39)
    at /usr/local/lib/node_modules/bower/lib/commands/install.js:27:16
    at _rejected (/usr/local/lib/node_modules/bower/node_modules/q/q.js:808:24)
    at /usr/local/lib/node_modules/bower/node_modules/q/q.js:834:30
    at Promise.when (/usr/local/lib/node_modules/bower/node_modules/q/q.js:1079:31)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/bower/node_modules/q/q.js:752:41)
    at /usr/local/lib/node_modules/bower/node_modules/q/q.js:574:44

Tried some ways, but didn't work. As the error path was .cache, so I did

bower cache clean
bower update jquery-mousewheel

Which fixed the issue.

Friday, November 13, 2015

Shim and Polyfill

Shim:
Shim intercepts API calls and creates an abstract layer between the caller and the target. It is more like an adapter. e.g. es5-shim provides Date.now() API which adapts to old new Date().getTime() API.

Polyfill:
Polyfilling is really just a specialized version of shimming. Polyfill is about implementing missing features in an API. e.g. location.origin which is not available on IE 10.

Wednesday, November 11, 2015

ES6 (ECMAScript 6) 101

Many companies start to use ES6 to write Javascript codes and use transpilation tool to transform ES6 codes to well-supported ES5 codes.

Here are some concepts (new stuff) in ES6
  • Variables (let, const)
  • Arrow Functions (map, set, =>)
  • Strings (startsWith, endsWith, includes, repeat)
  • TEMPLATE LITERAL (${name})
  • Arrays (Array.from, Array.of, find, findIndex, fill)
  • Math (Math.sign, Math.trunc, Math.cbrt)
  • Spread Operator (...)
  • Destructuring (let [x, y] = [1, 2];)
  • Parameters (function(defaultX = 1), REST PARAMETERS ...remaining)
  • Modules (export function/var, import from, export default)
  • Classes (class, constructor, extends, new)
  • Symbols (getOwnPropertySymbols)
  • Transpilation (Babel, Traceur, TypeScript, ScratchJS)
https://kangax.github.io/compat-table/es6/ has the complete list and cross browser support status, and some other concepts are not covered above like
  • Proxy
  • Promise
  • Reflect
  • RegExp y and u flags