File tree Expand file tree Collapse file tree 4 files changed +13
-13
lines changed Expand file tree Collapse file tree 4 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ const glob = require('glob')
44
55const _ = require ( 'lodash' )
66
7- const Source = require ( './source' )
7+ const SimpleSource = require ( './source' )
88const JsSource = require ( './js-source' )
99
1010const FILE_PREFIX = 'file://'
@@ -68,7 +68,7 @@ class SourceFactory {
6868 return new JsSource ( file . content )
6969 }
7070
71- return new Source ( file . content )
71+ return new SimpleSource ( file . content )
7272 }
7373}
7474
Original file line number Diff line number Diff line change 11const esprima = require ( 'esprima' )
22const debug = require ( 'debug' ) ( 'nukecss:js-source' )
3- const Source = require ( './source' )
3+ const SimpleSource = require ( './source' )
44
5- class JsSource extends Source {
5+ class JsSource {
66 constructor ( text , opts = { } ) {
7- super ( text )
7+ this . _text = text
88
99 let tokens = opts . tokens
1010 if ( ! tokens ) {
@@ -28,7 +28,7 @@ class JsSource extends Source {
2828 }
2929
3030 _findWholeSelectorInTokens ( selector ) {
31- return this . _tokensArray . find ( token => Source . textContains ( token , selector ) )
31+ return this . _tokensArray . find ( token => SimpleSource . textContains ( token , selector ) )
3232 }
3333
3434 _findSelectorPartsInTokens ( selector ) {
@@ -53,7 +53,7 @@ class JsSource extends Source {
5353 this . _findWholeSelectorInTokens ( selector ) ||
5454 this . _findSelectorPartsInTokens ( selector ) )
5555 } else {
56- return Source . textContains ( this . _text , selector )
56+ return SimpleSource . textContains ( this . _text , selector )
5757 }
5858 }
5959
Original file line number Diff line number Diff line change 1- class Source {
1+ class SimpleSource {
22 constructor ( text ) {
33 this . _text = text
44 }
@@ -8,20 +8,20 @@ class Source {
88 }
99
1010 contains ( selector ) {
11- return Source . textContains ( this . _text , selector )
11+ return SimpleSource . textContains ( this . _text , selector )
1212 }
1313
1414 join ( source ) {
1515 if ( source . type !== 'simple' ) {
16- throw new Error ( 'Source can only be joined with Source ' )
16+ throw new Error ( 'SimpleSource can only be joined with SimpleSource ' )
1717 }
1818
19- return new Source ( `${ this . _text } ${ source . _text } ` )
19+ return new SimpleSource ( `${ this . _text } ${ source . _text } ` )
2020 }
2121
2222 static textContains ( text , selector ) {
2323 return new RegExp ( `\\b${ selector } \\b` , 'i' ) . test ( text )
2424 }
2525}
2626
27- module . exports = Source
27+ module . exports = SimpleSource
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ describe('sources/factory.js', () => {
9393
9494 context ( 'when opts.simple=true' , ( ) => {
9595 const opts = { simple : true }
96- it ( 'should always use Source ' , ( ) => {
96+ it ( 'should always use SimpleSource ' , ( ) => {
9797 const content = 'const foobar = "baz"'
9898 const sources = SourceFactory . fromObject ( { content, type : 'js' } , opts )
9999 expect ( sources ) . to . have . length ( 1 )
You can’t perform that action at this time.
0 commit comments