added bower, gulp

This commit is contained in:
Bachir Soussi Chiadmi
2017-01-22 15:18:08 +01:00
parent 4c9b35f2d1
commit ac58a24f5c
12657 changed files with 1359874 additions and 579 deletions
@@ -0,0 +1 @@
/node_modules/
@@ -0,0 +1,22 @@
Copyright (c) 2012 Todd Wolfson
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
+102
View File
@@ -0,0 +1,102 @@
# char-props [![Donate on Gittip](http://badgr.co/gittip/twolfson.png)](https://www.gittip.com/twolfson/)
Utility for looking up line and column of a character at a given index and vice versa.
## Getting Started
Install the module with: `npm install charProps`
## Documentation
```js
// charProps is a function which invokes the Indexer constructor
// Indexer JSDoc
/**
* Indexer constructor (takes index and performs pre-emptive caching)
* @constructor
* @param {String} input Content to index
*/
// Indexer.lineAt JSDoc
/**
* Get the line of the character at a certain index
* @param {Number} index Index of character to retrieve line of
* @param {Object} [options] Options to use for search
* @param {Number} [options.minLine=0] Minimum line for us to search on
* TODO: The following still have to be built/implemented
* @param {Number} [options.maxLine=lines.length] Maximum line for us to search on
* @param {String} [options.guess="average"] Affects searching pattern -- can be "high", "low", or "average" (linear top-down, linear bottom-up, or binary)
* @returns {Number} Line number of character
*/
// Indexer.columnAt JSDoc
/**
* Get the column of the character at a certain index
* @param {Number} index Index of character to retrieve column of
* @returns {Number} Column number of character
*/
// Indexer.indexAt JSDoc
/**
* Get the index of the character at a line and column
* @param {Object} params Object containing line and column
* @param {Number} params.line Line of character
* @param {Number} params.column Column of character
* @returns {Number} Index of character
*/
// Indexer.charAt JSDoc
/**
* Get the character at a line and column
* @param {Object} params Object containing line and column
* @param {Number} params.line Line of character
* @param {Number} params.column Column of character
* @returns {String} Character at specified location
*/
```
## Examples
### Initial load
```js
var charProps = require('char-props'),
jquerySrc = fs.readFileSync('jquery.js', 'utf8');
// Load jQuery into charProps
var jqueryProps = charProps(jquerySrc);
```
### lineAt usage
```js
// Look up line of character at index 42
jqueryProps.lineAt(42);
```
### columnAt usage
```js
// Look up column of character at index 88
jqueryProps.columnAt(88);
```
### indexAt usage
```js
// Look up the index of a character at line 9000, column 1
jqueryProps.indexAt({'line': 9000, 'column': 1});
```
### charAt usage
```js
// Get the character at line 20, column 20
jqueryProps.charAt({'line': 20, 'column': 20});
```
## lineAt advanced usage
```js
// Look up line of character at index 9001 with a minimum line of 99
jqueryProps.lineAt(9001, {'minLine': 99});
```
## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint your code via [grunt](http://gruntjs.com/) and test via [vows](http://vowsjs.org/).
## License
Copyright (c) 2012 Todd Wolfson
Licensed under the MIT license.
+36
View File
@@ -0,0 +1,36 @@
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: '<json:package.json>',
lint: {
files: ['grunt.js', 'lib/**/*.js', 'test/**/*.js']
},
watch: {
files: '<config:lint.files>',
tasks: 'default'
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
node: true
},
globals: {
exports: true
}
}
});
// Default task.
grunt.registerTask('default', 'lint test');
};
@@ -0,0 +1,146 @@
/**
* Indexer constructor (takes index and performs pre-emptive caching)
* @constructor
* @param {String} input Content to index
*/
function Indexer(input) {
this.input = input;
// Break up lines by line breaks
var lines = input.split('\n');
// Iterate over the lines until we reach the end or we hit our index
var i = 0,
len = lines.length,
line,
lineStart = 0,
lineEnd,
lineMap = {'length': len};
for (; i < len; i++) {
// Grab the line
line = lines[i];
// Calculate the line end (includes \n we removed)
lineEnd = lineStart + line.length + 1;
// Save the line to its map
lineMap[i] = {'start': lineStart, 'end': lineEnd};
// Overwrite lineStart with lineEnd
lineStart = lineEnd;
}
// Save the lineMap to this
this.lineMap = lineMap;
}
Indexer.prototype = {
/**
* Get the line of the character at a certain index
* @param {Number} index Index of character to retrieve line of
* @param {Object} [options] Options to use for search
* @param {Number} [options.minLine=0] Minimum line for us to search on
* TODO: The following still have to be built/implemented
* @param {Number} [options.maxLine=lines.length] Maximum line for us to search on
* @param {String} [options.guess="average"] Affects searching pattern -- can be "high", "low", or "average" (linear top-down, linear bottom-up, or binary)
* @returns {Number} Line number of character
*/
'lineAt': function (index, options) {
// Fallback options
options = options || {};
// TODO: We can binary search here
// Grab the line map and iterate over it
var lineMap = this.lineMap,
i = options.minLine || 0,
len = lineMap.length,
lineItem;
for (; i < len; i++) {
// TODO: If binary searching, this requires both above and below
// If the index is under end of the lineItem, stop
lineItem = lineMap[i];
if (index < lineItem.end) {
break;
}
}
// Return the line we stopped on
return i;
},
/**
* Get the column of the character at a certain index
* @param {Number} index Index of character to retrieve column of
* @returns {Number} Column number of character
*/
'columnAt': function (index) {
// Start at the index - 1
var input = this.input,
char,
i = index - 1;
// If the index is negative, return now
if (index < 0) {
return 0;
}
// Continue left until index < 0 or we hit a line break
for (; i >= 0; i--) {
char = input.charAt(i);
if (char === '\n') {
break;
}
}
// Return the col of our index - 1 (line break is not in the column count)
var col = index - i - 1;
return col;
},
/**
* Get the index of the character at a line and column
* @param {Object} params Object containing line and column
* @param {Number} params.line Line of character
* @param {Number} params.column Column of character
* @returns {Number} Index of character
*/
'indexAt': function (params) {
// Grab the parameters and lineMap
var line = params.line,
column = params.column,
lineMap = this.lineMap;
// Go to the nth line and get the start
var retLine = lineMap[line],
lineStart = retLine.start;
// Add on the column to the line start and return
var retVal = lineStart + column;
return retVal;
},
/**
* Get the character at a line and column
* @param {Object} params Object containing line and column
* @param {Number} params.line Line of character
* @param {Number} params.column Column of character
* @returns {String} Character at specified location
*/
'charAt': function (params) {
// Get the index of the character, look it up, and return
var index = this.indexAt(params),
input = this.input,
retVal = input.charAt(index);
return retVal;
}
};
function charProps(input) {
// Create and return a new Indexer with the content
var indexer = new Indexer(input);
return indexer;
}
// Expose Indexer to charProps
charProps.Indexer = Indexer;
// Export charProps
module.exports = charProps;
@@ -0,0 +1,99 @@
{
"_args": [
[
{
"raw": "char-props@~0.1.3",
"scope": null,
"escapedName": "char-props",
"name": "char-props",
"rawSpec": "~0.1.3",
"spec": ">=0.1.3 <0.2.0",
"type": "range"
},
"/mnt/Data/bach/Sites/clameurs.org/sites/all/themes/figureslibres/inifig/node_modules/source-map-index-generator"
]
],
"_from": "char-props@>=0.1.3 <0.2.0",
"_id": "char-props@0.1.5",
"_inCache": true,
"_location": "/char-props",
"_npmUser": {
"name": "twolfson",
"email": "todd@twolfson.com"
},
"_npmVersion": "1.2.14",
"_phantomChildren": {},
"_requested": {
"raw": "char-props@~0.1.3",
"scope": null,
"escapedName": "char-props",
"name": "char-props",
"rawSpec": "~0.1.3",
"spec": ">=0.1.3 <0.2.0",
"type": "range"
},
"_requiredBy": [
"/source-map-index-generator"
],
"_resolved": "https://registry.npmjs.org/char-props/-/char-props-0.1.5.tgz",
"_shasum": "5b952f9e20ea21cd08ca7fe135a10f6fe91c109e",
"_shrinkwrap": null,
"_spec": "char-props@~0.1.3",
"_where": "/mnt/Data/bach/Sites/clameurs.org/sites/all/themes/figureslibres/inifig/node_modules/source-map-index-generator",
"author": {
"name": "Todd Wolfson",
"email": "todd@twolfson.com",
"url": "http://twolfson.com/"
},
"bugs": {
"url": "https://github.com/twolfson/char-props/issues"
},
"dependencies": {},
"description": "Utility for looking up line and column of a character at a given index and vice versa",
"devDependencies": {
"grunt": "~0.3.12",
"vows": "~0.6.4"
},
"directories": {},
"dist": {
"shasum": "5b952f9e20ea21cd08ca7fe135a10f6fe91c109e",
"tarball": "https://registry.npmjs.org/char-props/-/char-props-0.1.5.tgz"
},
"engines": {
"node": ">= 0.6.0"
},
"homepage": "https://github.com/twolfson/char-props",
"keywords": [
"character",
"lookup",
"line",
"row",
"column",
"index"
],
"licenses": [
{
"type": "MIT",
"url": "https://github.com/twolfson/char-props/blob/master/LICENSE-MIT"
}
],
"main": "lib/charProps",
"maintainers": [
{
"name": "twolfson",
"email": "todd@twolfson.com"
}
],
"name": "char-props",
"optionalDependencies": {},
"readme": "# char-props [![Donate on Gittip](http://badgr.co/gittip/twolfson.png)](https://www.gittip.com/twolfson/)\n\nUtility for looking up line and column of a character at a given index and vice versa.\n\n## Getting Started\nInstall the module with: `npm install charProps`\n\n## Documentation\n```js\n// charProps is a function which invokes the Indexer constructor\n\n// Indexer JSDoc\n/**\n * Indexer constructor (takes index and performs pre-emptive caching)\n * @constructor\n * @param {String} input Content to index\n */\n\n// Indexer.lineAt JSDoc\n/**\n * Get the line of the character at a certain index\n * @param {Number} index Index of character to retrieve line of\n * @param {Object} [options] Options to use for search\n * @param {Number} [options.minLine=0] Minimum line for us to search on\n * TODO: The following still have to be built/implemented\n * @param {Number} [options.maxLine=lines.length] Maximum line for us to search on\n * @param {String} [options.guess=\"average\"] Affects searching pattern -- can be \"high\", \"low\", or \"average\" (linear top-down, linear bottom-up, or binary)\n * @returns {Number} Line number of character\n */\n\n// Indexer.columnAt JSDoc\n/**\n * Get the column of the character at a certain index\n * @param {Number} index Index of character to retrieve column of\n * @returns {Number} Column number of character\n */\n\n// Indexer.indexAt JSDoc\n/**\n * Get the index of the character at a line and column\n * @param {Object} params Object containing line and column\n * @param {Number} params.line Line of character\n * @param {Number} params.column Column of character\n * @returns {Number} Index of character\n */\n\n// Indexer.charAt JSDoc\n/**\n * Get the character at a line and column\n * @param {Object} params Object containing line and column\n * @param {Number} params.line Line of character\n * @param {Number} params.column Column of character\n * @returns {String} Character at specified location\n */\n```\n\n## Examples\n### Initial load\n```js\nvar charProps = require('char-props'),\n jquerySrc = fs.readFileSync('jquery.js', 'utf8');\n\n// Load jQuery into charProps\nvar jqueryProps = charProps(jquerySrc);\n```\n\n### lineAt usage\n```js\n// Look up line of character at index 42\njqueryProps.lineAt(42);\n```\n\n### columnAt usage\n```js\n// Look up column of character at index 88\njqueryProps.columnAt(88);\n```\n\n### indexAt usage\n```js\n// Look up the index of a character at line 9000, column 1\njqueryProps.indexAt({'line': 9000, 'column': 1});\n```\n\n### charAt usage\n```js\n// Get the character at line 20, column 20\njqueryProps.charAt({'line': 20, 'column': 20});\n```\n\n## lineAt advanced usage\n```js\n// Look up line of character at index 9001 with a minimum line of 99\njqueryProps.lineAt(9001, {'minLine': 99});\n```\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint your code via [grunt](http://gruntjs.com/) and test via [vows](http://vowsjs.org/).\n\n## License\nCopyright (c) 2012 Todd Wolfson\nLicensed under the MIT license.\n",
"readmeFilename": "README.md",
"repository": {
"type": "git",
"url": "git://github.com/twolfson/char-props.git"
},
"scripts": {
"test": "vows test/* --spec"
},
"version": "0.1.5"
}
@@ -0,0 +1,160 @@
var vows = require('vows'),
assert = require('assert'),
charProps = require('../lib/charProps.js'),
suite = vows.describe('charProps');
var file = [
// line, col, charCount (including line breaks)
'line 1', // 0, 5, 5
'another second line', // 1, 19, 25 (5 + 1 + 19)
'3rd line!', // 2, 9, 35 (25 + 1 + 9)
'line fourrrrrrrrr' // 3, 17, 53 (35 + 1 + 17)
].join('\n');
// Basic tests
suite.addBatch({
'A new Indexer': {
topic: function () {
return charProps(file);
},
'can find the line of a character at a given index': function (indexer) {
var index = 20, // d in 'second'
char = file.charAt(index);
// Sanity check
assert.strictEqual(char, 'd', 'The character we are the line of finding is "d"');
// Grab the line number of char
var line = indexer.lineAt(index);
// Assert the 'second' is on the second line
assert.strictEqual(line, 1, 'The character at index 20 is on the second line');
},
'can find the column of a character at a given index': function (indexer) {
var index = 35, // ! in 'line!'
char = file.charAt(index);
// Sanity check
assert.strictEqual(char, '!', 'The character we are the column of finding is "!"');
// Grab the column number of char
var col = indexer.columnAt(index);
// Assert it is in the eigth column
assert.strictEqual(col, 8, 'The character at index 35 is in the ninth column');
},
'can find the index of a character at a given column and line': function (indexer) {
var location = {
'line': 2,
'column': 8
};
// Grab the index of our locaiton
var index = indexer.indexAt(location);
assert.strictEqual(index, 35, 'The character at line 2 and column 8 is index 35');
}
}
});
// Intermediate tests
suite.addBatch({
'A new Indexer': {
topic: function () {
return charProps(file);
},
'can find the line of a character at a given index using a minimum line': function (indexer) {
var index = 43, // o in 'fourrrr'
char = file.charAt(index);
// Sanity check
assert.strictEqual(char, 'o', 'The character we are the line of finding is "o"');
// Grab the line number of char
var line = indexer.lineAt(index, {'minLine': 3});
// Assert it is in the fourth line
assert.strictEqual(line, 3, 'The character at index 42 is on the fourth line');
},
'can get the character at a given column and line': function (indexer) {
var location = {
'line': 3,
'column': 6
};
// Grab the character at our locaiton
var char = indexer.charAt(location);
assert.strictEqual(char, 'o', 'The character at line 3 and column 6 is "o"');
}
}
});
// Edge cases
suite.addBatch({
'A new Indexer': {
topic: function () {
return charProps(file);
},
'considers a line feed part of the past line': function (indexer) {
var index = 26, // \n of line 3
char = file.charAt(index);
// Sanity check
assert.strictEqual(char, '\n', 'The character we are the column of finding is a line feed');
// Grab the line number of char
var line = indexer.lineAt(index);
// Assert it is on the second line
assert.strictEqual(line, 1, 'The character at index 26 on the second line');
// Grab the column number of char
var col = indexer.columnAt(index);
// Assert it is in the nineteenth column
assert.strictEqual(col, 19, 'The character at index 26 is in the nineteenth column');
},
'considers the first character of a line to be on that line': function (indexer) {
var index = 27, // 3 of line 3
char = file.charAt(index);
// Sanity check
assert.strictEqual(char, '3', 'The character we are the positions of finding is 3');
// Grab the line number of char
var line = indexer.lineAt(index);
// Assert it is on the third line
assert.strictEqual(line, 2, 'The character at index 27 on the third line');
// Grab the column number of char
var col = indexer.columnAt(index);
// Assert it is in the zeroth column
assert.strictEqual(col, 0, 'The character at index 27 is in the zero-th column');
},
'considers the last character of a line to be on that line': function (indexer) {
var index = 5, // 1 of line 1
char = file.charAt(index);
// Sanity check
assert.strictEqual(char, '1', 'The character we are the positions of finding is 1');
// Grab the line number of char
var line = indexer.lineAt(index);
// Assert it is on the first line
assert.strictEqual(line, 0, 'The character at index 6 on the first line');
// Grab the column number of char
var col = indexer.columnAt(index);
// Assert it is in the fifth column
assert.strictEqual(col, 5, 'The character at index 6 is in the fifth column');
}
}
});
// Export the suite
suite['export'](module);