# sass-var

> Sass variable generator for Node.js

Latest version **0.2.0** (published 2018-02-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install sass-var
pnpm add sass-var
yarn add sass-var
bun add sass-var
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2018-02-04 |
| First published | 2017-09-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Yuichi Goto |
| Maintainers | yasaichi |
| Keywords | generator, sass, variable |

## Links

- npm: https://www.npmjs.com/package/sass-var
- Repository: https://github.com/yasaichi/sass-var
- npm.io page: https://npm.io/package/sass-var

## Dependencies (2)

- [lodash.isplainobject](https://npm.io/package/lodash.isplainobject.md) ^4.0.6
- [@types/lodash.isplainobject](https://npm.io/package/@types/lodash.isplainobject.md) ^4.0.3

## Recent versions

- 0.2.0 (latest) — 2018-02-04
- 0.1.3 — 2017-09-13
- 0.1.2 — 2017-09-13
- 0.1.1 — 2017-09-13
- 0.1.0 — 2017-09-12

## README

# sass-var
[![npm version](https://badge.fury.io/js/sass-var.svg)](https://badge.fury.io/js/sass-var)
[![Build Status](https://travis-ci.org/yasaichi/sass-var.svg?branch=master)](https://travis-ci.org/yasaichi/sass-var)
[![Code Climate](https://codeclimate.com/github/yasaichi/sass-var/badges/gpa.svg)](https://codeclimate.com/github/yasaichi/sass-var)
[![Test Coverage](https://codeclimate.com/github/yasaichi/sass-var/badges/coverage.svg)](https://codeclimate.com/github/yasaichi/sass-var/coverage)

sass-var provides a Sass variable generator with Node.js.

## Installation
```sh
npm install sass-var
```

## Usage
### Basic

```js
const sassVar = require('sass-var');

sassVar.generate('string', 'foo');          // '$string:foo;'
sassVar.generate('boolean', true);          // '$boolean:true;'
sassVar.generate('number', 46);             // '$number:46;'
sassVar.generate('null', null);             // '$null:null;'
sassVar.generate('array', [1, 2, 3]);       // '$array:(1,2,3);'
sassVar.generate('object', { bar: 'baz' }); // '$object:(bar:baz);'
```

### Advanced
```js
/* variables.json
{
  "string": "foo",
  "number": 46,
  "boolean": true,
  "null": null,
  "array": [1, 2, 3],
  "object": {
    "bar": "baz"
  }
}
*/

const sassVar = require('sass-var');
const variables = require('./variables.json');

Object.keys(variables)
  .map(key => sassVar.generate(key, variables[key]))
  .join('')
// '$string:foo;$number:46;$boolean:true;$null:null;$array:(1,2,3);$object:(bar:baz);'
```

## API
### `sassVar.generate(name: string, value: any): string`
Returns a Sass variable, which of name is `name` and of value is `value`.  
Throws an error when `undefined` is specified as `value`.

## Contributing
You should follow the steps below.

1. [Fork the repository](https://help.github.com/articles/fork-a-repo/)
2. Create a feature branch: `git checkout -b add-new-feature`
3. Commit your changes: `git commit -am 'Add new feature'`
4. Push the branch: `git push origin add-new-feature`
4. [Send us a pull request](https://help.github.com/articles/about-pull-requests/)

## License
The library is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

---
_Source: https://npm.io/package/sass-var · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
