Skip to content

Commit 92d6d25

Browse files
committed
Initial commit
0 parents  commit 92d6d25

File tree

14 files changed

+435
-0
lines changed

14 files changed

+435
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.{json,html,svg,css,remarkrc,eslintrc}]
12+
indent_size = 2
13+
14+
[*.md]
15+
trim_trailing_whitespace = false

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
coverage/
2+
example.js
3+
unist-util-generated.js
4+
unist-util-generated.min.js

.eslintrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "eslint:recommended",
3+
"rules": {
4+
"quotes": [2, "single"]
5+
}
6+
}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
*.log
3+
coverage/
4+
node_modules/
5+
unist-util-generated.js
6+
unist-util-generated.min.js

.jscs.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"excludeFiles": [
3+
"coverage/",
4+
"node_modules/",
5+
"unist-util-generated.js",
6+
"unist-util-generated.min.js"
7+
],
8+
"preset": "crockford",
9+
"requireMultipleVarDecl": false,
10+
"disallowDanglingUnderscores": false,
11+
"requireQuotedKeysInObjects": true,
12+
"disallowKeywords": [
13+
"with"
14+
],
15+
"maximumLineLength": {
16+
"value": 79,
17+
"allExcept": [
18+
"regex",
19+
"urlComments"
20+
]
21+
},
22+
"jsDoc": {
23+
"checkAnnotations": "jsdoc3",
24+
"checkParamExistence": true,
25+
"checkParamNames": true,
26+
"checkRedundantAccess": true,
27+
"checkRedundantParams": true,
28+
"checkRedundantReturns": true,
29+
"checkReturnTypes": true,
30+
"checkTypes": "strictNativeCase",
31+
"enforceExistence": true,
32+
"requireHyphenBeforeDescription": true,
33+
"requireNewlineAfterDescription": true,
34+
"requireParamDescription": true,
35+
"requireParamTypes": true,
36+
"requireReturnDescription": true,
37+
"requireReturnTypes": true
38+
}
39+
}

.remarkrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"output": true,
3+
"plugins": [
4+
"lint",
5+
"github",
6+
"comment-config",
7+
"usage"
8+
],
9+
"settings": {
10+
"bullet": "*"
11+
}
12+
}

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
deploy:
2+
- provider: npm
3+
email: tituswormer@gmail.com
4+
api_key:
5+
secure: HugL7fzYscvXKhhvisloDFA407xQB8fOOysJXpBqHx589jpcCmuxR7A1RgnzxFlxgk7v/u7B67C0UEbv2ETwD1A/wxX3wSRVBTpSDhgkl9BB8mZX0Fq+DcfcqYd+B8uVTE2xfdPcBYDtFerbXpLGGqL/ugrunqisyYZTHFOMAkyBkIhXap7KWmnJKHxyDfML5l8OyKe6aaK+0RSrXh8u5D4giurLWvLjmJjBsUq87niiujdoRr9J5p+tzTsTbzM3ryYoZ8Js1p7hG6yuMK6/3Lm1XlaCCivy8eymI5/ytngmu3p8zpOxtG3uprSNT2IiJ6jZpoAXPyqKprj++zrYcEm+kd+5B8XxtN9QpaGon5B9Lr3Aj4617iS8jzYhP2dJKg34i8hw8rfBXv48Uv5gIEbH+Z7kkez60atNuPnJFOqfnJelxNDz+IaJh3d5uLx0ygVRYAXKINkV7UhzHsAvcAoIgafylI22TRso7EiQgCAz8TTI/t7C9L9idSIjXdW2RFAXCjtdzsnlHq+xISupC79QrjI3OE1UBJnGuEL9YMzsSu3tOWxKt3/QwKGxGt9L1qx4hi2yyYK9kkclLEzxALaF1tqsSzm32RH93dQovwsNiV+eCdYmOKrfmibN5GhNDBDsRDdnkkjmC/jfMgATEQNyZ5BZhRNgcNvunJ17b3Y=
6+
on:
7+
tags: true
8+
node: '5.0'
9+
- provider: releases
10+
api_key:
11+
secure: bc/mWTXNG9ffRJcixXTjOiVgxcpDijMgLGaph2kOUZtzmAeKZIViaqxjVIbISodQWJPM4JiROEa2Tou3j0gCvIvIonMOkPuXG186MHI8Wp5gGahex3orC4uiuAimiiLFbzz/jH6LAeE8CccBGecWoZh0jEb0akKWWR3R4bh0uegPIQe0tnbWaA7oR+RjUpaorfQSIETYnDUdvQUK94sA+BkEDtGom2McaPPQZW/1ecj82FQdhMqQdcVVQtq/jpypj3hZsuFJBaJDZbY1ZBBq7D5G2PXreHSTUVVISXcjvaQRxtQvnQrrW3V9mY6Ro03sEnk39QAONz6IPc9C3VKBabLa2Og0CKRFmgVNiZJ+axrbPh457ARAgH0Q9W3oqEuYgsuVQEDDZBWlvjkr0RL7daKJLacGAeLw0mETewonv6ODt+ZWsWnc10Lg8y0TrKGUb+pJmqJ8YX9ytTdiPkADkm9g/2xUky7WRu69xvZN3k/wSRmCnNN4v9yAIfGc9qhYFISVo6NUjMWxCkfcpB2up2pCuTonP8aamhVPuwbBU8T+04vYLZ1n/Va8yMKmBNx+2o93n5XyD0R3Z1HVIWJE9l5CCuJKYzynMUEE3Q5Ycn2KbDKrS/5ozifbH3gB1ZjC12YlO+NZqek6upiDqfWcB4njtdqMkEVDwMUcLD2DEHU=
12+
file:
13+
- "unist-util-generated.js"
14+
- "unist-util-generated.min.js"
15+
on:
16+
tags: true

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2016 Titus Wormer <tituswormer@gmail.com>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
'Software'), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

