Skip to content

Commit

Permalink
chore(all): prepare release 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Apr 9, 2015
1 parent 191125d commit af2d0a0
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 148 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-path",
"version": "0.4.6",
"version": "0.5.0",
"description": "Utilities for path manipulation.",
"keywords": [
"aurelia",
Expand Down
80 changes: 31 additions & 49 deletions dist/amd/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
define(["exports"], function (exports) {
"use strict";
define(['exports'], function (exports) {
'use strict';

Object.defineProperty(exports, '__esModule', {
value: true
});
exports.relativeToFile = relativeToFile;
exports.join = join;
exports.buildQueryString = buildQueryString;
function trimDots(ary) {
var i, part;
for (i = 0; i < ary.length; ++i) {
part = ary[i];
if (part === ".") {
if (part === '.') {
ary.splice(i, 1);
i -= 1;
} else if (part === "..") {
// If at the start, or previous value is still ..,
// keep them so that when converted to a path it may
// still work when converted to a path, even though
// as an ID it is less than ideal. In larger point
// releases, may be better to just kick out an error.
if (i === 0 || i == 1 && ary[2] === ".." || ary[i - 1] === "..") {
} else if (part === '..') {
if (i === 0 || i == 1 && ary[2] === '..' || ary[i - 1] === '..') {
continue;
} else if (i > 0) {
ary.splice(i - 1, 2);
Expand All @@ -30,24 +28,19 @@ define(["exports"], function (exports) {
function relativeToFile(name, file) {
var lastIndex,
normalizedBaseParts,
fileParts = file && file.split("/");
fileParts = file && file.split('/');

name = name.trim();
name = name.split("/");

if (name[0].charAt(0) === "." && fileParts) {
//Convert file to array, and lop off the last part,
//so that . matches that 'directory' and not name of the file's
//module. For instance, file of 'one/two/three', maps to
//'one/two/three.js', but we want the directory, 'one/two' for
//this normalization.
name = name.split('/');

if (name[0].charAt(0) === '.' && fileParts) {
normalizedBaseParts = fileParts.slice(0, fileParts.length - 1);
name = normalizedBaseParts.concat(name);
}

trimDots(name);

return name.join("/");
return name.join('/');
}

function join(path1, path2) {
Expand All @@ -61,94 +54,83 @@ define(["exports"], function (exports) {
return path1;
}

urlPrefix = path1.indexOf("//") === 0 ? "//" : path1.indexOf("/") === 0 ? "/" : "";
urlPrefix = path1.indexOf('//') === 0 ? '//' : path1.indexOf('/') === 0 ? '/' : '';

url1 = path1.split("/");
url2 = path2.split("/");
url1 = path1.split('/');
url2 = path2.split('/');
url3 = [];

for (i = 0, ii = url1.length; i < ii; ++i) {
if (url1[i] == "..") {
if (url1[i] == '..') {
url3.pop();
} else if (url1[i] == "." || url1[i] == "") {
} else if (url1[i] == '.' || url1[i] == '') {
continue;
} else {
url3.push(url1[i]);
}
}

for (i = 0, ii = url2.length; i < ii; ++i) {
if (url2[i] == "..") {
if (url2[i] == '..') {
url3.pop();
} else if (url2[i] == "." || url2[i] == "") {
} else if (url2[i] == '.' || url2[i] == '') {
continue;
} else {
url3.push(url2[i]);
}
}

return urlPrefix + url3.join("/").replace(/\:\//g, "://");;
return urlPrefix + url3.join('/').replace(/\:\//g, '://');;
}

var r20 = /%20/g,
rbracket = /\[\]$/,
class2type = {};

"Boolean Number String Function Array Date RegExp Object Error".split(" ").forEach(function (name, i) {
class2type["[object " + name + "]"] = name.toLowerCase();
'Boolean Number String Function Array Date RegExp Object Error'.split(' ').forEach(function (name, i) {
class2type['[object ' + name + ']'] = name.toLowerCase();
});

function type(obj) {
if (obj == null) {
return obj + "";
return obj + '';
}

// Support: Android<4.0 (functionish RegExp)
return typeof obj === "object" || typeof obj === "function" ? class2type[toString.call(obj)] || "object" : typeof obj;
return typeof obj === 'object' || typeof obj === 'function' ? class2type[toString.call(obj)] || 'object' : typeof obj;
}

function buildQueryString(a, traditional) {
var prefix,
s = [],
add = function add(key, value) {
// If value is a function, invoke it and return its value
value = typeof value === "function" ? value() : value == null ? "" : value;
s[s.length] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
value = typeof value === 'function' ? value() : value == null ? '' : value;
s[s.length] = encodeURIComponent(key) + '=' + encodeURIComponent(value);
};

for (prefix in a) {
_buildQueryString(prefix, a[prefix], traditional, add);
}

// Return the resulting serialization
return s.join("&").replace(r20, "+");
return s.join('&').replace(r20, '+');
}

function _buildQueryString(prefix, obj, traditional, add) {
var name;

if (Array.isArray(obj)) {
// Serialize array item.
obj.forEach(function (v, i) {
if (traditional || rbracket.test(prefix)) {
// Treat each array item as a scalar.
add(prefix, v);
} else {
// Item is non-scalar (array or object), encode its numeric index.
_buildQueryString(prefix + "[" + (typeof v === "object" ? i : "") + "]", v, traditional, add);
_buildQueryString(prefix + '[' + (typeof v === 'object' ? i : '') + ']', v, traditional, add);
}
});
} else if (!traditional && type(obj) === "object") {
// Serialize object item.
} else if (!traditional && type(obj) === 'object') {
for (name in obj) {
_buildQueryString(prefix + "[" + name + "]", obj[name], traditional, add);
_buildQueryString(prefix + '[' + name + ']', obj[name], traditional, add);
}
} else {
// Serialize scalar item.
add(prefix, obj);
}
}
Object.defineProperty(exports, "__esModule", {
value: true
});
});
80 changes: 31 additions & 49 deletions dist/commonjs/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
"use strict";
'use strict';

Object.defineProperty(exports, '__esModule', {
value: true
});
exports.relativeToFile = relativeToFile;
exports.join = join;
exports.buildQueryString = buildQueryString;
function trimDots(ary) {
var i, part;
for (i = 0; i < ary.length; ++i) {
part = ary[i];
if (part === ".") {
if (part === '.') {
ary.splice(i, 1);
i -= 1;
} else if (part === "..") {
// If at the start, or previous value is still ..,
// keep them so that when converted to a path it may
// still work when converted to a path, even though
// as an ID it is less than ideal. In larger point
// releases, may be better to just kick out an error.
if (i === 0 || i == 1 && ary[2] === ".." || ary[i - 1] === "..") {
} else if (part === '..') {
if (i === 0 || i == 1 && ary[2] === '..' || ary[i - 1] === '..') {
continue;
} else if (i > 0) {
ary.splice(i - 1, 2);
Expand All @@ -29,24 +27,19 @@ function trimDots(ary) {
function relativeToFile(name, file) {
var lastIndex,
normalizedBaseParts,
fileParts = file && file.split("/");
fileParts = file && file.split('/');

name = name.trim();
name = name.split("/");

if (name[0].charAt(0) === "." && fileParts) {
//Convert file to array, and lop off the last part,
//so that . matches that 'directory' and not name of the file's
//module. For instance, file of 'one/two/three', maps to
//'one/two/three.js', but we want the directory, 'one/two' for
//this normalization.
name = name.split('/');

if (name[0].charAt(0) === '.' && fileParts) {
normalizedBaseParts = fileParts.slice(0, fileParts.length - 1);
name = normalizedBaseParts.concat(name);
}

trimDots(name);

return name.join("/");
return name.join('/');
}

function join(path1, path2) {
Expand All @@ -60,93 +53,82 @@ function join(path1, path2) {
return path1;
}

urlPrefix = path1.indexOf("//") === 0 ? "//" : path1.indexOf("/") === 0 ? "/" : "";
urlPrefix = path1.indexOf('//') === 0 ? '//' : path1.indexOf('/') === 0 ? '/' : '';

url1 = path1.split("/");
url2 = path2.split("/");
url1 = path1.split('/');
url2 = path2.split('/');
url3 = [];

for (i = 0, ii = url1.length; i < ii; ++i) {
if (url1[i] == "..") {
if (url1[i] == '..') {
url3.pop();
} else if (url1[i] == "." || url1[i] == "") {
} else if (url1[i] == '.' || url1[i] == '') {
continue;
} else {
url3.push(url1[i]);
}
}

for (i = 0, ii = url2.length; i < ii; ++i) {
if (url2[i] == "..") {
if (url2[i] == '..') {
url3.pop();
} else if (url2[i] == "." || url2[i] == "") {
} else if (url2[i] == '.' || url2[i] == '') {
continue;
} else {
url3.push(url2[i]);
}
}

return urlPrefix + url3.join("/").replace(/\:\//g, "://");;
return urlPrefix + url3.join('/').replace(/\:\//g, '://');;
}

var r20 = /%20/g,
rbracket = /\[\]$/,
class2type = {};

"Boolean Number String Function Array Date RegExp Object Error".split(" ").forEach(function (name, i) {
class2type["[object " + name + "]"] = name.toLowerCase();
'Boolean Number String Function Array Date RegExp Object Error'.split(' ').forEach(function (name, i) {
class2type['[object ' + name + ']'] = name.toLowerCase();
});

function type(obj) {
if (obj == null) {
return obj + "";
return obj + '';
}

// Support: Android<4.0 (functionish RegExp)
return typeof obj === "object" || typeof obj === "function" ? class2type[toString.call(obj)] || "object" : typeof obj;
return typeof obj === 'object' || typeof obj === 'function' ? class2type[toString.call(obj)] || 'object' : typeof obj;
}

function buildQueryString(a, traditional) {
var prefix,
s = [],
add = function add(key, value) {
// If value is a function, invoke it and return its value
value = typeof value === "function" ? value() : value == null ? "" : value;
s[s.length] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
value = typeof value === 'function' ? value() : value == null ? '' : value;
s[s.length] = encodeURIComponent(key) + '=' + encodeURIComponent(value);
};

for (prefix in a) {
_buildQueryString(prefix, a[prefix], traditional, add);
}

// Return the resulting serialization
return s.join("&").replace(r20, "+");
return s.join('&').replace(r20, '+');
}

function _buildQueryString(prefix, obj, traditional, add) {
var name;

if (Array.isArray(obj)) {
// Serialize array item.
obj.forEach(function (v, i) {
if (traditional || rbracket.test(prefix)) {
// Treat each array item as a scalar.
add(prefix, v);
} else {
// Item is non-scalar (array or object), encode its numeric index.
_buildQueryString(prefix + "[" + (typeof v === "object" ? i : "") + "]", v, traditional, add);
_buildQueryString(prefix + '[' + (typeof v === 'object' ? i : '') + ']', v, traditional, add);
}
});
} else if (!traditional && type(obj) === "object") {
// Serialize object item.
} else if (!traditional && type(obj) === 'object') {
for (name in obj) {
_buildQueryString(prefix + "[" + name + "]", obj[name], traditional, add);
_buildQueryString(prefix + '[' + name + ']', obj[name], traditional, add);
}
} else {
// Serialize scalar item.
add(prefix, obj);
}
}
Object.defineProperty(exports, "__esModule", {
value: true
});
}
Loading

0 comments on commit af2d0a0

Please sign in to comment.