Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 26 additions & 30 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
{
"rules": {
"indent": [
1,
4,
{
"SwitchCase": 1,
"VariableDeclarator": {"var": 1, "let": 1, "const": 1}
}
],
"quotes": 0,
"no-console": 0,
"semi": [
2,
"always"
]
},
"globals": {
},
"env": {
"es6": true,
"browser": true,
"commonjs": true,
"mocha": true
},
"extends": "eslint:recommended",
"ecmaFeatures": {
"experimentalObjectRestSpread": true
},
"plugins": []
}
"rules": {
"indent": [
1,
2,
{
"SwitchCase": 1,
"VariableDeclarator": { "var": 1, "let": 1, "const": 1 }
}
],
"quotes": 0,
"no-console": 0,
"semi": [2, "always"]
},
"globals": {},
"env": {
"es6": true,
"browser": true,
"commonjs": true,
"mocha": true
},
"extends": "eslint:recommended",
"ecmaFeatures": {
"experimentalObjectRestSpread": true
},
"plugins": []
}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules
npm-debug.log
*.map
browser/sweatmap.js
53 changes: 29 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
#SweatMap
# SweatMap

[![npm version](https://badge.fury.io/js/sweatmap.svg)](http://badge.fury.io/js/sweatmap)
[![Build Status](https://travis-ci.org/soluml/SweatMap.svg?branch=master)](https://travis-ci.org/soluml/SweatMap)

Take in a series of UTF-8 strings and map them to UTF-8 strings that are as small as possible while still being unique.

###Why?
### Why?

The motivation behind SweatMap was to take semantic CSS Identifiers (e.g. for selectors) and make them as small as possible at build time. With new tools that can take advantage of CSS Modules all we needed was something to map our current class names to something smaller.

##Installation
## Installation

`npm install sweatmap --save`

##How to use
*SweatMap uses a few ES6 features that may not be present in your Node/Browser depending on the version.*
## How to use

_SweatMap uses a few ES6 features that may not be present in your Node/Browser depending on the version._
These include: `Array.fill`, `Object.assign`, `Object.freeze`, and `Object.keys`

* **Constructor(obj):**

*Takes in an object with up to three optional properties:*
* *cssSafe [default `false`]:* `true` disallows characters that aren't safe for [CSS Identifiers](https://www.w3.org/TR/CSS2/syndata.html#characters).
* *additional_ranges [[`object`](https://github.com/soluml/SweatMap/blob/master/node/sweatmap.js#L27)]:* An object where the key is a "range name" and the value is an object with a start character point and an end character point. You can set null to either start or end to remove a character range.
* *existing_strings [default `{}`]:* Pass in an object of strings that you don't want changed. Key is the original name, value is the name that should be used.

* **bytes(string):** Returns a byte count of the string passed in.
* **size():** Returns number of entries in the map.
* **cssSafeString(string):** Determines if the string is a safe [CSS Identifier](https://www.w3.org/TR/CSS2/syndata.html#characters).
* **set(string):** Returns an obfuscated UTF-8 string that's unique to all strings in the map.
* **delete(key):** Removes the string from the map.
* **clear():** Empties the map.
* **clear():** Empties the map.
* **entries():** Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order.
* **get(key):** Returns the value for a given key.
* **get_obfuscated(value):** Returns the key for a given value.
* **has(key):** Returns true/false if a key exists in the map.
* **has_obfuscated(value):** Returns true/false if a value exists in the map.
- **Constructor(obj):**

_Takes in an object with up to three optional properties:_

- _cssSafe [default `false`]:_ `true` disallows characters that aren't safe for [CSS Identifiers](https://www.w3.org/TR/CSS2/syndata.html#characters).
- _additional_ranges [[`object`](https://github.com/soluml/SweatMap/blob/master/node/sweatmap.js#L27)]:_ An object where the key is a "range name" and the value is an object with a start character point and an end character point. You can set null to either start or end to remove a character range.
- _existing_strings [default `{}`]:_ Pass in an object of strings that you don't want changed. Key is the original name, value is the name that should be used.

- **bytes(string):** Returns a byte count of the string passed in.
- **size():** Returns number of entries in the map.
- **cssSafeString(string):** Determines if the string is a safe [CSS Identifier](https://www.w3.org/TR/CSS2/syndata.html#characters).
- **set(string):** Returns an obfuscated UTF-8 string that's unique to all strings in the map.
- **delete(key):** Removes the string from the map.
- **clear():** Empties the map.
- **clear():** Empties the map.
- **entries():** Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order.
- **get(key):** Returns the value for a given key.
- **get_obfuscated(value):** Returns the key for a given value.
- **has(key):** Returns true/false if a key exists in the map.
- **has_obfuscated(value):** Returns true/false if a value exists in the map.
1 change: 0 additions & 1 deletion browser/sweatmap-0.0.5.min.js

This file was deleted.

1 change: 1 addition & 0 deletions browser/sweatmap-0.2.0.min.js

Large diffs are not rendered by default.

Loading