[{"data":1,"prerenderedAt":335},["ShallowReactive",2],{"project-12450684":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":28,"sentiment":29,"stance_mix":30,"scored_comments":34,"aspects":35,"strip":41,"post_text":44,"what":45,"said":77,"maker_in_thread":175,"shape":185,"grid":189,"attempts":297,"same_week":298,"maker_shows":18,"maker_hidden":327,"reader_version":328,"card":329},"12450684","cookies.js","cookies.js, making cookies a delight to work with on the front-end","title","Show HN: cookies.js, making cookies a delight to work with on the front-end","https:\u002F\u002Fgithub.com\u002Ffranciscop\u002Fcookies.js","github.com","franciscop",1473315511,2016,122,46,293,2264,13,"notable","languages","browser cookie library","library",[24,25,26,27],"javascript cookies","front-end cookies","cookie library","browser cookies","roasted",-0.278,{"positive":31,"neutral":32,"mixed":31,"critical":33},1,4,6,12,{"design":36,"idea":38,"execution":40},{"positive":31,"critical":37},2,{"positive":39,"critical":37},0,{"positive":39,"critical":37},[39,39,39,39,39,39,42,31,39,43,39,39,31,39,39,39,39,39,39,31,39,31,39,42,39,42,42,39,39,39,39,39,39,31,39,31,39,39,39,42],3,5,null,{"problem":46,"audience":44,"pricing":44,"motivation":56,"time_to_build":63,"stack":67,"openness":75,"stage":76,"team_size":75},{"value":47,"source":48,"evidence":49},"Working with browser cookies in JavaScript is verbose and awkward","maker",[50,53],{"id":51,"by":11,"text":52},"12450819","Yes, after the initial simple version, when I thought of expanding it, I looked into js-cookie and Cookies [1], but they all seem to require a `.set()` and `.get()` methods which…",{"id":54,"by":11,"text":55},"12454095","That was totally my original meaning; sensible defaults, easy options and just a simple function to work with makes me want to keep using a library all day. So I try to follow…",{"value":57,"source":48,"evidence":58},"Maker found no cookie library they liked in 2016 and wanted a simpler API",[59,62],{"id":60,"by":11,"text":61},"12467381","But bower came after NPM... Anyway, I didn't really intend this library to be in-the-loop. I just did it because I couldn't find one I liked in 2016. Which is just nuts on…",{"id":51,"by":11,"text":52},{"value":64,"source":48,"evidence":65},"About an hour to build, plus testing and documentation",[66],{"id":60,"by":11,"text":61},[68],{"value":69,"source":70,"evidence":71},"JavaScript","inferred",[72],{"id":73,"by":11,"text":74},"12450863","I URL-Encode it: ``` var res = opt.encode(key) + '=' + encoded + ... ``` Where `opt.encode()` is defined as: ``` function (val) { return encodeURIComponent(val); } ``` But from…","unknown","launched",{"praise":78,"objections":95,"requests":117,"questions":137,"alternatives":156},[79,91],{"value":80,"source":81,"evidence":82},"Simple, prefer the API over alternatives","commenter",[83,87],{"id":84,"by":85,"text":86},"12451700","Fifer82","Unlike izolate, I prefer your API. Great Library!",{"id":88,"by":89,"text":90},"12451271","izolate","Is preference not a valid reason? :) Other reason: the syntax is more explicit, and already familiar to anybody who has used Maps [1] I find your syntax a little confusing. It's…",{"value":92,"source":48,"evidence":93},"Sensible defaults and easy options",[94],{"id":54,"by":11,"text":55},[96,100,110],{"value":97,"source":81,"evidence":98},"Syntax is confusing, e.g. setting multiple cookies with different options",[99],{"id":88,"by":89,"text":90},{"value":101,"source":81,"evidence":102},"Cookie name encoding does not follow RFC token rules",[103,107],{"id":104,"by":105,"text":106},"12450841","niftich","Cool submission! Per RFC 6265, which is the cookie spec you seem to use, the valid chars for cookie names is defined [1] by RFC 2616 (since obsoleted by the 723x series; but…",{"id":108,"by":105,"text":109},"12458339","I did more research and have a further follow-up. According to MDN [1], encodeURIComponent escapes all characters except the following: ``` alphabetic, decimal digits, - _ . ! ~…",{"value":111,"source":81,"evidence":112},"Options object style seems unusual to some",[113],{"id":114,"by":115,"text":116},"12455365","abimaelmartell","This feels so wrong.... ``` cookies({ token: '42' }, { expires: 100 * 24 * 3600, \u002F\u002F The time to expire in seconds domain: false, \u002F\u002F The domain for the cookie path: '\u002F', \u002F\u002F The…",[118,125,131],{"value":119,"source":81,"evidence":120},"Add a WebStorage adapter",[121],{"id":122,"by":123,"text":124},"12451158","keeperofdakeys","It would be interesting if you adapted this to use the WebStorage api. https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FAPI\u002FWeb_Storage_API\u002FUsing_the_Web_Storage_API",{"value":126,"source":48,"evidence":127},"Add more examples to the readme",[128],{"id":129,"by":11,"text":130},"12451314","It is totally a valid reason, that's what I wanted to say with fair enough (: I see, you could just call the same function few times with different options (preferred) as…",{"value":132,"source":81,"evidence":133},"Drop Bower support and promote npm",[134],{"id":135,"by":89,"text":136},"12450813","Good work, but I prefer the syntax of cookies-js [1] Side note, Bower is a dying package manager. You'd get better results if you promoted the npm link over bower. [1]…",[138,145],{"value":139,"source":81,"evidence":140},"How does it compare to Express cookie-parser?",[141],{"id":142,"by":143,"text":144},"12450795","yefim","How does this compare to Express's cookie parser (https:\u002F\u002Fgithub.com\u002Fexpressjs\u002Fcookie-parser) which relies on cookie (https:\u002F\u002Fgithub.com\u002Fjshttp\u002Fcookie) for parsing?",{"value":146,"source":81,"evidence":147},"Why is the library needed at all, and how is it different from js-cookie?",[148,152],{"id":149,"by":150,"text":151},"12450756","brian_herman","This reminds me of jquery-cookie which was replaced by js-cookie. https:\u002F\u002Fgithub.com\u002Fjs-cookie\u002Fjs-cookie",{"id":153,"by":154,"text":155},"12452978","TheAceOfHearts","Someone already mentioned js-cookie [0], but they didn't mention that it supports legacy browsers! If you're tied down supporting old IE, it's a great choice. I've used both…",[157,166,171],{"value":158,"source":81,"evidence":159},"js-cookie",[160,161,162],{"id":149,"by":150,"text":151},{"id":153,"by":154,"text":155},{"id":163,"by":164,"text":165},"12455155","ianstormtaylor","Congrats on shipping it! This got me thinking about what the existing cookie libraries looked like in npm, since I figured it was a solved problem already, potentially even with…",{"value":167,"source":81,"evidence":168},"cookies-js",[169,170],{"id":135,"by":89,"text":136},{"id":153,"by":154,"text":155},{"value":172,"source":81,"evidence":173},"Express cookie-parser",[174],{"id":142,"by":143,"text":144},{"comments":176,"answered":37,"key":177},9,[178,181,182],{"id":179,"text":180},"12450830","Fair enough, I didn't like it and that's the main reason why I continued and published this package. Is it just a preference or do you have any reasoning for liking it?",{"id":129,"text":130},{"id":183,"text":184},"12460120","Thank you",{"commenters":186,"max_depth":33,"maker_replies":176,"first_comment_mins":187,"lifespan_hours":188},26,20,44,[190,192,195,197,200,204,207,209,211,213,214,216,217,220,224,227,229,231,233,235,238,241,244,246,248,249,251,253,254,255,256,259,262,263,266,268,270,273,275,278,282,286,289,292,294,295],[163,39,39,191,164,39],"other\u002Fneutral\u002Fnone",[193,39,39,194,105,39],"12455456","commenter\u002Fneutral\u002Fnone",[196,39,39,194,164,39],"12455588",[198,39,39,191,199,39],"12455523","tracker1",[201,39,39,202,203,39],"12459551","other\u002Fcritical\u002Fnone","jazoom",[205,39,39,191,206,39],"12459724","zachrose",[135,31,42,208,89,39],"project\u002Fmixed\u002Fdesign",[179,31,39,210,11,31],"maker\u002Fneutral\u002Fdesign",[88,31,31,212,89,39],"project\u002Fcritical\u002Fdesign",[129,31,39,210,11,31],[84,31,43,215,85,39],"project\u002Fpositive\u002Fdesign",[183,31,39,194,11,31],[218,31,39,194,219,39],"12450957","kakarot",[221,31,31,222,223,39],"12452944","project\u002Fcritical\u002Fidea","Kiro",[225,31,39,194,226,39],"12454161","konradb",[228,31,39,194,89,39],"12460375",[230,31,39,194,226,39],"12460813",[60,31,39,232,11,31],"maker\u002Fneutral\u002Fidea",[234,31,39,194,199,39],"12455569",[236,31,39,191,237,39],"12452733","berdario",[239,31,39,191,240,39],"12454425","zatkin",[242,31,39,191,243,39],"12454661","joshwcomeau",[104,37,31,245,105,39],"project\u002Fcritical\u002Fexecution",[73,37,39,247,11,31],"maker\u002Fneutral\u002Fexecution",[108,37,31,245,105,39],[250,37,39,247,11,31],"12450889",[149,42,42,252,150,39],"project\u002Fneutral\u002Fidea",[51,42,39,232,11,31],[122,32,42,252,123,39],[153,43,42,252,154,39],[257,33,39,191,258,39],"12453270","throwaway2016a",[260,33,39,191,261,39],"12453310","6DM",[54,33,39,210,11,31],[264,33,39,191,265,39],"12453362","todd3834",[267,33,39,191,258,39],"12453554",[269,33,39,191,258,39],"12453505",[271,33,39,191,272,39],"12454217","dahart",[114,274,31,212,115,39],7,[276,274,39,277,105,39],"12455492","commenter\u002Fneutral\u002Fdesign",[279,274,39,280,281,39],"12456001","commenter\u002Fpositive\u002Fdesign","SamBam",[283,284,31,222,285,39],"12452069",8,"matthewhall",[287,284,39,288,265,39],"12453397","other\u002Fneutral\u002Fidea",[290,284,39,288,291,39],"12453579","aikah",[293,284,39,288,265,39],"12453983",[142,176,42,252,143,39],[296,176,39,232,11,31],"12450828",[],[299,304,308,313,318,322],{"id":300,"name":301,"points":302,"category":303},"12466625","flask_jsondash",302,"data",{"id":305,"name":306,"points":307,"category":303},"12486631","DeuSu",229,{"id":309,"name":310,"points":311,"category":312},"12474406","Colors Used by Popular Sites",179,"creative",{"id":314,"name":315,"points":316,"category":317},"12468723","OverThrown",141,"games",{"id":319,"name":320,"points":321,"category":312},"12477296","beatboxer",134,{"id":323,"name":324,"points":325,"category":326},"12456335","Materia",127,"dev_tools",false,"v2",{"id":330,"name":5,"line":6,"ai":327,"cat":20,"year":13,"points":14,"comments":15,"rec":28,"s":331,"top":18,"kw":332,"maker":11,"domain":10,"tier":19,"attempts":39,"strip":333,"url":9,"mix":334,"praise":80,"objection":97,"sub":21},12450684,-0.28,[24,25,26,27],"0000003105001000000101030330000001010003",[31,32,31,33],1794036547424]