mirror of
https://github.com/atom/atom.git
synced 2026-01-22 13:28:01 -05:00
Add _.isSubset
This commit is contained in:
committed by
Nathan Sobo
parent
eaba8ef016
commit
39d15d6087
@@ -107,3 +107,11 @@ describe "underscore extensions", ->
|
||||
object:
|
||||
first: 1
|
||||
second: 2
|
||||
|
||||
describe "_.isSubset(potentialSubset, potentialSuperset)", ->
|
||||
it "returns whether the first argument is a subset of the second", ->
|
||||
expect(_.isSubset([1, 2], [1, 2])).toBeTruthy()
|
||||
expect(_.isSubset([1, 2], [1, 2, 3])).toBeTruthy()
|
||||
expect(_.isSubset([], [1])).toBeTruthy()
|
||||
expect(_.isSubset([], [])).toBeTruthy()
|
||||
expect(_.isSubset([1, 2], [2, 3])).toBeFalsy()
|
||||
|
||||
@@ -195,4 +195,7 @@ _.mixin
|
||||
newObject[key] = value if value?
|
||||
newObject
|
||||
|
||||
isSubset: (potentialSubset, potentialSuperset) ->
|
||||
_.every potentialSubset, (element) -> _.include(potentialSuperset, element)
|
||||
|
||||
_.isEqual = require 'tantamount'
|
||||
|
||||
Reference in New Issue
Block a user