Platform-Node.st 595 B

123456789101112131415161718192021222324252627282930
  1. Smalltalk createPackage: 'Platform-Node'!
  2. Object subclass: #NodePlatform
  3. instanceVariableNames: ''
  4. package: 'Platform-Node'!
  5. !NodePlatform commentStamp!
  6. I am `Platform` service implementation for node-like environment.!
  7. !NodePlatform methodsFor: 'accessing'!
  8. globals
  9. ^ global
  10. !
  11. newXhr
  12. XMLHttpRequest
  13. ifNotNil: [ ^ XMLHttpRequest new ]
  14. ifNil: [ self error: 'XMLHttpRequest not available.' ]
  15. ! !
  16. !NodePlatform class methodsFor: 'testing'!
  17. initialize
  18. self isFeasible ifTrue: [ Platform registerIfNone: self new ]
  19. !
  20. isFeasible
  21. <inlineJS: 'return typeof global !!== "undefined"'>
  22. ! !