Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
49 changes: 49 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"extends": ["airbnb", "prettier", "prettier/react"],
"parser": "babel-eslint",
"parserOptions": {"ecmaVersion": 6, "sourceType": "module"},
"env": {"browser": true, "jest": true, "mocha": true, "node": true},
"reportUnusedDisableDirectives": true,
"rules": {
"no-param-reassign-allow-reduce/allow-reduce": 2,
"camelcase": 0,
"class-methods-use-this": 0,
"consistent-return": 0,
"default-case": 0,
"global-require": 0,
"import/default": 0,
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true,
"optionalDependencies": false,
"peerDependencies": true
}
],
"import/prefer-default-export": 0,
"lines-between-class-members": 0,
"max-statements": [2, 15],
"new-cap": 0,
"no-alert": 2,
"no-async-promise-executor": 0,
"no-case-declarations": 0,
"no-control-regex": 0,
"no-console": 1,
"no-extra-boolean-cast": 0,
"no-fallthrough": ["error", {"commentPattern": "break[\\s\\w]*omitted"}],
"no-only-tests/no-only-tests": 2,
"no-param-reassign": 0,
"no-restricted-globals": 0,
"no-restricted-syntax": ["error", "ForInStatement", "LabeledStatement", "WithStatement"],
"no-return-assign": 0,
"no-underscore-dangle": 0,
"no-useless-escape": 0,
"no-useless-return": 0,
"one-var": 0,
"operator-assignment": 0,
"padding-line-between-statements": ["error", {"blankLine": "always", "next": "export", "prev": "const"}],
"prefer-const": 0,
"prefer-promise-reject-errors": 0,
"prefer-template": 0
}
}
26 changes: 9 additions & 17 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
{
"predef": [
"before",
"after",
"it",
"describe",
"beforeEach",
"afterEach"
],
"asi" : false,
"bitwise" : true,
"boss" : false,
"curly" : true,
"predef": ["before", "after", "it", "describe", "beforeEach", "afterEach"],
"asi": false,
"bitwise": true,
"boss": false,
"curly": true,
"debug": false,
"devel": false,
"eqeqeq": false,
"evil": false,
"expr": true,
"forin": false,
"immed": true,
"latedef" : false,
"latedef": false,
"laxbreak": false,
"multistr": true,
"newcap": true,
"noarg": true,
"node" : true,
"node": true,
"noempty": false,
"nonew": true,
"onevar": false,
"plusplus": false,
"regexp": false,
"strict": false,
"sub": false,
"trailing" : true,
"trailing": true,
"undef": true,
"unused": true

}
}
33 changes: 33 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"printWidth": 120,
"arrowParens": "always",
"semi": true,
"useTabs": true,
"tabWidth": 4,
"bracketSpacing": false,
"jsxBracketSameLine": false,
"singleQuote": true,
"trailingComma": "es5",
"overrides": [
{
"files": [".prettierrc", ".eslintrc", ".stylelintrc", ".babelrc"],
"options": {
"parser": "json"
}
},
{
"files": ["*.yaml", "*.yml"],
"options": {
"useTabs": false,
"tabWidth": 2
}
},
{
"files": ["package.json"],
"options": {
"useTabs": false,
"tabWidth": 2
}
}
]
}
15 changes: 7 additions & 8 deletions Collection.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var _ = require('./util');
var Cursor = require('./Cursor');
function noop() {
}
function noop() {}

function Collection(initialArray) {
this._data = initialArray.slice();
Expand All @@ -24,7 +23,7 @@ Collection.prototype.save = function (doc, options, callback) {
callback = options;
}
if (doc._id) {
this.update({_id: doc._id}, doc, { upsert: true }, callback);
this.update({_id: doc._id}, doc, {upsert: true}, callback);
} else {
this.insert(doc, callback);
}
Expand All @@ -36,7 +35,7 @@ Collection.prototype.findOne = function (query, callback) {

Collection.prototype.count = function (query, options, callback) {
if ('function' === typeof options) {
callback = options, options = {};
(callback = options), (options = {});
}
if (options === null) {
options = {};
Expand All @@ -58,7 +57,7 @@ Collection.prototype.toArray = function (callback) {

Collection.prototype.insert = function (doc, options, callback) {
if ('function' === typeof options) {
callback = options, options = {};
(callback = options), (options = {});
}

if (options === null) {
Expand All @@ -76,7 +75,7 @@ Collection.prototype.insert = function (doc, options, callback) {

Collection.prototype.update = function (query, modifier, options, callback) {
if ('function' === typeof options) {
callback = options, options = {};
(callback = options), (options = {});
}

if (options === null) {
Expand Down Expand Up @@ -106,7 +105,7 @@ Collection.prototype.remove = function (query, callback) {

Collection.prototype.findAndModify = function (query, sort, modifier, options, callback) {
if ('function' === typeof options) {
callback = options, options = {};
(callback = options), (options = {});
}

if (options === null) {
Expand All @@ -126,4 +125,4 @@ Collection.prototype.findAndModify = function (query, sort, modifier, options, c
callback(null, doc);
};

module.exports = Collection;
module.exports = Collection;
10 changes: 10 additions & 0 deletions Collection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {Cursor} from './Cursor';

export class Collection<T extends object> {
private items: T[];
constructor(data: T[]) {
this.items = {...data};
}
private restore() {}
public find(query: Record<string, any>): Cursor<T> {}
}
Loading