New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

changesets

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

changesets - npm Package Compare versions

Comparing version 0.1.3 to 0.2.0

client-side.js

2

ideas.txt
Astropad, IonWriter, Papyrus, Parchment, Vellum, Parabaik, Slate
MoonSlate, IonSlate
MoonSlate, IonSlate, IonPaper, NightWriter, WarpEdit

@@ -5,0 +5,0 @@ http://googledocs.blogspot.de/2010/09/whats-different-about-new-google-docs_23.html

exports.text = require('./text/index')
exports.Operation = require('./Operation')
exports.Operation = require('./Operation')
if('undefined' != typeof window) window.changesets = exports

@@ -148,3 +148,4 @@ /*!

return this.map(function(op) {
return op.__proto__.constructor.name+' '+op.pos+':'+op.text
if(op.__proto__) return op.__proto__.constructor.name+' '+op.pos+':'+op.text
return (op instanceof Insert? 'Insert' : 'Delete')+' '+op.pos+':'+op.text
})

@@ -180,3 +181,3 @@ }

var packed = this.map(function(op) {
var text = base64_encode(op.text)
var text = op.text.replace('%', '%25').replace(':', '%3A')
, pos = (op.pos).toString(36)

@@ -205,3 +206,3 @@ , accessory = (op.accessory).toString(36)

Changeset.unpack = function(packed) {
var matches = packed.match(/(\+|-)\w+?:[^:\+-]+?:\w+?/g)
var matches = packed.match(/(\+|-)\w+?:[^:]+?:\w+?/g)
if(!matches) throw new Error('Cannot unpack invalid serialized changeset string')

@@ -214,5 +215,5 @@

var pos = parseInt(props[0], 36)
, text = base64_decode(props[1])
, text = url_decode(props[1])
, accessory = parseInt(props[2], 36)
if(type == '-') return cs.push(new Delete(props[0], text, props[2]))
if(type == '-') return cs.push(new Delete(pos, text, accessory))
if(type == '+') return cs.push(new Insert(pos, text, accessory))

@@ -224,12 +225,5 @@ })

function base64_encode(text) {
if('undefined' != typeof window) return btoa(text)
if('undefined' != typeof process) return (new Buffer(text)).toString('base64').replace(/=+/, '')
throw new Error('No base64 implementation available!')
}
function base64_decode(base64) {
if('undefined' != typeof window) return atob(base64)
if('undefined' != typeof process) return (new Buffer(base64, 'base64')).toString()
throw new Error('No base64 implementation available!')
function url_decode(text) {
if('undefined' != typeof window) return decodeURIComponent(text)
return require('querystring').unescape(text)
}

@@ -36,2 +36,4 @@ /*!

exports.Changeset = Changeset
exports.Insert = Insert
exports.Delete = Delete

@@ -38,0 +40,0 @@ /**

{
"name": "changesets",
"version": "0.1.3",
"description": "A Changeset library incorporating an operational transformation (OT) algorithm.",
"version": "0.2.0",
"description": "A Changeset library incorporating an operational transformation (OT) algorithm -- for node and the browser!",
"repository": {

@@ -6,0 +6,0 @@ "type": "git",

@@ -5,2 +5,4 @@

[![Build Status](https://travis-ci.org/marcelklehr/node-changesets.png?branch=master)](https://travis-ci.org/marcelklehr/node-changesets)
*changesets* allows you to easily create changesets and apply them on all sites of a distributed system using Operational Transformation. It was built with the following requirements in mind:

@@ -20,9 +22,14 @@

In your code, `require('changesets')`
## Usage
```
In node, simply require `'changesets'`
```js
var cs = require('changesets')
```
In the browser, you need to load the package as a browserified javascript file...
```
<script type="text/javascript" src="node_modules/changesets/client-side.js"></script>
```
... in order to be able to use the global `changesets` variable
### Constructing and applying changesets

@@ -130,4 +137,5 @@ Construct a changeset between two texts:

* Simplify anyundo (large numbers of changesets have to be transformed against each other and an undo changseset)
* Browsers can run out of memory when en-/decoding large texts in base64, ie. on paste -- it's not ideal
# License
MIT
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