was.js

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 1  →  ?path2? @ 2
File deleted
/trunk/dist/collections/arrays/arrays.js
File deleted
/trunk/dist/formats/csv/csv.js
/trunk/Gruntfile.js
@@ -0,0 +1,90 @@
/*global module:false*/
module.exports = function(grunt) {
 
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %> \n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>;' +
' Licensed <%= pkg.license %> */\n',
// Task configuration.
concat: {
options: {
banner: '<%= banner %>',
stripBanners: true
},
dist: {
src: ['lib/**/*.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
uglify: {
options: {
banner: '<%= banner %>'
},
dist: {
src: '<%= concat.dist.dest %>',
dest: 'dist/<%= pkg.name %>.min.js'
}
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
unused: false,
boss: true,
eqnull: true,
globals: {
'$': false
}
},
gruntfile: {
src: 'Gruntfile.js'
},
lib_test: {
src: ['lib/**/*.js', 'test/**/*.js']
}
},
nodeunit: {
files: ['test/**/*_test.js']
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
lib_test: {
files: '<%= jshint.lib_test.src %>',
tasks: ['jshint:lib_test', 'nodeunit']
}
}
});
 
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
//grunt.loadNpmTasks('grunt-contrib-nodeunit');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
 
// Default task.
grunt.registerTask(
'default',
[
'jshint',
//'nodeunit',
'concat',
'uglify'
]
);
 
};
/trunk/bower.json
@@ -1,10 +1,9 @@
{
"name": "was.js",
"name": "was",
"authors": [
"Wizardry and Steamworks <office@grimore.org>"
],
"description": "Wizardry and Steamworks JavaScript Libraries and Utilities",
"main": "",
"keywords": [
"wizardry",
"steamworks",
@@ -22,8 +21,5 @@
"bower_components",
"test",
"tests"
],
"dependencies": {
"jQuery": "^3.2.1"
}
]
}
/trunk/lib/collections/arrays/arrays.js
@@ -0,0 +1,66 @@
/*************************************************************************/
/* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */
/*************************************************************************/
if (!Array.prototype.product) {
Array.prototype.product = function(b) {
var a = this;
return $.map(
new Array(Math.max(this.length, a.length)),
function(e, i) {
var o = {};
o[a[i]] = b[i];
return o;
});
};
}
$.extend({
product: function(a, b) {
return $.map(
new Array(Math.max(this.length, a.length)),
function(e, i) {
var o = {};
o[a[i]] = b[i];
return o;
});
}
});
 
/*************************************************************************/
/* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */
/*************************************************************************/
if (!Array.prototype.stride) {
Array.prototype.stride = function(s) {
return this.filter(function(e, i) {
return i % s === 0;
});
};
}
$.extend({
stride: function(a, s) {
return a.filter(function(e, i) {
return i % s === 0;
});
}
});
 
/*************************************************************************/
/* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */
/*************************************************************************/
if (!Array.prototype.chunk) {
Array.prototype.chunk = function(n) {
if (!this.length) {
return [];
}
return [this.slice(0, n)]
.concat(this.slice(n).chunk(n));
};
}
$.extend({
chunk: function(a, n) {
if (!a.length) {
return [];
}
return [a.slice(0, n)]
.concat(a.slice(n).chunk(n));
}
});
/trunk/lib/formats/csv/csv.js
@@ -0,0 +1,56 @@
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
function wasCSVToArray(csv) {
var l = [];
var s = [];
var m = "";
do {
var a = csv.charAt(0);
csv = csv.slice(1, csv.length);
if(a === ",") {
if(s[s.length-1] !== '"') {
l.push(m);
m = "";
continue;
}
m += a;
continue;
}
if(a === '"' && csv.charAt(0) === a) {
m += a;
csv = csv.slice(1, csv.length);
continue;
}
if(a === '"') {
if(s[s.length-1] !== a) {
s.push(a);
continue;
}
s.pop();
continue;
}
m += a;
} while(csv !== "");
l.push(m);
return l;
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Wizardry and Steamworks - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
function wasArrayToCSV(a) {
var csv = [];
for(var i=0; i<a.length; ++i) {
var cell = a[i].toString().replace('"', '""');
if(/"\s,\r\n/.test(cell)) {
csv[i] = '"' + cell + '"';
continue;
}
csv[i] = cell;
}
return csv.join();
}
/trunk/package.json
@@ -0,0 +1,39 @@
{
"engines": {
"node": ">= 0.10.0"
},
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-jshint": "~0.11.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-contrib-nodeunit": "~0.4.1",
"grunt-contrib-concat": "~0.4.0",
"grunt-contrib-uglify": "~0.5.0"
},
"name": "was",
"description": "Original repo at http://svn.grimore.org/was.js",
"version": "1.0.0",
"main": "Gruntfile.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "tap test/*.js"
},
"repository": {
"type": "git",
"url": "svn+http://svn.grimore.org/was.js"
},
"keywords": [
"wizardry",
"steamworks",
"javascript",
"jquery",
"library",
"utilities",
"extensions"
],
"author": "Wizardry and Steamworks <office@grimore.org>",
"license": "GPL-3.0",
"homepage": "http://grimore.org"
}