[Pkg-javascript-commits] [node-normalize-path] 01/06: Import Upstream version 2.0.1

Sruthi Chandran srud-guest at moszumanska.debian.org
Tue Oct 18 09:24:31 UTC 2016


This is an automated email from the git hooks/post-receive script.

srud-guest pushed a commit to branch master
in repository node-normalize-path.

commit f1a4e4930257e4e781f3047b29b722692d541c01
Author: Sruthi <srud at disroot.org>
Date:   Tue Oct 18 14:27:51 2016 +0530

    Import Upstream version 2.0.1
---
 .editorconfig                    |  22 +++++++
 .eslintrc                        | 125 +++++++++++++++++++++++++++++++++++++++
 .gitattributes                   |  14 +++++
 .gitignore                       |  53 +++++++++++++++++
 .travis.yml                      |  10 ++++
 .verb.md                         |  49 +++++++++++++++
 LICENSE                          |  21 +++++++
 README.md                        |  75 +++++++++++++++++++++++
 benchmark/code/current.js        |   1 +
 benchmark/code/no-regex.js       |  31 ++++++++++
 benchmark/code/node-path.js      |  10 ++++
 benchmark/code/regex.js          |   8 +++
 benchmark/code/slice-trailing.js |  11 ++++
 benchmark/code/split.js          |   7 +++
 benchmark/code/while.js          |  40 +++++++++++++
 benchmark/fixtures/long.js       |   7 +++
 benchmark/fixtures/path-0.js     |   7 +++
 benchmark/fixtures/path-1.js     |   7 +++
 benchmark/fixtures/path-10.js    |   7 +++
 benchmark/fixtures/path-11.js    |   7 +++
 benchmark/fixtures/path-12.js    |   7 +++
 benchmark/fixtures/path-13.js    |   7 +++
 benchmark/fixtures/path-14.js    |   7 +++
 benchmark/fixtures/path-15.js    |   7 +++
 benchmark/fixtures/path-16.js    |   7 +++
 benchmark/fixtures/path-17.js    |   7 +++
 benchmark/fixtures/path-18.js    |   7 +++
 benchmark/fixtures/path-2.js     |   7 +++
 benchmark/fixtures/path-3.js     |   7 +++
 benchmark/fixtures/path-4.js     |   7 +++
 benchmark/fixtures/path-5.js     |   7 +++
 benchmark/fixtures/path-6.js     |   7 +++
 benchmark/fixtures/path-7.js     |   7 +++
 benchmark/fixtures/path-8.js     |   7 +++
 benchmark/fixtures/path-9.js     |   7 +++
 benchmark/fixtures/short.js      |   7 +++
 benchmark/fixtures/trailing.js   |   7 +++
 benchmark/fixtures/unix.js       |   1 +
 benchmark/fixtures/win.js        |   1 +
 benchmark/index.js               |  12 ++++
 bower.json                       |  30 ++++++++++
 index.js                         |  17 ++++++
 package.json                     |  59 ++++++++++++++++++
 test.js                          |  83 ++++++++++++++++++++++++++
 44 files changed, 834 insertions(+)

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..991900b
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,22 @@
+# http://editorconfig.org
+root = true
+
+[*]
+indent_style = space
+end_of_line = lf
+charset = utf-8
+indent_size = 2
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false
+insert_final_newline = false
+
+[test/**]
+trim_trailing_whitespace = false
+insert_final_newline = false
+
+[templates/**]
+trim_trailing_whitespace = false
+insert_final_newline = false
diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 0000000..7b5d047
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,125 @@
+{
+  "ecmaFeatures": {
+    "modules": true,
+    "experimentalObjectRestSpread": true
+  },
+
+  "env": {
+    "browser": false,
+    "es6": true,
+    "node": true,
+    "mocha": true
+  },
+
+  "globals": {
+    "document": false,
+    "navigator": false,
+    "window": false
+  },
+
+  "rules": {
+    "accessor-pairs": 2,
+    "arrow-spacing": [2, { "before": true, "after": true }],
+    "block-spacing": [2, "always"],
+    "brace-style": [2, "1tbs", { "allowSingleLine": true }],
+    "comma-dangle": [2, "never"],
+    "comma-spacing": [2, { "before": false, "after": true }],
+    "comma-style": [2, "last"],
+    "constructor-super": 2,
+    "curly": [2, "multi-line"],
+    "dot-location": [2, "property"],
+    "eol-last": 2,
+    "eqeqeq": [2, "allow-null"],
+    "generator-star-spacing": [2, { "before": true, "after": true }],
+    "handle-callback-err": [2, "^(err|error)$" ],
+    "indent": [2, 2, { "SwitchCase": 1 }],
+    "key-spacing": [2, { "beforeColon": false, "afterColon": true }],
+    "new-cap": [2, { "newIsCap": true, "capIsNew": false }],
+    "new-parens": 2,
+    "no-array-constructor": 2,
+    "no-caller": 2,
+    "no-class-assign": 2,
+    "no-cond-assign": 2,
+    "no-const-assign": 2,
+    "no-control-regex": 2,
+    "no-debugger": 2,
+    "no-delete-var": 2,
+    "no-dupe-args": 2,
+    "no-dupe-class-members": 2,
+    "no-dupe-keys": 2,
+    "no-duplicate-case": 2,
+    "no-empty-character-class": 2,
+    "no-empty-label": 2,
+    "no-eval": 2,
+    "no-ex-assign": 2,
+    "no-extend-native": 2,
+    "no-extra-bind": 2,
+    "no-extra-boolean-cast": 2,
+    "no-extra-parens": [2, "functions"],
+    "no-fallthrough": 2,
+    "no-floating-decimal": 2,
+    "no-func-assign": 2,
+    "no-implied-eval": 2,
+    "no-inner-declarations": [2, "functions"],
+    "no-invalid-regexp": 2,
+    "no-irregular-whitespace": 2,
+    "no-iterator": 2,
+    "no-label-var": 2,
+    "no-labels": 2,
+    "no-lone-blocks": 2,
+    "no-mixed-spaces-and-tabs": 2,
+    "no-multi-spaces": 2,
+    "no-multi-str": 2,
+    "no-multiple-empty-lines": [2, { "max": 1 }],
+    "no-native-reassign": 2,
+    "no-negated-in-lhs": 2,
+    "no-new": 2,
+    "no-new-func": 2,
+    "no-new-object": 2,
+    "no-new-require": 2,
+    "no-new-wrappers": 2,
+    "no-obj-calls": 2,
+    "no-octal": 2,
+    "no-octal-escape": 2,
+    "no-proto": 0,
+    "no-redeclare": 2,
+    "no-regex-spaces": 2,
+    "no-return-assign": 2,
+    "no-self-compare": 2,
+    "no-sequences": 2,
+    "no-shadow-restricted-names": 2,
+    "no-spaced-func": 2,
+    "no-sparse-arrays": 2,
+    "no-this-before-super": 2,
+    "no-throw-literal": 2,
+    "no-trailing-spaces": 0,
+    "no-undef": 2,
+    "no-undef-init": 2,
+    "no-unexpected-multiline": 2,
+    "no-unneeded-ternary": [2, { "defaultAssignment": false }],
+    "no-unreachable": 2,
+    "no-unused-vars": [2, { "vars": "all", "args": "none" }],
+    "no-useless-call": 0,
+    "no-with": 2,
+    "one-var": [0, { "initialized": "never" }],
+    "operator-linebreak": [0, "after", { "overrides": { "?": "before", ":": "before" } }],
+    "padded-blocks": [0, "never"],
+    "quotes": [2, "single", "avoid-escape"],
+    "radix": 2,
+    "semi": [2, "always"],
+    "semi-spacing": [2, { "before": false, "after": true }],
+    "space-after-keywords": [2, "always"],
+    "space-before-blocks": [2, "always"],
+    "space-before-function-paren": [2, "never"],
+    "space-before-keywords": [2, "always"],
+    "space-in-parens": [2, "never"],
+    "space-infix-ops": 2,
+    "space-return-throw-case": 2,
+    "space-unary-ops": [2, { "words": true, "nonwords": false }],
+    "spaced-comment": [0, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }],
+    "use-isnan": 2,
+    "valid-typeof": 2,
+    "wrap-iife": [2, "any"],
+    "yoda": [2, "never"]
+  }
+}
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..759c2c5
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,14 @@
+# Enforce Unix newlines
+*.*     text eol=lf
+*.css   text eol=lf
+*.html  text eol=lf
+*.js    text eol=lf
+*.json  text eol=lf
+*.less  text eol=lf
+*.md    text eol=lf
+*.yml   text eol=lf
+
+*.jpg binary
+*.gif binary
+*.png binary
+*.jpeg binary
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..7fd3a1a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,53 @@
+# Numerous always-ignore extensions
+*.csv
+*.dat
+*.diff
+*.err
+*.gz
+*.log
+*.orig
+*.out
+*.pid
+*.rej
+*.seed
+*.swo
+*.swp
+*.vi
+*.yo-rc.json
+*.zip
+*~
+.ruby-version
+lib-cov
+
+# OS or Editor folders
+*.esproj
+*.sublime-project
+*.sublime-workspace
+._*
+.cache
+.DS_Store
+.idea
+.project
+.settings
+.tmproj
+nbproject
+Thumbs.db
+
+# Komodo
+*.komodoproject
+.komodotools
+
+# grunt-html-validation
+validation-status.json
+validation-report.json
+
+# Vendor packages
+node_modules
+bower_components
+vendor
+
+# General folders and files to ignore
+_gh_pages
+tmp
+temp
+TODO.md
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..d6e658e
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,10 @@
+sudo: false
+language: node_js
+node_js:
+  - "stable"
+  - "0.12"
+  - "0.10"
+matrix:
+  fast_finish: true
+  allow_failures:
+    - node_js: "0.10"
diff --git a/.verb.md b/.verb.md
new file mode 100644
index 0000000..5269483
--- /dev/null
+++ b/.verb.md
@@ -0,0 +1,49 @@
+# {%= name %} {%= badge("fury") %} {%= badge("travis") %}
+
+> {%= description %}
+
+## Install
+{%= include("install-npm", {save: true}) %}
+
+## Usage
+
+```js
+var normalize = require('{%= name %}');
+
+normalize('\\foo\\bar\\baz\\');
+//=> '/foo/bar/baz'
+
+normalize('./foo/bar/baz/');
+//=> './foo/bar/baz'
+```
+
+Pass `false` as the last argument to **not** strip trailing slashes:
+
+```js
+normalize('./foo/bar/baz/', false);
+//=> './foo/bar/baz/'
+
+normalize('foo\\bar\\baz\\', false);
+//=> 'foo/bar/baz/'
+```
+
+## Related
+{%= verb.related.description %}
+{%= related(verb.related.list) %}
+
+## Running tests
+{%= include("tests") %}
+
+## Contributing
+{%= include("contributing") %}
+
+## Author
+{%= include("author") %}
+
+## License
+{%= copyright() %}
+{%= license() %}
+
+***
+
+{%= include("footer") %}
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..fa30c4c
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014-2015, Jon Schlinkert.
+
+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.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e75d4bd
--- /dev/null
+++ b/README.md
@@ -0,0 +1,75 @@
+# normalize-path [![NPM version](https://badge.fury.io/js/normalize-path.svg)](http://badge.fury.io/js/normalize-path)  [![Build Status](https://travis-ci.org/jonschlinkert/normalize-path.svg)](https://travis-ci.org/jonschlinkert/normalize-path)
+
+> Normalize file path slashes to be unix-like forward slashes. Also condenses repeat slashes to a single slash and removes and trailing slashes.
+
+## Install
+
+Install with [npm](https://www.npmjs.com/)
+
+```sh
+$ npm i normalize-path --save
+```
+
+## Usage
+
+```js
+var normalize = require('normalize-path');
+
+normalize('\\foo\\bar\\baz\\');
+//=> '/foo/bar/baz'
+
+normalize('./foo/bar/baz/');
+//=> './foo/bar/baz'
+```
+
+Pass `false` as the last argument to **not** strip trailing slashes:
+
+```js
+normalize('./foo/bar/baz/', false);
+//=> './foo/bar/baz/'
+
+normalize('foo\\bar\\baz\\', false);
+//=> 'foo/bar/baz/'
+```
+
+## Related
+
+Other useful libraries for working with paths in node.js:
+
+* [contains-path](https://www.npmjs.com/package/contains-path): Return true if a file path contains the given path. | [homepage](https://github.com/jonschlinkert/contains-path)
+* [ends-with](https://www.npmjs.com/package/ends-with): Returns `true` if the given `string` or `array` ends with `suffix` using strict equality for… [more](https://www.npmjs.com/package/ends-with) | [homepage](https://github.com/jonschlinkert/ends-with)
+* [is-absolute](https://www.npmjs.com/package/is-absolute): Returns true if a file path is absolute. | [homepage](https://github.com/jonschlinkert/is-absolute)
+* [is-relative](https://www.npmjs.com/package/is-relative): Returns `true` if the path appears to be relative. | [homepage](https://github.com/jonschlinkert/is-relative)
+* [parse-filepath](https://www.npmjs.com/package/parse-filepath): Parse a filepath into an object. Falls back on the native node.js `path.parse` method if… [more](https://www.npmjs.com/package/parse-filepath) | [homepage](https://github.com/jonschlinkert/parse-filepath)
+* [path-ends-with](https://www.npmjs.com/package/path-ends-with): Return `true` if a file path ends with the given string/suffix. | [homepage](https://github.com/jonschlinkert/path-ends-with)
+* [path-segments](https://www.npmjs.com/package/path-segments): Get n specific segments of a file path, e.g. first 2, last 3, etc. | [homepage](https://github.com/jonschlinkert/path-segments)
+* [rewrite-ext](https://www.npmjs.com/package/rewrite-ext): Automatically re-write the destination extension of a filepath based on the source extension. e.g … [more](https://www.npmjs.com/package/rewrite-ext) | [homepage](https://github.com/jonschlinkert/rewrite-ext)
+* [unixify](https://www.npmjs.com/package/unixify): Convert Windows file paths to unix paths. | [homepage](https://github.com/jonschlinkert/unixify)
+
+## Running tests
+
+Install dev dependencies:
+
+```sh
+$ npm i -d && npm test
+```
+
+## Contributing
+
+Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/normalize-path/issues/new).
+
+## Author
+
+**Jon Schlinkert**
+
++ [github/jonschlinkert](https://github.com/jonschlinkert)
++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
+
+## License
+
+Copyright © 2015 Jon Schlinkert
+Released under the MIT license.
+
+***
+
+_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on November 17, 2015._
\ No newline at end of file
diff --git a/benchmark/code/current.js b/benchmark/code/current.js
new file mode 100644
index 0000000..24b4202
--- /dev/null
+++ b/benchmark/code/current.js
@@ -0,0 +1 @@
+module.exports = require('../..');
\ No newline at end of file
diff --git a/benchmark/code/no-regex.js b/benchmark/code/no-regex.js
new file mode 100644
index 0000000..9daaaaf
--- /dev/null
+++ b/benchmark/code/no-regex.js
@@ -0,0 +1,31 @@
+module.exports = function normalize(str) {
+  str = replace(str, '\\', '/');
+  str = replace(str, '//', '/');
+
+  var last = str[str.length - 1];
+
+  if (str[0] === '.' && str[1] === '/') {
+    str = str.substr(2, str.length - 1);
+  }
+
+  if (last === '/') {
+    str = str.substr(0, str.length - 1);
+  }
+
+  return str.toLowerCase();
+};
+
+
+function replace(str, pattern, replacement) {
+  var i, from = 0;
+
+  while (str.indexOf(pattern, from) !== -1) {
+    i = str.indexOf(pattern, from);
+    from = i + pattern.length;
+    str = str.substr(0, i)
+      + replacement
+      + str.substr(from, str.length);
+    from = i + replacement.length;
+  }
+  return str;
+}
\ No newline at end of file
diff --git a/benchmark/code/node-path.js b/benchmark/code/node-path.js
new file mode 100644
index 0000000..31ed727
--- /dev/null
+++ b/benchmark/code/node-path.js
@@ -0,0 +1,10 @@
+var path = require('path');
+path.sep = '/';
+
+module.exports = function(fp, stripTrailing) {
+  fp = path.normalize(fp).replace(/\\+/g, '/');
+  if (stripTrailing === false) {
+    return fp;
+  }
+  return fp.replace(/\/$/g, '');
+};
\ No newline at end of file
diff --git a/benchmark/code/regex.js b/benchmark/code/regex.js
new file mode 100644
index 0000000..cc3cfac
--- /dev/null
+++ b/benchmark/code/regex.js
@@ -0,0 +1,8 @@
+module.exports = function(fp, stripTrailing) {
+  fp = fp.replace(/[\\\/]+/g, '/');
+  fp = fp.replace(/^\.\//g, '');
+  if (stripTrailing === false) {
+    return fp;
+  }
+  return fp.replace(/\/$/g, '');
+};
diff --git a/benchmark/code/slice-trailing.js b/benchmark/code/slice-trailing.js
new file mode 100644
index 0000000..071dd21
--- /dev/null
+++ b/benchmark/code/slice-trailing.js
@@ -0,0 +1,11 @@
+module.exports = function(fp, stripTrailing) {
+  fp = fp.replace(/[\\\/]+/g, '/');
+  fp = fp.replace(/^\.\//g, '');
+  if (stripTrailing === false) {
+    return fp;
+  }
+
+  return fp.slice(-1) === '/'
+    ? fp.slice(0, fp.length -1)
+    : fp;
+};
diff --git a/benchmark/code/split.js b/benchmark/code/split.js
new file mode 100644
index 0000000..168e41d
--- /dev/null
+++ b/benchmark/code/split.js
@@ -0,0 +1,7 @@
+module.exports = function normalize(str) {
+  str = str.split('\\').join('//');
+  if (str[str.length - 1] === '/') {
+    return str.slice(0, str.length - 1);
+  }
+  return str;
+};
diff --git a/benchmark/code/while.js b/benchmark/code/while.js
new file mode 100644
index 0000000..8cb0b77
--- /dev/null
+++ b/benchmark/code/while.js
@@ -0,0 +1,40 @@
+module.exports = function normalize(str, strip) {
+  var len = str.length, i = -1;
+  var res = '';
+  var prev;
+
+  while (++i < len) {
+    var ch = str[i];
+
+    if (i === 0) {
+      if (ch === '.' && str[i + 1] === '/') {
+        i++;
+        continue;
+      }
+    }
+
+    var is = isSlash(ch);
+    if (i === len - 1 && is) {
+      if (strip !== false) {
+        if (prev) res = res.slice(0, res.length -1);
+        continue;
+      }
+    }
+
+    if (is) {
+      if (prev) continue;
+      res += '/';
+    } else {
+      res += ch;
+    }
+
+    prev = is;
+  }
+
+  return res;
+};
+
+
+function isSlash(ch) {
+  return ch === '\\' || ch === '/';
+}
\ No newline at end of file
diff --git a/benchmark/fixtures/long.js b/benchmark/fixtures/long.js
new file mode 100644
index 0000000..599f875
--- /dev/null
+++ b/benchmark/fixtures/long.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * /user/docs/letter.txt'
+ */
+
+module.exports = ['\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\doc [...]
\ No newline at end of file
diff --git a/benchmark/fixtures/path-0.js b/benchmark/fixtures/path-0.js
new file mode 100644
index 0000000..0cf8b95
--- /dev/null
+++ b/benchmark/fixtures/path-0.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * 'e:/foo/bar/baz'
+ */
+
+module.exports = ['E://foo//bar//baz'];
\ No newline at end of file
diff --git a/benchmark/fixtures/path-1.js b/benchmark/fixtures/path-1.js
new file mode 100644
index 0000000..3934851
--- /dev/null
+++ b/benchmark/fixtures/path-1.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * 'e:/foo/bar/baz'
+ */
+
+module.exports = ['E://foo//bar//baz//'];
\ No newline at end of file
diff --git a/benchmark/fixtures/path-10.js b/benchmark/fixtures/path-10.js
new file mode 100644
index 0000000..f17f937
--- /dev/null
+++ b/benchmark/fixtures/path-10.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * 'c:/user/docs/letter.txt'
+ */
+
+module.exports = ['C:\\user\\docs\\Letter.txt'];
\ No newline at end of file
diff --git a/benchmark/fixtures/path-11.js b/benchmark/fixtures/path-11.js
new file mode 100644
index 0000000..cd8bb5f
--- /dev/null
+++ b/benchmark/fixtures/path-11.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * /user/docs/letter.txt'
+ */
+
+module.exports = ['/user/docs/Letter.txt'];
\ No newline at end of file
diff --git a/benchmark/fixtures/path-12.js b/benchmark/fixtures/path-12.js
new file mode 100644
index 0000000..b59db7e
--- /dev/null
+++ b/benchmark/fixtures/path-12.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * 'c:letter.txt'
+ */
+
+module.exports = ['C:Letter.txt'];
\ No newline at end of file
diff --git a/benchmark/fixtures/path-13.js b/benchmark/fixtures/path-13.js
new file mode 100644
index 0000000..fd775df
--- /dev/null
+++ b/benchmark/fixtures/path-13.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * /server01/user/docs/letter.txt'
+ */
+
+module.exports = ['\\Server01\\user\\docs\\Letter.txt'];
\ No newline at end of file
diff --git a/benchmark/fixtures/path-14.js b/benchmark/fixtures/path-14.js
new file mode 100644
index 0000000..c13f2f4
--- /dev/null
+++ b/benchmark/fixtures/path-14.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * /unc/server01/user/docs/letter.txt'
+ */
+
+module.exports = ['\\?\\UNC\\Server01\\user\\docs\\Letter.txt'];
\ No newline at end of file
diff --git a/benchmark/fixtures/path-15.js b/benchmark/fixtures/path-15.js
new file mode 100644
index 0000000..1f11569
--- /dev/null
+++ b/benchmark/fixtures/path-15.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * /c:/user/docs/letter.txt'
+ */
+
+module.exports = ['\\?\\C:\\user\\docs\\Letter.txt'];
\ No newline at end of file
diff --git a/benchmark/fixtures/path-16.js b/benchmark/fixtures/path-16.js
new file mode 100644
index 0000000..3115f02
--- /dev/null
+++ b/benchmark/fixtures/path-16.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * 'c:/user/docs/somefile.ext:alternate_stream_name'
+ */
+
+module.exports = ['C:\\user\\docs\\somefile.ext:alternate_stream_name'];
\ No newline at end of file
diff --git a/benchmark/fixtures/path-17.js b/benchmark/fixtures/path-17.js
new file mode 100644
index 0000000..8e5d71f
--- /dev/null
+++ b/benchmark/fixtures/path-17.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * 'cwd'
+ */
+
+module.exports = ['./cwd'];
\ No newline at end of file
diff --git a/benchmark/fixtures/path-18.js b/benchmark/fixtures/path-18.js
new file mode 100644
index 0000000..8af5768
--- /dev/null
+++ b/benchmark/fixtures/path-18.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * '/grandparent'
+ */
+
+module.exports = ['../../grandparent'];
\ No newline at end of file
diff --git a/benchmark/fixtures/path-2.js b/benchmark/fixtures/path-2.js
new file mode 100644
index 0000000..33edf7c
--- /dev/null
+++ b/benchmark/fixtures/path-2.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * 'e:/foo/bar/baz'
+ */
+
+module.exports = ['E:/foo/bar/baz/'];
\ No newline at end of file
diff --git a/benchmark/fixtures/path-3.js b/benchmark/fixtures/path-3.js
new file mode 100644
index 0000000..b0e77ac
--- /dev/null
+++ b/benchmark/fixtures/path-3.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * 'e:/foo/bar/baz'
+ */
+
+module.exports = ['E://foo\\bar\\baz'];
\ No newline at end of file
diff --git a/benchmark/fixtures/path-4.js b/benchmark/fixtures/path-4.js
new file mode 100644
index 0000000..6decad0
--- /dev/null
+++ b/benchmark/fixtures/path-4.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * 'foo/bar/baz'
+ */
+
+module.exports = ['foo\\bar\\baz'];
\ No newline at end of file
diff --git a/benchmark/fixtures/path-5.js b/benchmark/fixtures/path-5.js
new file mode 100644
index 0000000..316cfb3
--- /dev/null
+++ b/benchmark/fixtures/path-5.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * 'foo/bar/baz'
+ */
+
+module.exports = ['foo\\bar\\baz\\'];
\ No newline at end of file
diff --git a/benchmark/fixtures/path-6.js b/benchmark/fixtures/path-6.js
new file mode 100644
index 0000000..ae60fef
--- /dev/null
+++ b/benchmark/fixtures/path-6.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * 'e:/foo/bar/baz'
+ */
+
+module.exports = ['E://foo/bar\\baz'];
\ No newline at end of file
diff --git a/benchmark/fixtures/path-7.js b/benchmark/fixtures/path-7.js
new file mode 100644
index 0000000..918e4b3
--- /dev/null
+++ b/benchmark/fixtures/path-7.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * 'e:/foo/bar/baz'
+ */
+
+module.exports = ['E:\\\\foo/bar\\baz'];
\ No newline at end of file
diff --git a/benchmark/fixtures/path-8.js b/benchmark/fixtures/path-8.js
new file mode 100644
index 0000000..8eff40e
--- /dev/null
+++ b/benchmark/fixtures/path-8.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * /foo/bar/baz'
+ */
+
+module.exports = ['//foo/bar\\baz'];
\ No newline at end of file
diff --git a/benchmark/fixtures/path-9.js b/benchmark/fixtures/path-9.js
new file mode 100644
index 0000000..4762548
--- /dev/null
+++ b/benchmark/fixtures/path-9.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * /foo/bar/baz'
+ */
+
+module.exports = ['//foo\\bar\\baz'];
\ No newline at end of file
diff --git a/benchmark/fixtures/short.js b/benchmark/fixtures/short.js
new file mode 100644
index 0000000..61c90c4
--- /dev/null
+++ b/benchmark/fixtures/short.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * /user/docs/letter.txt'
+ */
+
+module.exports = ['\\user\\docs\\Letter.txt'];
\ No newline at end of file
diff --git a/benchmark/fixtures/trailing.js b/benchmark/fixtures/trailing.js
new file mode 100644
index 0000000..1643cc4
--- /dev/null
+++ b/benchmark/fixtures/trailing.js
@@ -0,0 +1,7 @@
+'use strict';
+
+/**
+ * /user/docs/letter.txt'
+ */
+
+module.exports = ['a/b/c/d/e/f/g/', true];
\ No newline at end of file
diff --git a/benchmark/fixtures/unix.js b/benchmark/fixtures/unix.js
new file mode 100644
index 0000000..b3333ba
--- /dev/null
+++ b/benchmark/fixtures/unix.js
@@ -0,0 +1 @@
+module.exports = ['/Users/jonschlinkert/dev/path-utils/normalize-path/benchmark/index.js'];
\ No newline at end of file
diff --git a/benchmark/fixtures/win.js b/benchmark/fixtures/win.js
new file mode 100644
index 0000000..73aa8b3
--- /dev/null
+++ b/benchmark/fixtures/win.js
@@ -0,0 +1 @@
+module.exports = ['C:\\Users\\jonschlinkert\\dev\\path-utils\\normalize-path\\benchmark\\index.js'];
\ No newline at end of file
diff --git a/benchmark/index.js b/benchmark/index.js
new file mode 100644
index 0000000..78eb108
--- /dev/null
+++ b/benchmark/index.js
@@ -0,0 +1,12 @@
+'use strict';
+
+var Suite = require('benchmarked');
+
+var suite = new Suite({
+  result: true,
+  fixtures: 'fixtures/{unix,win}.js',
+  add: 'code/{current,while}.js',
+  cwd: __dirname
+});
+
+suite.run();
\ No newline at end of file
diff --git a/bower.json b/bower.json
new file mode 100644
index 0000000..4d080c7
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,30 @@
+{
+  "name": "normalize-path",
+  "description": "Normalize file path slashes to be unix-like forward slashes. Also condenses repeat slashes to a single slash and removes and trailing slashes.",
+  "repository": "jonschlinkert/normalize-path",
+  "license": "MIT",
+  "homepage": "https://github.com/jonschlinkert/normalize-path",
+  "authors": [
+    "Jon Schlinkert (https://github.com/jonschlinkert)"
+  ],
+  "main": [
+    "index.js"
+  ],
+  "devDependencies": {
+    "benchmarked": "^0.1.1",
+    "mocha": "*"
+  },
+  "keywords": [
+    "backslash",
+    "file",
+    "filepath",
+    "fp",
+    "normalize",
+    "path",
+    "slash",
+    "slashes",
+    "trailing",
+    "unix",
+    "urix"
+  ]
+}
\ No newline at end of file
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..137f601
--- /dev/null
+++ b/index.js
@@ -0,0 +1,17 @@
+/*!
+ * normalize-path <https://github.com/jonschlinkert/normalize-path>
+ *
+ * Copyright (c) 2014-2015, Jon Schlinkert.
+ * Licensed under the MIT License
+ */
+
+module.exports = function normalizePath(str, stripTrailing) {
+  if (typeof str !== 'string') {
+    throw new TypeError('expected a string');
+  }
+  str = str.replace(/[\\\/]+/g, '/');
+  if (stripTrailing !== false) {
+    str = str.replace(/\/$/, '');
+  }
+  return str;
+};
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..44dc399
--- /dev/null
+++ b/package.json
@@ -0,0 +1,59 @@
+{
+  "name": "normalize-path",
+  "description": "Normalize file path slashes to be unix-like forward slashes. Also condenses repeat slashes to a single slash and removes and trailing slashes.",
+  "version": "2.0.1",
+  "homepage": "https://github.com/jonschlinkert/normalize-path",
+  "author": "Jon Schlinkert (https://github.com/jonschlinkert)",
+  "repository": "jonschlinkert/normalize-path",
+  "bugs": {
+    "url": "https://github.com/jonschlinkert/normalize-path/issues"
+  },
+  "license": "MIT",
+  "files": [
+    "index.js"
+  ],
+  "main": "index.js",
+  "engines": {
+    "node": ">=0.10.0"
+  },
+  "scripts": {
+    "test": "mocha"
+  },
+  "devDependencies": {
+    "benchmarked": "^0.1.1",
+    "minimist": "^1.2.0",
+    "mocha": "*"
+  },
+  "keywords": [
+    "backslash",
+    "file",
+    "filepath",
+    "fix",
+    "forward",
+    "fp",
+    "fs",
+    "normalize",
+    "path",
+    "slash",
+    "slashes",
+    "trailing",
+    "unix",
+    "urix"
+  ],
+  "verb": {
+    "related": {
+      "list": [
+        "rewrite-ext",
+        "contains-path",
+        "ends-with",
+        "path-ends-with",
+        "path-segments",
+        "is-absolute",
+        "is-relative",
+        "parse-filepath",
+        "unixify"
+      ],
+      "description": "Other useful libraries for working with paths in node.js:"
+    }
+  }
+}
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..b598e72
--- /dev/null
+++ b/test.js
@@ -0,0 +1,83 @@
+/*!
+ * normalize-path <https://github.com/jonschlinkert/normalize-path>
+ *
+ * Copyright (c) 2014-2015, Jon Schlinkert.
+ * Licensed under the MIT License
+ */
+
+require('mocha');
+var path = require('path');
+var argv = require('minimist')(process.argv.slice(2));
+var assert = require('assert');
+var normalize = require('./');
+
+if (argv.bench) {
+  var b = path.join(__dirname, 'benchmark/code', argv.bench);
+  console.log(b);
+  normalize = require(b);
+}
+
+describe('normalize:', function () {
+  it('should normalize "E://foo//bar//baz"', function() {
+    assert.equal(normalize('E://foo//bar//baz'), 'E:/foo/bar/baz');
+  });
+  it('should normalize "E://foo//bar//baz//"', function() {
+    assert.equal(normalize('E://foo//bar//baz//'), 'E:/foo/bar/baz');
+  });
+  it('should normalize "E:/foo/bar/baz/"', function() {
+    assert.equal(normalize('E:/foo/bar/baz/'), 'E:/foo/bar/baz');
+  });
+  it('should normalize "E://foo\\bar\\baz"', function() {
+    assert.equal(normalize('E://foo\\bar\\baz'), 'E:/foo/bar/baz');
+  });
+  it('should normalize "foo\\bar\\baz"', function() {
+    assert.equal(normalize('foo\\bar\\baz'), 'foo/bar/baz');
+  });
+  it('should normalize "foo\\bar\\baz\\"', function() {
+    assert.equal(normalize('foo\\bar\\baz\\'), 'foo/bar/baz');
+  });
+  it('should normalize "E://foo/bar\\baz"', function() {
+    assert.equal(normalize('E://foo/bar\\baz'), 'E:/foo/bar/baz');
+  });
+  it('should normalize "E:\\\\foo/bar\\baz"', function() {
+    assert.equal(normalize('E:\\\\foo/bar\\baz'), 'E:/foo/bar/baz');
+  });
+  it('should normalize "foo/bar\\baz"', function() {
+    assert.equal(normalize('//foo/bar\\baz'), '/foo/bar/baz');
+  });
+  it('should normalize "foo\\bar\\baz"', function() {
+    assert.equal(normalize('//foo\\bar\\baz'), '/foo/bar/baz');
+  });
+  it('should normalize "C:\\user\\docs\\Letter.txt"', function() {
+    assert.equal(normalize('C:\\user\\docs\\Letter.txt'), 'C:/user/docs/Letter.txt');
+  });
+  it('should normalize "user/docs/Letter.txt"', function() {
+    assert.equal(normalize('/user/docs/Letter.txt'), '/user/docs/Letter.txt');
+  });
+  it('should normalize "C:Letter.txt"', function() {
+    assert.equal(normalize('C:Letter.txt'), 'C:Letter.txt');
+  });
+  it('should normalize "Server01\\user\\docs\\Letter.txt"', function() {
+    assert.equal(normalize('\\Server01\\user\\docs\\Letter.txt'), '/Server01/user/docs/Letter.txt');
+  });
+  it('should normalize "UNC\\Server01\\user\\docs\\Letter.txt"', function() {
+    assert.equal(normalize('\\?\\UNC\\Server01\\user\\docs\\Letter.txt'), '/?/UNC/Server01/user/docs/Letter.txt');
+  });
+  it('should normalize "C:\\user\\docs\\Letter.txt"', function() {
+    assert.equal(normalize('\\?\\C:\\user\\docs\\Letter.txt'), '/?/C:/user/docs/Letter.txt');
+  });
+  it('should normalize "C:\\user\\docs\\somefile.ext:alternate_stream_name"', function() {
+    assert.equal(normalize('C:\\user\\docs\\somefile.ext:alternate_stream_name'), 'C:/user/docs/somefile.ext:alternate_stream_name');
+  });
+  it('should normalize "grandparent"', function() {
+    assert.equal(normalize('../../grandparent'), '../../grandparent');
+  });
+
+  describe('when `false` is passed as the last argument:', function() {
+    it('should not strip trailing slashes', function() {
+      assert.equal(normalize('foo\\bar\\baz\\', false), 'foo/bar/baz/');
+      assert.equal(normalize('foo/bar/baz/', false), 'foo/bar/baz/');
+      assert.equal(normalize('./foo/bar/baz/', false), './foo/bar/baz/');
+    });
+  });
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-normalize-path.git



More information about the Pkg-javascript-commits mailing list