Skip to content

Commit

Permalink
Updated README to describe windowless CommonJS environments
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottHamper committed Nov 7, 2014
1 parent 5c0d60c commit f954ce2
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ Cookies.js is a small client-side javascript library that makes managing cookies
[Features](#features)
[Browser Compatibility](#browser-compatibility)
[Getting the Library](#getting-the-library)
[Use in CommonJS/Node Environments Without `window`](#use-in-commonjsnode-environments-without-window)
[A Note About Encoding](#a-note-about-encoding)
[API Reference](#api-reference)

## Features
- [RFC6265](http://www.rfc-editor.org/rfc/rfc6265.txt) Compliant
- [RFC6265](http://www.rfc-editor.org/rfc/rfc6265.txt) compliant
- Cross browser
- Lightweight
- No dependencies
- Public domain
- Supports AMD / CommonJS loaders

Expand All @@ -34,6 +36,19 @@ The following browsers have passed all of the automated Cookies.js tests:
#### Bower
`bower install cookies-js`

## Use in CommonJS/Node Environments Without `window`
In environments where there is no native `window` object, Cookies.js will export a factory method
that accepts a `window` instance. For example, using [jsdom](https://github.com/tmpvar/jsdom), you
might do something like:

```javascript
var jsdom = require('jsdom');
var window = jsdom.jsdom().parentWindow;
var Cookies = require('cookies-js')(window);

// Use Cookies as you normally would
```

## A Note About Encoding
[RFC6265](http://www.rfc-editor.org/rfc/rfc6265.txt) defines a strict set of allowed characters for
cookie keys and values. In order to effectively allow any character to be used in a key or value,
Expand Down

0 comments on commit f954ce2

Please sign in to comment.