Skip to content
This repository has been archived by the owner on Dec 13, 2024. It is now read-only.

Commit

Permalink
Have fixed issue with strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
akopachov committed Dec 19, 2016
1 parent e4a6b13 commit 9e8be7b
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 131 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mini-linq-js",
"version": "1.3.1",
"version": "1.3.2",
"description": "LINQ for JavaScript library, which allows to work with arrays in a more easy way and focus on business logic.",
"main": "dist/mini-linq.full.min.js",
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion dist/mini-linq.full.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mini-linq.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mini-linq.with-knockout.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mini-linq.with-lazy.min.js

Large diffs are not rendered by default.

94 changes: 60 additions & 34 deletions gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,61 @@
module.exports = function(grunt) {
var license = grunt.file.read('LICENSE');
var githubUrl = 'https://github.com/akopachov/mini-linq-js';
grunt.initConfig({
uglify: {
options: {
preserveComments: false,
banner: '/* ! ' + githubUrl + ' */\n/* !\n' + license + '\n */\n'
},
core: {
files: {
'dist/mini-linq.min.js': ['src/mini-linq.js']
}
},
coreAndLazy: {
files: {
'dist/mini-linq.with-lazy.min.js': ['src/mini-linq.js', 'src/mini-linq.lazy.js']
}
},
coreAndKnockout: {
files: {
'dist/mini-linq.with-knockout.min.js': ['src/mini-linq.js', 'src/mini-linq.knockout.js']
}
},
full: {
files: {
'dist/mini-linq.full.min.js': ['src/mini-linq.js', 'src/mini-linq.lazy.js', 'src/mini-linq.knockout.js']
}
}
}
});
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

grunt.registerTask('default', ['uglify']);
module.exports = function(grunt) {
var license = grunt.file.read('LICENSE');
var githubUrl = 'https://github.com/akopachov/mini-linq-js';
grunt.initConfig({
copy: {
core: {
src: 'src/mini-linq.js',
dest: 'dist/mini-linq.min.js',
options: {
process: function (content, srcpath) {
return content.replace('/* ADDITIONAL_ATTACHMENTS */', '');
}
}
},
coreAndLazy: {
src: 'src/mini-linq.js',
dest: 'dist/mini-linq.with-lazy.min.js',
options: {
process: function (content, srcpath) {
return content.replace('/* ADDITIONAL_ATTACHMENTS */', grunt.file.read('src/mini-linq.lazy.js'));
}
}
},
coreAndKnockout: {
src: 'src/mini-linq.js',
dest: 'dist/mini-linq.with-knockout.min.js',
options: {
process: function (content, srcpath) {
return content.replace('/* ADDITIONAL_ATTACHMENTS */', grunt.file.read('src/mini-linq.knockout.js'));
}
}
},
full: {
src: 'src/mini-linq.js',
dest: 'dist/mini-linq.full.min.js',
options: {
process: function (content, srcpath) {
return content.replace('/* ADDITIONAL_ATTACHMENTS */', grunt.file.read('src/mini-linq.lazy.js') + grunt.file.read('src/mini-linq.knockout.js'));
}
}
}
},
uglify: {
options: {
preserveComments: false,
banner: '/* ! ' + githubUrl + ' */\n/* !\n' + license + '\n */\n'
},
build: {
files: [{
expand: true,
cwd: 'dist/',
src: '*.js',
dest: 'dist/'
}]
}
}
});
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

grunt.registerTask('default', ['copy', 'uglify']);
};
68 changes: 36 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
{
"name": "mini-linq-js",
"version": "1.3.1",
"description": "LINQ for JavaScript library, which allows to work with arrays in a more easy way and focus on business logic.",
"homepage": "https://github.com/akopachov/mini-linq-js",
"keywords": ["linq", "array"],
"license": "MIT",
"main": "dist/mini-linq.full.min.js",
"repository" : {
"type" : "git",
"url" : "https://github.com/akopachov/mini-linq-js.git"
},
"author": {
"name" : "Alex Kopachov",
"email" : "alex.kopachov@gmail.com",
"url" : "https://www.linkedin.com/in/akopachov"
},
"files": [
"dist",
"src",
"README.md",
"tests",
"gruntfile.js"
],
"devDependencies": {
"mocha": "^2.5.0",
"unit.js": "^2.0.0",
"grunt": "^1.0.1",
"grunt-contrib-uglify": "^1.0.1",
"matchdep": "^1.0.1"
}
}
{
"name": "mini-linq-js",
"version": "1.3.2",
"description": "LINQ for JavaScript library, which allows to work with arrays in a more easy way and focus on business logic.",
"homepage": "https://github.com/akopachov/mini-linq-js",
"keywords": [
"linq",
"array"
],
"license": "MIT",
"main": "dist/mini-linq.full.min.js",
"repository": {
"type": "git",
"url": "https://github.com/akopachov/mini-linq-js.git"
},
"author": {
"name": "Alex Kopachov",
"email": "alex.kopachov@gmail.com",
"url": "https://www.linkedin.com/in/akopachov"
},
"files": [
"dist",
"src",
"README.md",
"tests",
"gruntfile.js"
],
"devDependencies": {
"grunt": "^1.0.1",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-uglify": "^1.0.1",
"matchdep": "^1.0.1",
"mocha": "^2.5.0",
"unit.js": "^2.0.0"
}
}
4 changes: 3 additions & 1 deletion src/mini-linq.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ SOFTWARE.
return str.trim();
};
var expressionCache = {};
LINQ = {
var LINQ = {
utils: {
parseExpression: function (expression) {
if (typeof (expression) === "function") {
Expand Down Expand Up @@ -617,4 +617,6 @@ SOFTWARE.
Array.prototype[key] = LINQ.methods[key];
}
}

/* ADDITIONAL_ATTACHMENTS */
})();
58 changes: 1 addition & 57 deletions tests/test-core.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,12 @@
if (typeof(require) !== 'undefined') {
require('../src/mini-linq.js');
require('../dist/mini-linq.min.js');
var test = require('unit.js');
} else {
var test = unitjs;
}

var testArray1 = [1, 2, 8, 2, 6, 3, 9, 2, 4];

describe('Core', function() {
it('Structure', function () {
test.object(LINQ)
.hasProperty('utils')
.hasProperty('methods');
test.object(LINQ.methods)
.isNotEmpty()
.matchEach(function(it, key) {
return typeof(it) === 'function';
});
});

it('Expression parser - 1', function() {
var expression = function(x) { return x * x; }
var expressionParsed = LINQ.utils.parseExpression('x => x * x');
var testValue = Math.random() * 99;
test.value(expressionParsed).isFunction();
test.value(expressionParsed(testValue)).is(expression(testValue));
});

it('Expression parser - 2', function() {
var expression = function(x) { return {x: x, xx: x * x}; }
var expressionParsed = LINQ.utils.parseExpression('x => {x : x, xx: x * x}');
var testValue = Math.random() * 99;
test.value(expressionParsed).isFunction();
test.object(expressionParsed(testValue)).is(expression(testValue));
});

it('Expression parser - 3', function() {
var expression = function(x) { var y = 1; y++; return x + y; }
var expressionParsed = LINQ.utils.parseExpression('x => { var y = 1; y++; return x + y;}');
var testValue = Math.random() * 99;
test.value(expressionParsed).isFunction();
test.value(expressionParsed(testValue)).is(expression(testValue));
});

it('Attachment to Array', function() {
var emptyArray = [];
test.object(LINQ.methods)
.isNotEmpty()
.matchEach(function(it, key) {
return emptyArray[key] === it;
});
});

it('isArray method', function() {
test.value(LINQ.utils.isArray([])).isTrue();
test.value(LINQ.utils.isArray([1, '2', true, false, {}, null])).isTrue();
test.value(LINQ.utils.isArray([false])).isTrue();
test.value(LINQ.utils.isArray(true)).isFalse();
test.value(LINQ.utils.isArray({})).isFalse();
test.value(LINQ.utils.isArray('test')).isFalse();
test.value(LINQ.utils.isArray(null)).isFalse();
});
});

describe('Methods', function() {
it('.any', function() {
test.value(testArray1.any('a => a == 2'))
Expand Down
3 changes: 1 addition & 2 deletions tests/test-lazy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
if (typeof(require) !== 'undefined') {
require('../src/mini-linq.js');
require('../src/mini-linq.lazy.js');
require('../dist/mini-linq.with-lazy.min.js');
var test = require('unit.js');
} else {
var test = unitjs;
Expand Down

0 comments on commit 9e8be7b

Please sign in to comment.