Use coffee-script node module

This required upgrading underscore which to fix issues
with _.isEqual working across objects created from different
documents.

The upgrade required adding a custom _.isEqual extension that
added back support for object's having an isEqual method that
was removed in underscore 1.4.0.
This commit is contained in:
Kevin Sawicki
2013-03-11 13:37:14 -07:00
parent 2212222c47
commit 03b32ec29c
9 changed files with 58 additions and 4650 deletions

View File

@@ -27,7 +27,7 @@ class SnippetExpansion
return if @settingTabStop or bufferChanged
oldTabStops = @tabStopsForBufferPosition(oldBufferPosition)
newTabStops = @tabStopsForBufferPosition(newBufferPosition)
@destroy() unless _.intersect(oldTabStops, newTabStops).length
@destroy() unless _.intersection(oldTabStops, newTabStops).length
placeTabStopMarkers: (startPosition, tabStopRanges) ->
@tabStopMarkers = tabStopRanges.map ({start, end}) =>

View File

@@ -218,7 +218,7 @@ module.exports =
readObject: (path) ->
contents = @read(path)
if @extension(path) is '.cson'
{CoffeeScript} = require 'coffee-script'
CoffeeScript = nodeRequire 'coffee-script'
CoffeeScript.eval(contents, bare: true)
else
JSON.parse(contents)

View File

@@ -61,7 +61,7 @@ exts =
compiled = __read(cacheFilePath)
writeToCache = false
else
{CoffeeScript} = require 'coffee-script'
CoffeeScript = nodeRequire 'coffee-script'
compiled = CoffeeScript.compile(__read(file), filename: file)
writeToCache = true
@@ -76,7 +76,7 @@ getPath = (path) ->
cacheFilePath = getCacheFilePath(path)
unless __exists(cacheFilePath)
{CoffeeScript} = require 'coffee-script'
CoffeeScript = nodeRequire 'coffee-script'
compiled = CoffeeScript.compile(__read(path), filename: path)
createCacheDirectory()
fs.writeFileSync(cacheFilePath, compiled)

View File

@@ -1,5 +1,5 @@
fs = require 'fs'
{CoffeeScript} = require 'coffee-script'
CoffeeScript = require 'coffee-script'
# Settings file looks like:
# editor: # name of class

View File

@@ -131,3 +131,53 @@ _.mixin
for key, value of object
newObject[key] = value if value?
newObject
originalIsEqual = _.isEqual
extendedIsEqual = (a, b, aStack=[], bStack=[]) ->
return originalIsEqual(a, b) if a is b
return originalIsEqual(a, b) if _.isFunction(a) or _.isFunction(b)
return a.isEqual(b) if _.isFunction(a?.isEqual)
return b.isEqual(a) if _.isFunction(b?.isEqual)
stackIndex = aStack.length
while stackIndex--
return bStack[stackIndex] is b if aStack[stackIndex] is a
aStack.push(a)
bStack.push(b)
equal = false
if _.isArray(a) and _.isArray(b) and a.length is b.length
equal = true
for aElement, i in a
unless extendedIsEqual(aElement, b[i], aStack, bStack)
equal = false
break
else if _.isObject(a) and _.isObject(b)
aCtor = a.constructor
bCtor = b.constructor
aCtorValid = _.isFunction(aCtor) and aCtor instanceof aCtor
bCtorValid = _.isFunction(bCtor) and bCtor instanceof bCtor
if aCtor isnt bCtor and not (aCtorValid and bCtorValid)
equal = false
else
aKeyCount = 0
equal = true
for key, aValue of a
continue unless _.has(a, key)
aKeyCount++
unless _.has(b, key) and extendedIsEqual(aValue, b[key], aStack, bStack)
equal = false
break
if equal
bKeyCount = 0
for key, bValue of b
bKeyCount++ if _.has(b, key)
equal = aKeyCount is bKeyCount
else
equal = originalIsEqual(a, b)
aStack.pop()
bStack.pop()
equal
_.isEqual = (a, b) -> extendedIsEqual(a, b)