Skip to content

Commit 64c6a61

Browse files
committed
Redefining experimental. Less underscored dirs.
Merge unported / notporting / workbench
1 parent fe02c9c commit 64c6a61

File tree

662 files changed

+208
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

662 files changed

+208
-9
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
_tools/_temp/*
1+
tools/_temp/*
22
_octopress/_deploy
33
nbproject
44
gitup.dat
55
.project
66
.gitup.dat
7-
_tests/node_modules/
7+
tests/node_modules/
8+
.DS_Store

.gitmodules

Whitespace-only changes.

_notporting/filesystem/file_put_contents.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

_tools/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

_unported/pcre/preg_replace_callback.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

_unported/pcre/preg_split.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

_unported/tokenizer/token_get_all.js

Lines changed: 0 additions & 3 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

experimental/filesystem/basename.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function basename (path, suffix) {
2+
// http://kevin.vanzonneveld.net
3+
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
4+
// + improved by: Ash Searle (http://hexmen.com/blog/)
5+
// + improved by: Lincoln Ramsay
6+
// + improved by: djmix
7+
// * example 1: basename('/www/site/home.htm', '.htm');
8+
// * returns 1: 'home'
9+
// * example 2: basename('ecra.php?p=1');
10+
// * returns 2: 'ecra.php?p=1'
11+
var b = path.replace(/^.*[\/\\]/g, '');
12+
13+
if (typeof suffix === 'string' && b.substr(b.length - suffix.length) == suffix) {
14+
b = b.substr(0, b.length - suffix.length);
15+
}
16+
17+
return b;
18+
}

experimental/filesystem/dirname.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function dirname (path) {
2+
// http://kevin.vanzonneveld.net
3+
// + original by: Ozh
4+
// + improved by: XoraX (http://www.xorax.info)
5+
// * example 1: dirname('/etc/passwd');
6+
// * returns 1: '/etc'
7+
// * example 2: dirname('c:/Temp/x');
8+
// * returns 2: 'c:/Temp'
9+
// * example 3: dirname('/dir/test/');
10+
// * returns 3: '/dir'
11+
return path.replace(/\\/g, '/').replace(/\/[^\/]*\/?$/, '');
12+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

experimental/filesystem/pathinfo.js

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
function pathinfo (path, options) {
2+
// http://kevin.vanzonneveld.net
3+
// + original by: Nate
4+
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
5+
// + improved by: Brett Zamir (http://brett-zamir.me)
6+
// + input by: Timo
7+
// % note 1: Inspired by actual PHP source: php5-5.2.6/ext/standard/string.c line #1559
8+
// % note 1: The way the bitwise arguments are handled allows for greater flexibility
9+
// % note 1: & compatability. We might even standardize this code and use a similar approach for
10+
// % note 1: other bitwise PHP functions
11+
// % note 2: php.js tries very hard to stay away from a core.js file with global dependencies, because we like
12+
// % note 2: that you can just take a couple of functions and be on your way.
13+
// % note 2: But by way we implemented this function, if you want you can still declare the PATHINFO_*
14+
// % note 2: yourself, and then you can use: pathinfo('/www/index.html', PATHINFO_BASENAME | PATHINFO_EXTENSION);
15+
// % note 2: which makes it fully compliant with PHP syntax.
16+
// - depends on: dirname
17+
// - depends on: basename
18+
// * example 1: pathinfo('/www/htdocs/index.html', 1);
19+
// * returns 1: '/www/htdocs'
20+
// * example 2: pathinfo('/www/htdocs/index.html', 'PATHINFO_BASENAME');
21+
// * returns 2: 'index.html'
22+
// * example 3: pathinfo('/www/htdocs/index.html', 'PATHINFO_EXTENSION');
23+
// * returns 3: 'html'
24+
// * example 4: pathinfo('/www/htdocs/index.html', 'PATHINFO_FILENAME');
25+
// * returns 4: 'index'
26+
// * example 5: pathinfo('/www/htdocs/index.html', 2 | 4);
27+
// * returns 5: {basename: 'index.html', extension: 'html'}
28+
// * example 6: pathinfo('/www/htdocs/index.html', 'PATHINFO_ALL');
29+
// * returns 6: {dirname: '/www/htdocs', basename: 'index.html', extension: 'html', filename: 'index'}
30+
// * example 7: pathinfo('/www/htdocs/index.html');
31+
// * returns 7: {dirname: '/www/htdocs', basename: 'index.html', extension: 'html', filename: 'index'}
32+
// Working vars
33+
var opt = '',
34+
optName = '',
35+
optTemp = 0,
36+
tmp_arr = {},
37+
cnt = 0,
38+
i = 0;
39+
var have_basename = false,
40+
have_extension = false,
41+
have_filename = false;
42+
43+
// Input defaulting & sanitation
44+
if (!path) {
45+
return false;
46+
}
47+
if (!options) {
48+
options = 'PATHINFO_ALL';
49+
}
50+
51+
// Initialize binary arguments. Both the string & integer (constant) input is
52+
// allowed
53+
var OPTS = {
54+
'PATHINFO_DIRNAME': 1,
55+
'PATHINFO_BASENAME': 2,
56+
'PATHINFO_EXTENSION': 4,
57+
'PATHINFO_FILENAME': 8,
58+
'PATHINFO_ALL': 0
59+
};
60+
// PATHINFO_ALL sums up all previously defined PATHINFOs (could just pre-calculate)
61+
for (optName in OPTS) {
62+
OPTS.PATHINFO_ALL = OPTS.PATHINFO_ALL | OPTS[optName];
63+
}
64+
if (typeof options !== 'number') { // Allow for a single string or an array of string flags
65+
options = [].concat(options);
66+
for (i = 0; i < options.length; i++) {
67+
// Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
68+
if (OPTS[options[i]]) {
69+
optTemp = optTemp | OPTS[options[i]];
70+
}
71+
}
72+
options = optTemp;
73+
}
74+
75+
// Internal Functions
76+
var __getExt = function (path) {
77+
var str = path + '';
78+
var dotP = str.lastIndexOf('.') + 1;
79+
return !dotP ? false : dotP !== str.length ? str.substr(dotP) : '';
80+
};
81+
82+
83+
// Gather path infos
84+
if (options & OPTS.PATHINFO_DIRNAME) {
85+
var dirname = this.dirname(path);
86+
tmp_arr.dirname = dirname === path ? '.' : dirname;
87+
}
88+
89+
if (options & OPTS.PATHINFO_BASENAME) {
90+
if (false === have_basename) {
91+
have_basename = this.basename(path);
92+
}
93+
tmp_arr.basename = have_basename;
94+
}
95+
96+
if (options & OPTS.PATHINFO_EXTENSION) {
97+
if (false === have_basename) {
98+
have_basename = this.basename(path);
99+
}
100+
if (false === have_extension) {
101+
have_extension = __getExt(have_basename);
102+
}
103+
if (false !== have_extension) {
104+
tmp_arr.extension = have_extension;
105+
}
106+
}
107+
108+
if (options & OPTS.PATHINFO_FILENAME) {
109+
if (false === have_basename) {
110+
have_basename = this.basename(path);
111+
}
112+
if (false === have_extension) {
113+
have_extension = __getExt(have_basename);
114+
}
115+
if (false === have_filename) {
116+
have_filename = have_basename.slice(0, have_basename.length - (have_extension ? have_extension.length + 1 : have_extension === false ? 0 : 1));
117+
}
118+
119+
tmp_arr.filename = have_filename;
120+
}
121+
122+
123+
// If array contains only 1 element: return string
124+
cnt = 0;
125+
for (opt in tmp_arr) {
126+
cnt++;
127+
}
128+
if (cnt == 1) {
129+
return tmp_arr[opt];
130+
}
131+
132+
// Return full-blown array
133+
return tmp_arr;
134+
}
File renamed without changes.
File renamed without changes.

experimental/filesystem/realpath.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
function realpath (path) {
2+
// http://kevin.vanzonneveld.net
3+
// + original by: mk.keck
4+
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
5+
// % note 1: Returned path is an url like e.g. 'http://yourhost.tld/path/'
6+
// * example 1: realpath('../.././_supporters/pj_test_supportfile_1.htm');
7+
// * returns 1: 'file:/home/kevin/workspace/_supporters/pj_test_supportfile_1.htm'
8+
var p = 0,
9+
arr = []; /* Save the root, if not given */
10+
var r = this.window.location.href; /* Avoid input failures */
11+
path = (path + '').replace('\\', '/'); /* Check if there's a port in path (like 'http://') */
12+
if (path.indexOf('://') !== -1) {
13+
p = 1;
14+
} /* Ok, there's not a port in path, so let's take the root */
15+
if (!p) {
16+
path = r.substring(0, r.lastIndexOf('/') + 1) + path;
17+
} /* Explode the given path into it's parts */
18+
arr = path.split('/'); /* The path is an array now */
19+
path = []; /* Foreach part make a check */
20+
for (var k in arr) { /* This is'nt really interesting */
21+
if (arr[k] == '.') {
22+
continue;
23+
} /* This reduces the realpath */
24+
if (arr[k] == '..') {
25+
/* But only if there more than 3 parts in the path-array.
26+
* The first three parts are for the uri */
27+
if (path.length > 3) {
28+
path.pop();
29+
}
30+
} /* This adds parts to the realpath */
31+
else {
32+
/* But only if the part is not empty or the uri
33+
* (the first three parts ar needed) was not
34+
* saved */
35+
if ((path.length < 2) || (arr[k] !== '')) {
36+
path.push(arr[k]);
37+
}
38+
}
39+
} /* Returns the absloute path as a string */
40+
return path.join('/');
41+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)