example.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Dependencies:
2+
var generated = require('./index.js');
3+
4+
// Checks:
5+
var a = generated({});
6+
7+
var b = generated({
8+
'position': {
9+
'start': {},
10+
'end': {}
11+
}
12+
});
13+
14+
var c = generated({
15+
'position': {
16+
'start': {
17+
'line': 1,
18+
'column': 1
19+
},
20+
'end': {
21+
'line': 1,
22+
'column': 2
23+
}
24+
}
25+
});
26+
27+
// Yields:
28+
console.log('txt', ['a: ' + a, 'b: ' + b, 'c: ' + c].join('\n'));

history.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!--remark setext-->
2+
3+
<!--lint disable no-multiple-toplevel-headings-->
4+
5+
0.0.0 / 2016-04-15
6+
==================

index.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* @author Titus Wormer
3+
* @copyright 2016 Titus Wormer
4+
* @license MIT
5+
* @module unist:util:generated
6+
* @fileoverview Check if a node is generated.
7+
*/
8+
9+
'use strict';
10+
11+
/* eslint-env commonjs */
12+
13+
/**
14+
* Return `value` if it’s an object, an empty object
15+
* otherwise.
16+
*
17+
* @private
18+
* @param {*} value - Value to check.
19+
* @return {Object} - `value` or `{}`.
20+
*/
21+
function optional(value) {
22+
return value && typeof value === 'object' ? value : {};
23+
}
24+
25+
/**
26+
* Detect if a node was available in the original document.
27+
*
28+
* @example
29+
* generated(); // true
30+
*
31+
* generated({
32+
* start: {
33+
* line: 1,
34+
* column: 1
35+
* },
36+
* end: {
37+
* line: 1,
38+
* column: 2
39+
* }
40+
* }); // false
41+
*
42+
* @param {Node} node - Node to check.
43+
* @return {boolean} - Whether or not `node` is generated.
44+
*/
45+
function generated(node) {
46+
var position = optional(optional(node).position);
47+
var start = optional(position.start);
48+
var end = optional(position.end);
49+
50+
return !start.line || !start.column || !end.line || !end.column;
51+
}
52+
53+
/*
54+
* Expose.
55+
*/
56+
57+
module.exports = generated;

