1
0

Platform-Node.st 833 B

1234567891011121314151617181920212223242526272829303132
  1. Smalltalk createPackage: 'Platform-Node'!
  2. (Smalltalk packageAt: 'Platform-Node' ifAbsent: [ self error: 'Package not created: Platform-Node' ]) imports: {'amber/core/Platform-Services'}!
  3. Object subclass: #NodePlatform
  4. slots: {}
  5. package: 'Platform-Node'!
  6. !NodePlatform commentStamp!
  7. I am `Platform` service implementation for node-like environment.!
  8. !NodePlatform methodsFor: 'accessing'!
  9. globals
  10. ^ global
  11. ! !
  12. !NodePlatform methodsFor: 'public API'!
  13. newXhr
  14. XMLHttpRequest
  15. ifNotNil: [ ^ XMLHttpRequest new ]
  16. ifNil: [ self error: 'XMLHttpRequest not available.' ]
  17. ! !
  18. !NodePlatform class methodsFor: 'testing'!
  19. initialize
  20. self isFeasible ifTrue: [ Platform registerIfNone: self new ]
  21. !
  22. isFeasible
  23. <inlineJS: 'return typeof process !!== "undefined" && process && process.versions && process.versions.node !!= null'>
  24. ! !