Skip to content

Commit a9233d5

Browse files
committed
initial commit
0 parents  commit a9233d5

6 files changed

Lines changed: 261 additions & 0 deletions

File tree

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Runtime data
7+
pids
8+
*.pid
9+
*.seed
10+
11+
# Directory for instrumented libs generated by jscoverage/JSCover
12+
lib-cov
13+
14+
# Coverage directory used by tools like istanbul
15+
coverage
16+
17+
# nyc test coverage
18+
.nyc_output
19+
20+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21+
.grunt
22+
23+
# node-waf configuration
24+
.lock-wscript
25+
26+
# Compiled binary addons (http://nodejs.org/api/addons.html)
27+
build/Release
28+
29+
# Dependency directories
30+
node_modules
31+
jspm_packages
32+
33+
# Optional npm cache directory
34+
.npm
35+
36+
# Optional REPL history
37+
.node_repl_history
38+
39+
# Don't Version docs in master
40+
docs

LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2016, Patrick Dufour
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
* Neither the name of geodash-expand nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# GeoDash Expand (geodash-expand)
2+
3+
The `expand` function for [GeoDash](http://geodash.io) that is used during building and runtime.
4+
5+
```
6+
var value = expand(keyChain);
7+
```
8+
9+
## GeoDash
10+
11+
GeoDash is a modern web framework and approach for quickly producing visualizations of geospatial data. The name comes from "geospatial dashboard".
12+
13+
The framework is built to be extremely extensible. You can use GeoDash Server (an implementation), the front-end framework, backend code, or just the Gulp pipeline. Have fun!
14+
15+
See [http://geodash.io](http://geodash.io) for more details.
16+
17+
# Install
18+
19+
Install with [npm](https://npmjs.org/package/geodash-expand)
20+
21+
```
22+
npm install geodash-expand--save-dev
23+
```
24+
25+
# Usage
26+
27+
`expand` is a function mostly used with [extract](https://www.npmjs.com/package/geodash-extract). Expand can expand an arbitrary array of period separated keychains and create a unified array of 1 element per key.
28+
29+
```
30+
var a = ["featurelayers"];
31+
var b = expand(a.concat([0, "popup.panes", 2]));
32+
// b == ["featurelayers", 0, "popup", "panes", 2]
33+
var pane = extract(b, dashbaord);
34+
```
35+
36+
Since the function can be used throughout the framework and in downstream project code, in GeoDashJS, it is attached to the `window` and is globally accessible with no namespace.
37+
38+
# Building
39+
40+
## docs
41+
42+
To build the custom docs template used in the website, you'll need to install a custom version of docstrap.git on top of the default version. The below command will install the custom version.
43+
44+
```
45+
npm install git+https://git@github.com/geodashio/docstrap.git\#geodash # Install custom docs template with font awesome
46+
```
47+
48+
You can just build docs with:
49+
```
50+
npm run build:docs # or gulp docs since run the same thing
51+
```
52+
53+
# Tests
54+
55+
Only [jshint](http://jshint.com/about/) is supported right now. Run tests with the following command.
56+
57+
```
58+
npm run tests
59+
```
60+
61+
# Contributing
62+
63+
Happy to accept pull requests!
64+
65+
# License
66+
67+
See `LICENSE` file.

gulpfile.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
var gulp = require('gulp');
2+
var gutil = require('gulp-util');
3+
var pkg = require('./package.json');
4+
var fs = require('fs');
5+
var jsdoc = require('gulp-jsdoc3');
6+
7+
gulp.task('docs', function (cb) {
8+
var src = ['README.md', './index.js'];
9+
var theme = "lumen";
10+
var config = {
11+
"opts": {
12+
"recurse": true,
13+
"destination": "docs"
14+
},
15+
"allowUnknownTags": true,
16+
"plugins": [
17+
"node_modules/jsdoc/plugins/markdown"
18+
],
19+
"markdown": {
20+
"parser": "gfm"
21+
},
22+
"templates": {
23+
"cleverLinks": false,
24+
"monospaceLinks": false,
25+
"default": {
26+
"outputSourceFiles": true
27+
},
28+
"path": "ink-docstrap",
29+
"theme": theme,
30+
"navType": "vertical",
31+
"linenums": true,
32+
"dateFormat": "MMMM Do YYYY, h:mm:ss a",
33+
"outputSourceFiles": true,
34+
"outputSourcePath": true
35+
}
36+
};
37+
gulp.src(src, {read: false}).pipe(jsdoc(config, cb));
38+
});
39+
40+
gulp.task('default', [
41+
'docs'
42+
]);

index.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* A function mostly used with [extract](https://www.npmjs.com/package/geodash-extract).
3+
* Expand can expand an arbitrary array of period-separated keychains and
4+
* create a unified array of 1 element per key.
5+
*
6+
* @function extract
7+
* @param {(string|string[]|int[]|Object[])} keyChain - The arbitrary key chain that cna be a string or array of primitives.
8+
* @return the unified array of keys aka key chain
9+
*
10+
* @example <caption>Basic</caption>
11+
* var a = ["featurelayers"];
12+
* var b = expand(a.concat([0, "popup.panes", 2]));
13+
* // b == ["featurelayers", 0, "popup", "panes", 2]
14+
* var pane = extract(b, dashbaord);
15+
*
16+
*/
17+
18+
19+
var expand = function(keyChain)
20+
{
21+
var newArray = [];
22+
if(Array.isArray(keyChain))
23+
{
24+
for(var i = 0; i < keyChain.length; i++)
25+
{
26+
var value = keyChain[i];
27+
if(angular.isString(value))
28+
{
29+
if(value.indexOf(".") != -1)
30+
{
31+
newArray = newArray.concat(value.split("."));
32+
}
33+
else
34+
{
35+
newArray.push(value);
36+
}
37+
}
38+
else
39+
{
40+
newArray.push(value);
41+
}
42+
}
43+
}
44+
else if(angular.isString(keyChain))
45+
{
46+
newArray = keyChain.split(".");
47+
}
48+
return newArray;
49+
};
50+
51+
module.exports = expand;

package.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "geodash-expand",
3+
"version": "0.0.1",
4+
"description": "The `expand` function for [GeoDash](http://geodash.io) that is used during building and runtime.",
5+
"keywords": [
6+
"map",
7+
"mapping",
8+
"gis",
9+
"geodash"
10+
],
11+
"homepage": "http://geodash.io/",
12+
"scripts": {
13+
"build:docs": "mkdir docs; gulp docs",
14+
"build": "npm run build:docs",
15+
"jshint": "jshint src",
16+
"tests": "npm run jshint"
17+
},
18+
"repository": {
19+
"type": "git",
20+
"url": "https://github.com/geodashio/geodash-expand"
21+
},
22+
"license": "BSD-3-Clause",
23+
"author": "GeoDash Developers",
24+
"bugs": {
25+
"url": "https://github.com/geodashio/geodash-expand/issues"
26+
},
27+
"dependencies": {},
28+
"devDependencies": {
29+
"gulp": "*",
30+
"gulp-jsdoc3": "^0.3.0",
31+
"jshint": "*",
32+
"uglify-js": "*"
33+
}
34+
}

0 commit comments

Comments
 (0)