Skip to content

Commit

Permalink
Removing unneeded funtions, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Feb 22, 2020
1 parent 30c31d9 commit 3cd35a0
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 87 deletions.
20 changes: 0 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -813,26 +813,6 @@ store.batch(data, 'set').then(function () {
});
```

**transform(input[, fn])**
_Mixed_

Transforms `Map` to `Object`, `Object` to `Map`, `Set` to `Array`, & `Array` to `Set`. Accepts an optional second parameter to perform the
transformation to simplify cross domain issues.

`haro.transform()` is exposed so that you can either duplicate it into the current context with `toString()` &
`new Function()`, or simply re-implement, for situations where you need to supply the transformation `Function`.

```javascript
const store = haro(null, {key: 'guid', index: ['name']}),
data = [{guid: 'abc', name: 'John Doe', age: 30}, {guid: 'def', name: 'Jane Doe', age: 28}];

store.batch(data, 'set').then(function () {
console.log(store.transform(store.indexes)); // {age: {'28': ['def'], '30': ['abc']}, name: {'John Doe': ['abc'], 'Jane Doe': ['def']}}
}, function (e) {
console.error(e.stack || e.message || e);
});
```

**unload([adapter=mongo, key])**
_Promise_

Expand Down
32 changes: 0 additions & 32 deletions lib/haro.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,6 @@
return arr;
}

function cast (input) {
let result;

switch (true) {
case input instanceof Map:
result = {};
input.forEach((value, key) => {
result[key] = cast(value);
});
break;
case input instanceof Set:
result = Array.from(input);
break;
case Array.isArray(input):
result = new Set(input);
break;
case input instanceof Object:
result = new Map(Object.keys(input).map(i => [i, cast(input[i])]));
break;
default:
result = input;
}

return result;
}

function blob (arg) {
return new Blob([arg], {type: "application/javascript"});
}
Expand Down Expand Up @@ -278,7 +252,6 @@
}

const functions = [
cast.toString(),
clone.toString(),
createIndexes.toString(),
each.toString(),
Expand Down Expand Up @@ -805,10 +778,6 @@
return frozen ? Object.freeze(result) : result;
}

transform (input, fn) {
return typeof fn === "function" ? fn(input) : cast(input);
}

async unload (type = "mongo", key = void 0) {
const id = key !== void 0 ? key : this.id;
let result;
Expand Down Expand Up @@ -889,7 +858,6 @@
return obj;
}

factory.transform = cast;
factory.version = "6.0.0";

// Node, AMD & window supported
Expand Down
2 changes: 1 addition & 1 deletion lib/haro.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/haro.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@
return obj;
}

factory.transform = cast;
factory.version = "{{VERSION}}";
4 changes: 0 additions & 4 deletions src/haro.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,6 @@
return frozen ? Object.freeze(result) : result;
}

transform (input, fn) {
return typeof fn === "function" ? fn(input) : cast(input);
}

async unload (type = "mongo", key = void 0) {
const id = key !== void 0 ? key : this.id;
let result;
Expand Down
27 changes: 0 additions & 27 deletions src/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,6 @@
return arr;
}

function cast (input) {
let result;

switch (true) {
case input instanceof Map:
result = {};
input.forEach((value, key) => {
result[key] = cast(value);
});
break;
case input instanceof Set:
result = Array.from(input);
break;
case Array.isArray(input):
result = new Set(input);
break;
case input instanceof Object:
result = new Map(Object.keys(input).map(i => [i, cast(input[i])]));
break;
default:
result = input;
}

return result;
}

function blob (arg) {
return new Blob([arg], {type: "application/javascript"});
}
Expand Down Expand Up @@ -256,7 +230,6 @@
}

const functions = [
cast.toString(),
clone.toString(),
createIndexes.toString(),
each.toString(),
Expand Down

0 comments on commit 3cd35a0

Please sign in to comment.