Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ancient-cursor

Package Overview
Dependencies
Maintainers
3
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ancient-cursor - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

tsconfig.json

23

lib/bundle.js
"use strict";
exports.__esModule = true;
var lodash = require("lodash");
var _ = require("lodash");
function get(data, path) {
var arrayPath = lodash.toPath(path);
return path.length ? lodash.get(data, path) : data;
var arrayPath = _.toPath(path);
return path.length ? _.get(data, path) : data;
}
exports.get = get;
function prepare(container, bundle) {
var bundlePath = lodash.toPath(bundle.path);
var bundlePath = _.toPath(bundle.path);
var oldValue = get(container.data, bundlePath);

@@ -22,3 +22,3 @@ return { oldValue: oldValue, bundlePath: bundlePath };

else {
container.data = lodash.set(container.data || {}, bundlePath, bundle.value);
container.data = _.set(container.data || {}, bundlePath, bundle.value);
}

@@ -43,3 +43,3 @@ var newValue = get(container.data, bundlePath);

var value = get(container.data, bundlePath);
if (!lodash.isArray(value)) {
if (!_.isArray(value)) {
throw new Error("Data by path \"" + bundle.path + "\" is not an array but " + typeof (value) + ".");

@@ -50,2 +50,13 @@ }

return { oldValue: oldValue, newValue: newValue, bundlePath: bundlePath, bundle: bundle, data: container.data };
},
arrayRemove: function (container, bundle) {
var bundlePath = prepare(container, bundle).bundlePath;
var value = get(container.data, bundlePath);
var oldValue = _.clone(value);
if (!_.isArray(value)) {
throw new Error("Data by path \"" + bundle.path + "\" is not an array but " + typeof (value) + ".");
}
_.remove(value, _.matches(bundle.selector));
var newValue = value;
return { oldValue: oldValue, newValue: newValue, bundlePath: bundlePath, bundle: bundle, data: container.data };
}

@@ -52,0 +63,0 @@ };

@@ -17,3 +17,3 @@ "use strict";

function mixin(superClass) {
return /** @class */ (function (_super) {
return (function (_super) {
__extends(ChildsCursorsManager, _super);

@@ -66,3 +66,3 @@ function ChildsCursorsManager() {

exports.MixedChildsCursorsManager = MixedChildsCursorsManager;
var ChildsCursorsManager = /** @class */ (function (_super) {
var ChildsCursorsManager = (function (_super) {
__extends(ChildsCursorsManager, _super);

@@ -69,0 +69,0 @@ function ChildsCursorsManager() {

@@ -65,3 +65,3 @@ "use strict";

function mixin(superClass) {
return /** @class */ (function (_super) {
return (function (_super) {
__extends(Cursor, _super);

@@ -102,3 +102,3 @@ function Cursor() {

exports.MixedCursor = MixedCursor;
var Cursor = /** @class */ (function (_super) {
var Cursor = (function (_super) {
__extends(Cursor, _super);

@@ -105,0 +105,0 @@ function Cursor() {

@@ -16,3 +16,3 @@ "use strict";

function mixin(superClass) {
return /** @class */ (function (_super) {
return (function (_super) {
__extends(CursorsManager, _super);

@@ -31,3 +31,3 @@ function CursorsManager() {

exports.MixedCursorsManager = MixedCursorsManager;
var CursorsManager = /** @class */ (function (_super) {
var CursorsManager = (function (_super) {
__extends(CursorsManager, _super);

@@ -34,0 +34,0 @@ function CursorsManager() {

{
"name": "ancient-cursor",
"version": "0.1.1",
"version": "0.1.2",
"description": "Abstract container of data synchronization.",

@@ -9,5 +9,5 @@ "bugs": "https://github.com/AncientSouls/Cursor/issues",

"scripts": {
"tsc": "rm -rf ./lib ./tests && tsc ./src/*/*.ts --outDir ./ --sourceMap -d true --module CommonJS",
"test": "mocha ./tests/index.js --require source-map-support/register",
"tslint": "tslint -c tslint.json './src/**/*.ts'",
"tsc": "rm -rf ./lib ./tests && ./node_modules/typescript/bin/tsc",
"test": "./node_modules/mocha/bin/mocha ./tests/index.js --require source-map-support/register",
"tslint": "./node_modules/tslint/bin/tslint -c tslint.json './src/**/*.ts'",
"dev-link": "npm link ancient-mixins",

@@ -14,0 +14,0 @@ "dev-test": "(rm -rf .dev && git clone -b dev https://github.com/AncientSouls/AncientSouls.github.io.git .dev && cd .dev && git submodule init && git submodule update && npm run dev-install) && npm link ./ && (cd .dev && npm run dev-use-links && npm run dev-check)"

@@ -10,3 +10,3 @@ "use strict";

bundle_1.bundleParsers.set(container, {
type: 'set()',
type: 'set',
path: 'a.0.b.c',

@@ -20,3 +20,3 @@ value: 234

bundle_1.bundleParsers.unset(container, {
type: 'unset()',
type: 'unset',
path: 'a.0.b.c'

@@ -29,3 +29,3 @@ });

bundle_1.bundleParsers.arraySplice(container, {
type: 'arraySplice()',
type: 'arraySplice',
path: 'a',

@@ -46,2 +46,13 @@ start: 1,

});
it('arrayRemove', function () {
var container = { data: { a: [{ b: { c: 123 } }, { b: { c: 456 } }] } };
bundle_1.bundleParsers.arrayRemove(container, {
type: 'arrayRemove',
path: 'a',
selector: { b: { c: 123 } }
});
chai_1.assert.deepEqual(container.data, { a: [
{ b: { c: 456 } },
] });
});
});

@@ -48,0 +59,0 @@ }

@@ -8,2 +8,4 @@ {

"no-increment-decrement": false,
"no-unused-variable": [true],
"function-name": false,
"variable-name": [

@@ -10,0 +12,0 @@ true,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc