4 ms·
The first 30 lines of this file are a 'joy' https://github.com/js-cookie/js-cookie/blob/master/src/js.cookie.js https://github.com/js-cookie/js-cookie/blob/mas
by monk_e_boy 11y ago
The first 30 lines of this file are a 'joy'
https://github.com/js-cookie/js-cookie/blob/master/src/js.cookie.js https://github.com/js-cookie/js-cookie/blob/master/src/js.co...
I'm sure js could be nice, but it never seems to be.
- tracker1 11y agoThe syntax could be a lot cleaner... the Universal Module Definition (UMD) pattern at the top makes it a bit quirky... A lot of people have moved towards using CommonJS (cjs/node-style) exports with tooling such as browserift/webpack and/or babel (for es6 modules) in order to clean up the source syntax. What you're looking at is a relatively poor example. In es6, that could be ... exports default function... without all the cruft around it, also the module itself could be cleaner. Similar to: var cookies = parse(); export function set({key, value, days=null}) { ... } export function get(key) { ... } export const remove = (key) => set({key, value:null}); export function parse(values = document && document.cookie || '') { ... }
- monk_e_boy 11y agoClasses and modules in almost any other modern language are much easier to read and write. Ruby, python, heck even php are better than JS. That's my real issue with JS. If we had a browser that had lots of languages baked into it, none of use would choose to use JS ;) node.js would never have been invented...