package.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "unist-util-generated",
3+
"version": "0.0.0",
4+
"description": "Check if a Unist node is generated",
5+
"license": "MIT",
6+
"keywords": [
7+
"unist",
8+
"position",
9+
"location",
10+
"generated",
11+
"util",
12+
"utility"
13+
],
14+
"repository": {
15+
"type": "git",
16+
"url": "https://github.com/wooorm/unist-util-generated.git"
17+
},
18+
"bugs": "https://github.com/wooorm/unist-util-generated/issues",
19+
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
20+
"contributors": [
21+
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
22+
],
23+
"files": [
24+
"index.js"
25+
],
26+
"devDependencies": {
27+
"browserify": "^13.0.0",
28+
"eslint": "^2.0.0",
29+
"esmangle": "^1.0.0",
30+
"istanbul": "^0.4.0",
31+
"jscs": "^3.0.0",
32+
"jscs-jsdoc": "^2.0.0",
33+
"remark": "^4.0.0",
34+
"remark-comment-config": "^3.0.0",
35+
"remark-github": "^4.0.0",
36+
"remark-lint": "^3.0.0",
37+
"remark-usage": "^3.0.0",
38+
"tape": "^4.5.1"
39+
},
40+
"scripts": {
41+
"build-md": "remark . --quiet --frail",
42+
"build-bundle": "browserify index.js --no-builtins -s unistUtilGenerated > unist-util-generated.js",
43+
"build-mangle": "esmangle unist-util-generated.js > unist-util-generated.min.js",
44+
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
45+
"lint-api": "eslint .",
46+
"lint-style": "jscs --reporter inline .",
47+
"lint": "npm run lint-api && npm run lint-style",
48+
"test-api": "node test.js",
49+
"test-coverage": "istanbul cover test.js",
50+
"test": "npm run build && npm run lint && npm run test-coverage"
51+
}
52+
}

readme.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# unist-util-generated [![Build Status][build-badge]][build-page] [![Coverage Status][coverage-badge]][coverage-page]
2+
3+
Check if a [**Unist**][unist] [node][] is [**generated**][spec].
4+
5+
## Installation
6+
7+
[npm][]:
8+
9+
```bash
10+
npm install unist-util-generated
11+
```
12+
13+
**unist-util-generated** is also available as an AMD, CommonJS, and
14+
globals module, [uncompressed and compressed][releases].
15+
16+
## Usage
17+
18+
Dependencies:
19+
20+
```javascript
21+
var generated = require('unist-util-generated');
22+
```
23+
24+
Checks:
25+
26+
```javascript
27+
var a = generated({});
28+
var b = generated({
29+
'position': {
30+
'start': {},
31+
'end': {}
32+
}
33+
});
34+
var c = generated({
35+
'position': {
36+
'start': {
37+
'line': 1,
38+
'column': 1
39+
},
40+
'end': {
41+
'line': 1,
42+
'column': 2
43+
}
44+
}
45+
});
46+
```
47+
48+
Yields:
49+
50+
```txt
51+
a: true
52+
b: true
53+
c: false
54+
```
55+
56+
## API
57+
58+
### `generated(node)`
59+
60+
Detect if [`node`][node] is [**generated**][spec].
61+
62+
**Parameters**:
63+
64+
* `node` ([`Node`][node]) — Node to check.
65+
66+
**Returns**: Whether `node` is generated.
67+
68+
## License
69+
70+
[MIT][license] © [Titus Wormer][author]
71+
72+
<!-- Definition -->
73+
74+
[build-badge]: https://img.shields.io/travis/wooorm/unist-util-generated.svg
75+
76+
[build-page]: https://travis-ci.org/wooorm/unist-util-generated
77+
78+
[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/unist-util-generated.svg
79+
80+
[coverage-page]: https://codecov.io/github/wooorm/unist-util-generated?branch=master
81+
82+
[npm]: https://docs.npmjs.com/cli/install
83+
84+
[releases]: https://github.com/wooorm/unist-util-generated/releases
85+
86+
[license]: LICENSE
87+
88+
[author]: http://wooorm.com
89+
90+
[unist]: https://github.com/wooorm/unist
91+
92+
[node]: https://github.com/wooorm/unist#node
93+
94+
[spec]: https://github.com/wooorm/unist#location

0 commit comments

Comments
 (0)